Skip to content

feat: add scatter write benchmark#92

Merged
mozhaa merged 2 commits into
developfrom
failing-benchmark
May 4, 2026
Merged

feat: add scatter write benchmark#92
mozhaa merged 2 commits into
developfrom
failing-benchmark

Conversation

@dkorbelainen

Copy link
Copy Markdown
Collaborator

No description provided.

mozhaa and others added 2 commits May 1, 2026 20:57
  1. fopen O_APPEND bug: opening with 'a'/'a+' used fopen("ab+") which
     enables O_APPEND, causing every fwrite to go to EOF regardless of
     fseek. The library manages offsets via fseek+fwrite, so 'a' must
     map to "rb+" (with "wb+" fallback for file creation).

  2. btree is_readonly for 'r+': btree was constructed with
     is_readonly=(mode_b & mode_bit::r), which is true for 'r+' since
     both r and plus bits are set. read_child() then called
     child.unmodify() preventing btree updates from being persisted to
     disk — scatter writes silently lost their index updates.
     Fix: is_readonly is true only for pure 'r' without '+', 'w', or 'a'.

  3. defragmentation mid-flush: allocator::deallocate() triggers
     maintenance() every 64 deallocs, which calls perform_defragmentation()
     from within block::~block() during clear_cache(). At that point the                                                                                                            btree index is only partially updated — remaining unflushed blocks
     still have stale addresses. Defrag read garbage data and corrupted
     the archive. Fix: pass perform_maintenance=false in the destructor.

Co-authored-by: mozhaa <mozhay2005@gmail.com>
@mozhaa mozhaa merged commit a4555c9 into develop May 4, 2026
3 checks passed
@mozhaa mozhaa deleted the failing-benchmark branch May 4, 2026 13:38
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.

2 participants