As seen multiple times, when using the BDB backend there is quite some overhead in WRITE
for files with ALTERNATE
keys hat have a WITH DUPLICATES
clause.
The last mention that also provides test programs for that are noted in [bugs:#928].
Analyzing this showed:
With BDB 5.3: 98.9% of the cpu cycles are spent in
indexed_write_internal
(libcob), below that with 97.4% in the functionget_dupno()
- this is getting the highest number of the alternate keys, and that check needs to be done for each of it on every write, to create an unique key for the alternate "databases".
This FR is about improving get_dupno()
, which currently reads forward until no duplicate is found.
The idea is to "increment" the actual key, then reading backwards.
First "roughly tested" new version of
get_dupno()
:The perf counters are quite promising, result before/after the change with the attached test program (99,999
WRITES
, each with 13ALTERNATE
keys, allWITH DUPLICATES
, non withSUPRRESS KEY
):before, DB_HOME not set:
after, DB_HOME not set
After, DB_HOME set:
This is a nice result: the new code takes 0.1% of the instructions and 0.32% of the time :-)
Last edit: Simon Sobisch 2023-11-10