Skip to content

Skip journal flush-trace loop when debug logging is disabled#4835

Merged
merlimat merged 1 commit into
apache:masterfrom
merlimat:journal-lazy-flush-trace
Jul 14, 2026
Merged

Skip journal flush-trace loop when debug logging is disabled#4835
merlimat merged 1 commit into
apache:masterfrom
merlimat:journal-lazy-flush-trace

Conversation

@merlimat

Copy link
Copy Markdown
Contributor

Motivation

After every journal flush, a second pass iterates the whole toFlush list purely to emit per-entry DEBUG trace lines. When DEBUG is disabled (the normal production configuration), the loop still runs: it allocates an Iterator per flush and walks the full list doing null checks for nothing.

Changes

Wrap the trace loop in slog's lazy consumer form, log.debug(e -> { ... }), which returns immediately without invoking the consumer when DEBUG is disabled — no iteration, no iterator. A local alias of toFlush is captured since the field variable is reassigned after the hand-off to the force-write thread (not effectively final).

Verified with BookieJournalTest and BookieJournalForceTest (22/22 pass) and module checkstyle.

@void-ptr974 void-ptr974 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@merlimat
merlimat merged commit bcb3e70 into apache:master Jul 14, 2026
20 checks passed
@merlimat
merlimat deleted the journal-lazy-flush-trace branch July 14, 2026 15:26
merlimat added a commit that referenced this pull request Jul 14, 2026
@merlimat merlimat added this to the 4.18.0 milestone Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants