tools/cephfs: flush every journal event as soon as it is scanned
NOTE: exclusive to only `event recover_dentries`
JournalScanner::scan() runs a loop and loads the entire decoded journal in an
`EventMap` called `events`. This can severely shoot up the RSS if the journal
is huge (unflushed journal) making the tool less efficient.
The way to curb the memory bomb is to scan and flush journal in batches. The
flush boundary is based on the batch size and at event EVENT_SUBTREEMAP or
EVENT_SUBTREEMAP_TEST(subtree event(s) mark a clear boundary). The knob to
control this setting is via providing `--max-rss <bytes>` with the journal
tool command. This patch divides the provided limit by three to create the
batch since it is observed that the decoded journal events weight on an avg
~3x the encoded stream.
Also: Currently, the events map retains all decoded events until all dentries
are recovered, causing unnecessary memory retention.
Fix this by erasing each event from the map right after it is processed.
While the primary RSS bloat is caused by dnbl holding the encoded stream
in memory, this incremental cleanup provides a minor optimization until
a permanent fix is implemented (https://tracker.ceph.com/issues/77909).