Skip to content

Draft: Improve perf for long log lines#7

Draft
seeseemelk wants to merge 2 commits into
dnovitski:masterfrom
seeseemelk:improve-perf-for-long-log-lines
Draft

Draft: Improve perf for long log lines#7
seeseemelk wants to merge 2 commits into
dnovitski:masterfrom
seeseemelk:improve-perf-for-long-log-lines

Conversation

@seeseemelk

@seeseemelk seeseemelk commented Apr 10, 2026

Copy link
Copy Markdown

When you're logging many large log lines, one can quickly exceed the AsyncWorker#MAX_BATCH_SIZE limit.

At this point, the AsyncWorker will calculate the size of each log event twice (once as part of drainBatchFromQueue->batchSize, and once as drainBatchFromQueue->eventSize).
The eventSize method internally calls String#getBytes, which calls String#encodeUTF8.

For large log lines, this call is quite expensive. Calling it twice is just unnecessary.

This caches calls to eventSize(), which in our case were consuming a significant amount of CPU usage.

When you're logging many large log lines, one can quickly exceed the MAX_BATCH_SIZE limit.
At this point, it will calculate the size of each log event twice (once as part of drainBatchFromQueue->batchSize, and once as drainBatchFromQueue->eventSize).
The eventSize method internally calls `String#getBytes`, which calls `String#encodeUTF8`. For large log lines, this call is quite expensive. Calling it twice is just unnecessary.
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