[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-developers] Patch submission
From: |
Hendrik Pagenhardt |
Subject: |
[GNUnet-developers] Patch submission |
Date: |
Mon, 12 Jan 2004 14:49:17 +0100 |
Hello,
I hacked a small patch to reduce the number of calls to
"estimateAvailableBlocks". It works by remembering the returned values
for all buckets and just refreshing those made dirty when needed. I
compiled and tested it on my tree and at least it doesn't make things
worse. Maybe a core developer can have a look at it and comment?
Ciao,
Hendrik
Index: src/applications/afs/module/manager.c
===================================================================
RCS file: /var/cvs/GNUnet/GNUnet/src/applications/afs/module/manager.c,v
retrieving revision 1.17
diff -r1.17 manager.c
27a28,29
> #include <values.h>
>
51a54,55
> #define DB_DIRTY_AVAILABLE MININT
>
307c311,313
< = MALLOC(dbAPI->buckets * sizeof(HighDBHandle*));
---
> = MALLOC(dbAPI->buckets * sizeof(HighDBHandle));
> dbAPI->dbAvailableBlocks
> = MALLOC(dbAPI->buckets * sizeof(int));
315a322,323
> dbAPI->dbAvailableBlocks[i]
> = DB_DIRTY_AVAILABLE; /* not yet initialized */
443a452,473
> * calculates the global available space using
> * cached bucket availability estimates
> **/
>
> int estimateGlobalAvailableBlocks() {
> unsigned int i;
> int ret = 0;
> int perBucketQuota = getConfigurationInt("AFS",
> "DISKQUOTA") * 1024 / dbAPI->buckets;
>
> for (i = 0; i < dbAPI->buckets; ++i) {
> if (dbAPI->dbAvailableBlocks[i] == DB_DIRTY_AVAILABLE) {
> dbAPI->dbAvailableBlocks[i]
> = dbAPI->estimateAvailableBlocks(dbAPI->dbHandles[i],
> perBucketQuota);
> }
> ret += dbAPI->dbAvailableBlocks[i];
> }
> return ret;
> }
>
> /**
486,490c516,517
< delta = 0;
< for (i=0;i<dbAPI->buckets;i++)
< delta += dbAPI->estimateAvailableBlocks(dbAPI->dbHandles[i],
< getConfigurationInt("AFS",
<
"DISKQUOTA")*1024/dbAPI->buckets);
---
> delta = estimateGlobalAvailableBlocks();
>
496a524,525
> dbAPI->dbAvailableBlocks[i]
> = DB_DIRTY_AVAILABLE;
672,673c701,704
< dbAPI->unlinkFromDB(computeHighDB(query),
< query);
---
> if (OK == dbAPI->unlinkFromDB(computeHighDB(query), query)) {
> dbAPI->dbAvailableBlocks[computeBucketGlobal(query)]
> = DB_DIRTY_AVAILABLE;
> }
722a754,755
> dbAPI->dbAvailableBlocks[computeBucketGlobal(query)]
> = DB_DIRTY_AVAILABLE;
742a776,777
> dbAPI->dbAvailableBlocks[computeBucketGlobal(query)]
> = DB_DIRTY_AVAILABLE;
793a829,830
> dbAPI->dbAvailableBlocks[computeBucketGlobal(query)]
> = DB_DIRTY_AVAILABLE;
822d858
< unsigned int i;
869,874c905
< avail = 0;
< for (i=0;i<dbAPI->buckets;i++)
< avail += dbAPI->estimateAvailableBlocks
< (dbAPI->dbHandles[i],
< getConfigurationInt("AFS",
< "DISKQUOTA")*1024/dbAPI->buckets);
---
> avail = estimateGlobalAvailableBlocks();
884a916,917
> dbAPI->dbAvailableBlocks[computeBucketGlobal(&query)]
> = DB_DIRTY_AVAILABLE;
938a972,973
> dbAPI->dbAvailableBlocks[computeBucketGlobal(&query)]
> = DB_DIRTY_AVAILABLE;
1012,1017c1047,1049
< unsigned int i;
< int delta = 0;
< for (i=0;i<dbAPI->buckets;i++)
< delta += dbAPI->estimateAvailableBlocks(dbAPI->dbHandles[i],
< getConfigurationInt("AFS",
<
"DISKQUOTA")*1024/dbAPI->buckets);
---
> dbAPI->dbAvailableBlocks[computeBucketGlobal(query)]
> = DB_DIRTY_AVAILABLE;
> int delta = estimateGlobalAvailableBlocks();
Index: src/applications/afs/module/manager.h
===================================================================
RCS file: /var/cvs/GNUnet/GNUnet/src/applications/afs/module/manager.h,v
retrieving revision 1.4
diff -r1.4 manager.h
207a208,212
> * cache estimated available blocks for each bucket
> **/
> int * dbAvailableBlocks;
>
> /**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-developers] Patch submission,
Hendrik Pagenhardt <=