ammachado opened a new pull request, #28818: URL: https://github.com/apache/camel/pull/28818
# Description [CAMEL-26474](https://issues.apache.org/jira/browse/CAMEL-26474), a follow-up of CAMEL-26393 ([#28760](https://github.com/apache/camel/pull/28760)) under [CAMEL-25132](https://issues.apache.org/jira/browse/CAMEL-25132). `StatisticCounter.updateValue` called `LongAdder.add` even with 0, which still does a compare and set on a shared cell and changes nothing. Most nodes of a fast route complete within a millisecond, so `totalProcessingTime` was updated with 0 for the processor, route and context counters on almost every node. It now skips an update of 0. No value changes. ## Measurements Default statistics level, a 10 node route through a `ProducerTemplate`, JDK 21 in a Linux arm64 container with 9 CPUs, ParallelGC, a new JVM per run, 3 rounds alternating before and after. Not JMH. The processors do nothing, so nearly all times are 0 ms, and this is the best case for this change. A route with slower nodes gains less. | threads | before, ops/s | after, ops/s | |---|---|---| | 1 | about 540k | no measurable change (measured with the variant below) | | 4 | 792k, 912k, 985k | 1.01M, 1.06M, 1.17M | | 8 | 1.21M, 1.38M, 1.60M | 1.78M, 1.84M, 1.86M | I also tried passing one `currentTimeMillis` read to the processor, route and context counters, through a new `PerformanceCounter` overload. The combined variant gave the same results as this change alone (1.77M to 1.99M at 8 threads), so it was dropped to avoid an interface change. ## Tests 2 new tests in `ManagedPerformanceCounterTest`: an exchange that takes 0 ms still counts but adds no time, and inflight still goes down, as it is a negative update of the same class of counter. They pass on the old code too, as the skipped compare and set is not observable. To check that they can fail, I changed the condition to positive values only (3 tests failed) and to values above 1 (6 tests failed). Verified: `camel-management`, 589 tests, 0 failures, 1 skipped (not related to this change, it was not reviewed). Other modules were not run locally. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. Not run from the root folder: I ran `mvn install -Dquickly` on `camel-management`, and `git status` showed only the two changed files afterwards. # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. 🤖 Generated with [Claude Code](https://claude.com/claude-code) on behalf of Adriano Machado (@ammachado) _This was generated by an AI agent and may contain inaccuracies. Please verify before relying on it._ -- 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]
