Skip to content

output: optimize branch condition in metadata generation#5289

Merged
kenhys merged 1 commit into
fluent:masterfrom
Watson1978:metadata
Mar 23, 2026
Merged

output: optimize branch condition in metadata generation#5289
kenhys merged 1 commit into
fluent:masterfrom
Watson1978:metadata

Conversation

@Watson1978

@Watson1978 Watson1978 commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:
Fixes #

What this PR does / why we need it:
This PR optimizes the branch conditions inside the metadata generation in Fluent::Plugin::Output.

In most production use cases, either time or tag (or both) are used as chunk keys.

When running rake benchmark:run:in_tail with a 10 GB file:

Benchmark before (sec) after (sec)
rake benchmark:run:in_tail 41.220453 40.671516

Docs Changes:
N/A

Release Note:

  • output: optimize branch condition in metadata generation

Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
@Watson1978 Watson1978 added this to the v1.20.0 milestone Mar 21, 2026
@Watson1978 Watson1978 requested a review from kenhys March 23, 2026 07:02
@kenhys

kenhys commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

How does it affect to <buffer []> case?

Before: [] => time,tag => time => tag
After: time,tag => time => tag => []

Because priority was changed in this case.

@Watson1978

Copy link
Copy Markdown
Contributor Author

Yes, as you pointed out, the evaluation for the <buffer []> case is deferred to the end, so it is expected to be slightly slower than before.

Since the main goal of this PR is to optimize the most common cases (using time and/or tag), I believe this slight trade-off for the empty buffer case is acceptable.

@kenhys kenhys merged commit d07ae92 into fluent:master Mar 23, 2026
36 of 37 checks passed
@Watson1978 Watson1978 deleted the metadata branch March 23, 2026 08:52
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.

2 participants