etzel-mes commented on code in PR #28049:
URL: https://github.com/apache/camel/pull/28049#discussion_r4310891427
##########
components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java:
##########
@@ -81,14 +98,40 @@ public OpcUaClient getOpcUaClient() {
}
protected void init() {
- this.manager = new SubscriptionManager(this.configuration,
Stack.sharedScheduledExecutor(), 10_000);
+ ObjectHelper.notNull(this.camelContext, "camelContext");
+
+ // A failed request disconnects the client, which can wait for a
reconnect attempt that Milo schedules on its shared
+ // scheduled executor, so this connection handles its requests and
reconnects on an executor of its own.
+ final ThreadPoolProfile profile = new ThreadPoolProfile("MiloClient");
+ // as many threads as that executor; with one processor or with
virtual threads this is one thread, so a route
+ // that continues on it after an awaited request must not wait for
another request of this connection
+ profile.setPoolSize(Runtime.getRuntime().availableProcessors());
Review Comment:
Thanks, I measured it on a JVM limited to 8 processors
(`-XX:ActiveProcessorCount=8`) against a local Milo server, two runs each:
- Idle after 30 connections: 240 `MiloClient` threads, as you wrote (319
platform threads in total, 56 on main). Resident memory did not change
measurably; reserved thread stacks did.
- 30 connections × 4 callers, each awaited write followed by 10 ms of
blocking work in the route: 7,200–9,500 exchanges/s, ~690/s on main, where
Milo's 8 shared threads ran the routes of all connections.
- With `camel.threads.virtual.enabled=true`, 1 connection × 32 callers with
the same work: ~86/s, ~670/s on main. This is the single worker you describe.
So I'll follow your suggestion in a follow-up: one scheduled thread per
connection for the reconnect job and a cached pool for the request completions,
so that idle threads time out and virtual threads get a thread per completion.
I'll open a JIRA for it and send the PR once it is measured the same way.
_Claude Code on behalf of etzel-mes_
--
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]