Croway opened a new pull request, #26303:
URL: https://github.com/apache/camel/pull/26303

   Resolves the `groovy` language and the `GroovyShellFactory` once per 
`CamelContext` instead of on every evaluation, keeps the compiled script class 
in the `Expression` (checked against context, language and a generation counter 
bumped on language stop and dev-mode reload), builds the script binding lazily 
(`exchangeProperties`, `variables` and `attachments` on first access), 
instantiates the `Script` through a cached constructor `MethodHandle`, and 
compiles a script once when concurrent evaluations miss the cache.
   
   **Why.** On main every evaluation scans the registry with `findByType`, 
rebuilds the binding maps (78% of the bytes it allocates) and re-enters the 
shared script cache. Measured (JMH, JDK 21): expressions 3.0–3.7 M ops/s vs 
47.8 M for Java; the route `filter(amount > 100) → setBody(concat)` at 0.48× 
the Java route on one thread and 0.22× on eight; a 5-minute 8-thread load at 
1.08 M msg/s (0.26× Java), p99 102 µs; with more than 1,000 distinct scripts 
every evaluation recompiles (5,019 msg/s).
   
   **With this change.** Expressions 4.9–7.7× faster, route 0.94× the Java 
route on 1 and 8 threads, load 3.80 M msg/s (0.91× Java) with p99 3 µs and the 
same heap after GC, 1,500 distinct scripts 2.92 M msg/s.
   
   **Behaviour changes** (upgrade guide entry included): a `GroovyShellFactory` 
bound after the first evaluation is no longer picked up; `exchangeProperties`, 
`variables` and `attachments` are read on first access instead of when the 
binding is created. Protected `createBinding` / `instantiateScript` signatures 
are unchanged.
   
   **Tests.** 100 tests in camel-groovy (16 new: binding semantics, shell 
factory globals on InOnly exchanges, cache invalidation, constructor errors, 
single compilation under 8 threads).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   _Claude Code on behalf of Croway_
   


-- 
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]

Reply via email to