improve performance of Vertx timer#5990
Conversation
|
Unless you spotted this on a hot path, I don't think I want to trade readability for performance in a case that seems to be narrow. |
|
Timer is quite the hot path for a lot of operations especially if using VT |
|
@zekronium yes timers is certainly worth it |
|
So yes, this was a hot path. I didn't see any regressions. Some memory improvements. |
|
@re-thc can you only contribute this change and discard the rest ? |
|
@vietj done |
|
can you update the title of the issue as well as the description and what it changes |
|
please merge in single commit and follow the commit format: motivation/changes/results |
|
@vietj done |
|
@re-thc can you update the motivation / PR title to specifically that you are improving the performance of vertx timer, that's what I meant. Currently as is we see "optimize vertx memory" or "Replace Atomic with Var Handle / Volatile to reduce memory usage." which is very generic and is not explanatory instead we should know that it impacts timer, e.g. Title : improve performance of Vertx timer Motivation: vertx timer handling and cancellation accesses a volatile field, this could be improved using an updater Changes: replace direct access to volatile field in timer with updater |
|
@vietj PR updated |
Motivation: InternalTimerHandler used AtomicBoolean for disposal tracking, which adds an object allocation and extra indirection in a hot timer path. Changes: - Replaced the per-instance AtomicBoolean disposed field with a volatile boolean field. - Added a static VarHandle for InternalTimerHandler.disposed and a disposedCAS helper to preserve atomic compare-and-set behavior where required. - Kept periodic timer execution checks as volatile reads while retaining one-shot/cancel atomicity. Results: mvn -pl vertx-core -DskipTests compile passes.
|
thanks @re-thc |
Motivation: vertx timer handling and cancellation accesses a volatile field, this could be improved using an updater. Fixes #4971.
Changes: replace direct access to volatile field in timer with updater