Skip to content

test(coverage): cover db_compint varint codec + lock config/allocator (lock007, test143) - #85

Closed
gburd wants to merge 2 commits into
masterfrom
agent/compint-lock
Closed

test(coverage): cover db_compint varint codec + lock config/allocator (lock007, test143)#85
gburd wants to merge 2 commits into
masterfrom
agent/compint-lock

Conversation

@gburd

@gburd gburd commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Raises coverage of three cold libdb areas by adding two Tcl tests and wiring
them into the bounded coverage subset (test/coverage/run_coverage.sh
COV_TESTS):

  • common/db_compint.c — the compressed-integer (varint) codec used by
    btree compression.
  • lock/lock_method.c — the DB_ENV lock-subsystem config setters/getters.
  • lock/lock_alloc.incl — the lock-region object/locker/lock allocator
    (included into lock_region.c).

Coverage before → after

Measured on identical footing: the exact COV_TESTS subset without the two
new tests (BEFORE) vs. with them (AFTER), instrumented --coverage build in the
nix dev shell, lcov --branch-coverage (the same source of truth as the ranking).

file line before line after branch before branch after
common/db_compint.c 0.0% 15.7% 0.0% 19.3%
lock/lock_alloc.incl 0.0% 81.8% 0.0% 50.0%
lock/lock_method.c 55.8% 58.0% 28.0% 28.4%

(lock_method.c was already exercised in the subset by env020/statprint001's
getters; lock007 adds the setter paths. lock_alloc.incl and db_compint.c
were both 0% in the subset before — nothing grew the lock region or opened a
-compress btree.)

Tests added

  • lock007 (group lock) — sets every lock config knob before open
    (set_lk_max_locks/lockers/objects, set_lk_partitions,
    set_lk_tablesize, the DB_MEM_LOCK/LOCKER/LOCKOBJECT init counts, and
    set_lk_detect for all nine deadlock-detection policies + a rejected bogus
    policy), reads them back through the getters, then runs a many-locker
    workload (200 lockers × 40 distinct read-lock objects) that exhausts the
    initial lock-region free lists and forces the region-growth loop in
    lock_alloc.incl.
  • test143 (group test) — stores records into a -compress btree whose
    data sizes span the codec's 1/2/3-byte size classes (1 B … 100 KB) and reads
    them back (point-get + full cursor scan), driving __db_compress_int on
    write and __db_decompress_int32 on read plus key prefix/suffix length
    compression.

Both are registered in testparams.tcl and wired into COV_TESTS
(lock007:, test143:btree). Both PASS reliably (verified repeatedly under
timeout in both the --coverage subset run and a clean --enable-debug build).

The db_compint ceiling and the PBT tier

db_compint.c cannot reach 100% from any Tcl workload: btree compression only
ever marshals 32-bit lengths, so the 64-bit __db_decompress_int (~130 of
the file's 324 lines) and the 4–9 byte size classes are unreachable from Tcl.
Those paths are already exhaustively property-tested by
test/pbt/pbt_compint.c — a separate property-based-testing tier that
round-trips random 64-bit values through __db_compress_int /
__db_decompress_int across every size class. That tier is not part of the
Tcl coverage subset, which is why db_compint showed "cold" in the ranking even
though the codec is well covered overall. The tcl-reachable ceiling is ~24%;
test143 reaches the practical ceiling for the codec's btree-driven path. The
README documents this. (The PBT tier was not modified.)

No engine changes / no real bug

Test-only change. No src/ engine code was modified. No real bug surfaced in
the codec or the lock allocator. build_windows/* CRLF noise was
skip-worktree'd per the repo convention; no coverage artifacts committed.

gburd added 2 commits July 29, 2026 10:26
… (varint codec)

lock007 exercises every DB_ENV lock-subsystem config setter/getter
(set_lk_max_locks/lockers/objects, set_lk_partitions, set_lk_tablesize,
the DB_MEM_LOCK/LOCKER/LOCKOBJECT init counts, and set_lk_detect for all
nine deadlock-detection policies), then runs a many-locker workload
(200 lockers x 40 distinct objects) that exhausts the initial lock-region
free lists and forces the region-growth loop in lock/lock_alloc.incl.

test143 stores records into a -compress btree whose data sizes span the
compressed-integer codec's 1/2/3-byte size classes and reads them back,
driving __db_compress_int / __db_decompress_int32 in common/db_compint.c.

Register both in testparams.tcl (lock, test groups).
Adds lock007 and test143:btree to the default coverage subset and
documents the lift in the coverage README:

  common/db_compint.c   0.0% -> 15.7% (subset, identical footing)
  lock/lock_alloc.incl  0.0% -> 81.8%
  lock/lock_method.c   55.8% -> 58.0%

Notes the codec ceiling: btree compression only marshals 32-bit lengths,
so the 64-bit __db_decompress_int and the 4-9 byte size classes are
unreachable from any Tcl workload -- those are exhaustively covered by
the separate property-based tier test/pbt/pbt_compint.c.
@gburd

gburd commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by rebased branch (resolved run_coverage.sh/README conflict vs #84; re-added lock007/test143 to COV_TESTS that git auto-resolution dropped); reopening.

@gburd gburd closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant