output: memoize calculate_timekey to reduce redundant calculations (#5288)
**Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: `calculate_timekey` is called for every emitted record. Since logs usually arrive chronologically, consecutive records almost always fall into the same timekey. However, the current implementation performs `%` and `to_i` for every single call. When running `rake benchmark:run:in_tail` with 10 GB of data, this memoization improved the overall throughput: | Benchmark | before | after | |---|---|---| | `rake benchmark:run:in_tail` | 43.170137 | 41.584905 | **Docs Changes**: N/A **Release Note**: * output: Improve performance by memoizing calculate_timekey Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
S
Shizuo Fujita committed
f261802dbaefa40107763292c3ca33f217170d44
Parent: 7619631
Committed by GitHub <noreply@github.com>
on 3/23/2026, 3:48:30 AM