Croway opened a new pull request, #22655:
URL: https://github.com/apache/camel/pull/22655
## Summary
- Pre-compile `--grep` and `--find` regex patterns once at startup instead
of calling `Pattern.compile()` on every log/trace line in the follow loop
- Cache `SimpleDateFormat` instances as fields instead of creating new ones
per line
- Add missing `Pattern.quote()` in `CamelStubAction` for consistency with
the other 3 action commands
- Extract shared `quoteAndCompilePatterns()` helper into `ActionBaseCommand`
Files changed: `ActionBaseCommand`, `CamelLogAction`, `CamelTraceAction`,
`CamelReceiveAction`, `CamelStubAction`
## Benchmark results
I know it is not a huge difference, but better than nothing — these add up
when tailing high-throughput logs with `camel log --follow --grep=ERROR`:
```
=== Fix 1: Pattern.compile per-line vs pre-compiled ===
isValidGrep (500000 iterations, 2 grep terms, 10 log lines):
OLD (Pattern.compile per line): 296.92 ms (150000 matches)
NEW (pre-compiled): 141.01 ms (150000 matches)
Speedup: 2.11x
replaceAll highlighting (500000 iterations, 2 patterns):
OLD (replaceAll per line): 358.34 ms
NEW (compiled matcher): 161.19 ms
Speedup: 2.22x
=== Fix 2: SimpleDateFormat per-line vs cached ===
SDF.format() (500000 iterations):
OLD (new SDF per call): 303.78 ms
NEW (cached SDF): 94.02 ms
Speedup: 3.23x
SDF.parse() (500000 iterations):
OLD (new SDF per call): 377.68 ms
NEW (cached SDF): 249.19 ms
Speedup: 1.52x
```
## Test plan
- [x] `mvn -DskipTests install` in `camel-jbang-core` — compiles clean
- [x] `mvn formatter:format impsort:sort` — no changes needed
- [x] `camel-jbang-core` unit tests pass
- [x] `camel-jbang-it` integration tests pass
_Claude Code on behalf of Federico Mariani_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]