perf: skip parseMap allocation and pool dynamicpb.Message - #5
Merged
Conversation
yuzone
force-pushed
the
perf/skip-parsemap-and-pool-dynamicpb-message
branch
from
March 5, 2026 08:13
13b072f to
220e669
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Eliminate two major per-row heap allocations in the Flush hot path to reduce GC pressure and CPU overhead.
Changes
Direct processing of raw records
Process the
map[interface{}]interface{}returned by Fluent Bit's msgpack decoder directly into proto binary, removing theparseMapdeep copy intomap[string]interface{}.rawMapToBinary/rawPopulateMessage/rawSetRepeatedFieldconvertTimestampFieldsRawto convert timestamps in-place on raw records[]bytecases to all scalar converters to handle msgpack string values directlyPool dynamicpb.Message
Reuse top-level
dynamicpb.Messageinstances viasync.Poolkeyed by protoFullName, avoiding a new allocation per row.getPooledMessage/putPooledMessage/marshalAndReleasepopulateMessagefrommapToMessageto allow filling a pre-allocated messageputPooledMessageclears fields viaRange+Clear, preserving internal map bucket memoryRemove dead code
Remove functions and tests that are no longer called after the above changes:
jsonToBinary,parseMap,parseSliceconvertTimestampFields,convertTimestampValueTestParseMap,TestParseSlice,TestConvertTimestampFieldsTesting
TestRawMapToBinary_*— raw map conversion including[]bytevalues, nested structs, and repeated fieldsTestMessagePoolReuse*— verify no stale field leaks across pooled message reuseTestConvertTimestampFieldsRaw— timestamp conversion on raw recordsBenchmarkRawMapToBinary— benchmark for the raw pathTestFLBPluginFlushCtx, etc.) pass without modification