diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-19 12:43:09 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-19 05:38:07 +0200 |
commit | b888bc4316f3f9c74b6768ddb1db1ec8fbac975e (patch) | |
tree | 265f0b7f53ceb5959dd32bd5698f8bb4665bfe17 /lib/ntdb/test | |
parent | 8fdd20b22f6b27b616b5b3a2285a267ffae0a262 (diff) | |
download | samba-b888bc4316f3f9c74b6768ddb1db1ec8fbac975e.tar.gz samba-b888bc4316f3f9c74b6768ddb1db1ec8fbac975e.tar.bz2 samba-b888bc4316f3f9c74b6768ddb1db1ec8fbac975e.zip |
ntdb: optimize ntdb_fetch.
We access the key on lookup, then access the data in the caller. It
makes more sense to access both at once. We also put in a likely()
for the case where the hash is not chained.
Before:
Adding 1000 records: 3644-3724(3675) ns (129656 bytes)
Finding 1000 records: 1596-1696(1622) ns (129656 bytes)
Missing 1000 records: 1409-1525(1452) ns (129656 bytes)
Traversing 1000 records: 1636-1747(1668) ns (129656 bytes)
Deleting 1000 records: 3138-3223(3175) ns (129656 bytes)
Re-adding 1000 records: 3278-3414(3329) ns (129656 bytes)
Appending 1000 records: 5396-5529(5426) ns (253312 bytes)
Churning 1000 records: 9451-10095(9584) ns (253312 bytes)
smbtorture results (--entries=1000)
ntdb speed 183881-191112(188223) ops/sec
After:
Adding 1000 records: 3590-3701(3640) ns (129656 bytes)
Finding 1000 records: 1539-1605(1566) ns (129656 bytes)
Missing 1000 records: 1398-1440(1413) ns (129656 bytes)
Traversing 1000 records: 1629-2015(1710) ns (129656 bytes)
Deleting 1000 records: 3118-3236(3163) ns (129656 bytes)
Re-adding 1000 records: 3235-3355(3275) ns (129656 bytes)
Appending 1000 records: 5335-5444(5385) ns (253312 bytes)
Churning 1000 records: 9350-9955(9494) ns (253312 bytes)
smbtorture results (--entries=1000)
ntdb speed 180559-199981(195106) ops/sec
Diffstat (limited to 'lib/ntdb/test')
-rw-r--r-- | lib/ntdb/test/run-04-basichash.c | 24 | ||||
-rw-r--r-- | lib/ntdb/test/run-15-append.c | 2 | ||||
-rw-r--r-- | lib/ntdb/test/run-64-bit-tdb.c | 2 |
3 files changed, 14 insertions, 14 deletions
diff --git a/lib/ntdb/test/run-04-basichash.c b/lib/ntdb/test/run-04-basichash.c index 41b49239cb..264932b988 100644 --- a/lib/ntdb/test/run-04-basichash.c +++ b/lib/ntdb/test/run-04-basichash.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) v = 0; /* Should not find it. */ - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == 0); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == 0); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have located space in top table, bucket 0. */ @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) ok1(ntdb_check(ntdb, NULL, NULL) == 0); /* Now, this should give a successful lookup. */ - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == new_off); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == new_off); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have located it in top table, bucket 0. */ @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) /* Test expansion. */ v = 1; - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == 0); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == 0); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have located clash in toplevel bucket 0. */ @@ -131,7 +131,7 @@ int main(int argc, char *argv[]) /* Should be able to find both. */ v = 1; - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == new_off2); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == new_off2); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have located space in chain. */ @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) ok1(ntdb_unlock_hash(ntdb, h.h, F_WRLCK) == 0); v = 0; - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == new_off); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == new_off); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have located space in chain. */ @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) /* Should still be able to find other record. */ v = 1; - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == new_off2); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == new_off2); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have located space in chain. */ @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) /* Now should find empty space. */ v = 0; - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == 0); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == 0); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have located space in chain, bucket 0. */ @@ -201,7 +201,7 @@ int main(int argc, char *argv[]) /* Adding another record should work. */ v = 2; - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == 0); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == 0); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have located space in chain, bucket 0. */ @@ -229,7 +229,7 @@ int main(int argc, char *argv[]) /* Adding another record should cause expansion. */ v = 3; - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == 0); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == 0); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should not have located space in chain. */ @@ -255,7 +255,7 @@ int main(int argc, char *argv[]) ok1(ntdb_unlock_hash(ntdb, h.h, F_WRLCK) == 0); /* Retrieve it and check. */ - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == new_off); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == new_off); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have appended to chain, bucket 2. */ @@ -272,7 +272,7 @@ int main(int argc, char *argv[]) /* YA record: relocation. */ v = 4; - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == 0); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == 0); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should not have located space in chain. */ @@ -298,7 +298,7 @@ int main(int argc, char *argv[]) ok1(ntdb_unlock_hash(ntdb, h.h, F_WRLCK) == 0); /* Retrieve it and check. */ - ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec) == new_off); + ok1(find_and_lock(ntdb, key, F_WRLCK, &h, &rec, NULL) == new_off); /* Should have created correct hash. */ ok1(h.h == ntdb_hash(ntdb, key.dptr, key.dsize)); /* Should have appended to chain, bucket 2. */ diff --git a/lib/ntdb/test/run-15-append.c b/lib/ntdb/test/run-15-append.c index 97fd53c241..a797944b53 100644 --- a/lib/ntdb/test/run-15-append.c +++ b/lib/ntdb/test/run-15-append.c @@ -12,7 +12,7 @@ static ntdb_off_t ntdb_offset(struct ntdb_context *ntdb, NTDB_DATA key) struct ntdb_used_record urec; struct hash_info h; - off = find_and_lock(ntdb, key, F_RDLCK, &h, &urec); + off = find_and_lock(ntdb, key, F_RDLCK, &h, &urec, NULL); if (NTDB_OFF_IS_ERR(off)) return 0; ntdb_unlock_hash(ntdb, h.h, F_RDLCK); diff --git a/lib/ntdb/test/run-64-bit-tdb.c b/lib/ntdb/test/run-64-bit-tdb.c index 5afdd8747c..582deb2234 100644 --- a/lib/ntdb/test/run-64-bit-tdb.c +++ b/lib/ntdb/test/run-64-bit-tdb.c @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) ok1(ntdb_check(ntdb, NULL, NULL) == NTDB_SUCCESS); /* Make sure it put it at end as we expected. */ - off = find_and_lock(ntdb, k, F_RDLCK, &h, &rec); + off = find_and_lock(ntdb, k, F_RDLCK, &h, &rec, NULL); ok1(off >= ALMOST_4G); ntdb_unlock_hash(ntdb, h.h, F_RDLCK); |