Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
f2c286c9
Commit
f2c286c9
authored
Dec 01, 2010
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdb2: add comparison stats
parent
4e185ad8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
10 deletions
+38
-10
ccan/tdb2/hash.c
ccan/tdb2/hash.c
+20
-10
ccan/tdb2/tdb2.h
ccan/tdb2/tdb2.h
+6
-0
ccan/tdb2/tools/speed.c
ccan/tdb2/tools/speed.c
+12
-0
No files found.
ccan/tdb2/hash.c
View file @
f2c286c9
...
...
@@ -85,32 +85,42 @@ static bool match(struct tdb_context *tdb,
tdb_off_t
val
,
struct
tdb_used_record
*
rec
)
{
bool
ret
;
bool
ret
=
false
;
const
unsigned
char
*
rkey
;
tdb_off_t
off
;
add_stat
(
tdb
,
compares
,
1
);
/* Desired bucket must match. */
if
(
h
->
home_bucket
!=
(
val
&
TDB_OFF_HASH_GROUP_MASK
))
return
false
;
if
(
h
->
home_bucket
!=
(
val
&
TDB_OFF_HASH_GROUP_MASK
))
{
add_stat
(
tdb
,
compare_wrong_bucket
,
1
);
return
ret
;
}
/* Top bits of offset == next bits of hash. */
if
(
bits
(
val
,
TDB_OFF_HASH_EXTRA_BIT
,
TDB_OFF_UPPER_STEAL_EXTRA
)
!=
bits
(
h
->
h
,
64
-
h
->
hash_used
-
TDB_OFF_UPPER_STEAL_EXTRA
,
TDB_OFF_UPPER_STEAL_EXTRA
))
return
false
;
TDB_OFF_UPPER_STEAL_EXTRA
))
{
add_stat
(
tdb
,
compare_wrong_offsetbits
,
1
);
return
ret
;
}
off
=
val
&
TDB_OFF_MASK
;
if
(
tdb_read_convert
(
tdb
,
off
,
rec
,
sizeof
(
*
rec
))
==
-
1
)
return
false
;
return
ret
;
/* FIXME: check extra bits in header? */
if
(
rec_key_length
(
rec
)
!=
key
->
dsize
)
return
false
;
if
(
rec_key_length
(
rec
)
!=
key
->
dsize
)
{
add_stat
(
tdb
,
compare_wrong_keylen
,
1
);
return
ret
;
}
rkey
=
tdb_access_read
(
tdb
,
off
+
sizeof
(
*
rec
),
key
->
dsize
,
false
);
if
(
!
rkey
)
return
false
;
ret
=
(
memcmp
(
rkey
,
key
->
dptr
,
key
->
dsize
)
==
0
);
return
ret
;
if
(
memcmp
(
rkey
,
key
->
dptr
,
key
->
dsize
)
==
0
)
ret
=
true
;
else
add_stat
(
tdb
,
compare_wrong_keycmp
,
1
);
tdb_access_release
(
tdb
,
rkey
);
return
ret
;
}
...
...
ccan/tdb2/tdb2.h
View file @
f2c286c9
...
...
@@ -126,6 +126,12 @@ struct tdb_attribute_stats {
uint64_t
alloc_coalesce_race
;
uint64_t
alloc_coalesce_succeeded
;
uint64_t
alloc_coalesce_num_merged
;
uint64_t
compares
;
uint64_t
compare_wrong_bucket
;
uint64_t
compare_wrong_offsetbits
;
uint64_t
compare_wrong_keylen
;
uint64_t
compare_wrong_rechash
;
uint64_t
compare_wrong_keycmp
;
uint64_t
expands
;
uint64_t
frees
;
uint64_t
locks
;
...
...
ccan/tdb2/tools/speed.c
View file @
f2c286c9
...
...
@@ -65,6 +65,18 @@ static void dump_and_clear_stats(struct tdb_attribute_stats *stats)
(
unsigned
long
long
)
stats
->
alloc_coalesce_succeeded
);
printf
(
" alloc_coalesce_num_merged = %llu
\n
"
,
(
unsigned
long
long
)
stats
->
alloc_coalesce_num_merged
);
printf
(
"compares = %llu
\n
"
,
(
unsigned
long
long
)
stats
->
compares
);
printf
(
" compare_wrong_bucket = %llu
\n
"
,
(
unsigned
long
long
)
stats
->
compare_wrong_bucket
);
printf
(
" compare_wrong_offsetbits = %llu
\n
"
,
(
unsigned
long
long
)
stats
->
compare_wrong_offsetbits
);
printf
(
" compare_wrong_keylen = %llu
\n
"
,
(
unsigned
long
long
)
stats
->
compare_wrong_keylen
);
printf
(
" compare_wrong_rechash = %llu
\n
"
,
(
unsigned
long
long
)
stats
->
compare_wrong_rechash
);
printf
(
" compare_wrong_keycmp = %llu
\n
"
,
(
unsigned
long
long
)
stats
->
compare_wrong_keycmp
);
printf
(
"expands = %llu
\n
"
,
(
unsigned
long
long
)
stats
->
expands
);
printf
(
"frees = %llu
\n
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment