From 26f3587d4bf60fe3c82084a7661c4f856534725f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 14 Sep 2011 08:10:13 +0930 Subject: tdb2: add stats to tdb1 backend. It's actually quite a good fit; we use compare_wrong_bucket for dead records, which is kind of correct (they should be in the free list). Signed-off-by: Rusty Russell (Imported from CCAN commit a3e4ebff2eb9dc2e386160b8acf77d70236f4def) --- lib/tdb2/tdb1_tdb.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lib/tdb2/tdb1_tdb.c') diff --git a/lib/tdb2/tdb1_tdb.c b/lib/tdb2/tdb1_tdb.c index 98f830cc9a..9730dceffc 100644 --- a/lib/tdb2/tdb1_tdb.c +++ b/lib/tdb2/tdb1_tdb.c @@ -89,11 +89,18 @@ static tdb1_off_t tdb1_find(struct tdb_context *tdb, TDB_DATA key, uint32_t hash if (tdb1_rec_read(tdb, rec_ptr, r) == -1) return 0; - if (!TDB1_DEAD(r) && hash==r->full_hash - && key.dsize==r->key_len - && tdb1_parse_data(tdb, key, rec_ptr + sizeof(*r), - r->key_len, tdb1_key_compare, - NULL) == 0) { + tdb->stats.compares++; + if (TDB1_DEAD(r)) { + tdb->stats.compare_wrong_bucket++; + } else if (key.dsize != r->key_len) { + tdb->stats.compare_wrong_keylen++; + } else if (hash != r->full_hash) { + tdb->stats.compare_wrong_rechash++; + } else if (tdb1_parse_data(tdb, key, rec_ptr + sizeof(*r), + r->key_len, tdb1_key_compare, + NULL) != 0) { + tdb->stats.compare_wrong_keycmp++; + } else { return rec_ptr; } /* detect tight infinite loop */ -- cgit