Repository navigation
out_s3: build the chunk debug message only when debug is on - #485
Merged
Merged
Conversation
The message was interpolated at the call site, so dump_unique_id_hex, Metadata#to_s and the concatenation ran on every chunk write even at the default log level, where Fluent::Log#debug returns before printing anything. - Pass a block instead, which moves that work behind the level check: 1000 bytes and 12 objects per call become 40 bytes and 1 at log_level info, measured with fluentd 1.19.3 on Ruby 4.0.6 - The logged line is unchanged when debug is on Signed-off-by: Shizuo Fujita <fujita@clear-code.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
kenhys
approved these changes
Aug 20, 2026
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.
out_s3interpolates its two chunk debug messages at the call site, sodump_unique_id_hex,Fluent::Plugin::Buffer::Metadata#to_sand the concatenation all run on every chunk write — including at the default log level, whereFluent::Log#debugreturns on its first line without printing anything. Passing a block moves that work behind the level check.Metadataandunique_id: atlog_level infothe current form costs 12 objects / 1000 B / 1.417 µs per call, the block form 1 object / 40 B / 0.044 µs. Atlog_level debugthe two are identical (22 objects / 3240 B / ~2.3 µs)log.debug { ... }is enough here.log.on_debug { log.debug ... }removes the remainingProcallocation and reaches 0 B, but 40 bytes does not pay for the extra nestingwritepath