Comments (7)
Preliminary investigations show that the following benefits can be obtained with the proposed solution:
Throughput
More than a 10% performance increase in the EventLoop. (handlers/s invoked)
Latency Percentiles
About 7% latency reduction at six nines (us)
Average Latency
About 4% reduction of the average latency (ns)
Potential Drawbacks
IsolatedEventLoop
would be less favorable in cases where handlers are added and removed relatively often or in cases with a large number of handlers with mixed priority.
If we add a method runOnce()
, the drawback of adding and removing short-lived handlers could be mitigated.
Test setup:
Property | Value |
---|---|
Pauser | Busy |
OS | Mac OS, Catalina 10.15.4 |
RAM | 64 GB |
CPU | 2.3 GHz 8 core i9 |
Java | 1.8.0_191 |
Priority | 2 High, 6 Medium |
returns | true except on average 128:th time |
Other threads | Poke the wound: EventLoop::toString each ms |
Benchmark | 10s with 1 warmup and 3 measure rounds, compute compound result from the 3 measure rounds |
Cases | |
Throughput | counter++ |
Histogram | duration -> Histogram::sampleNanos |
Latency | duration -> array[i]++ |
Summary | |
Throughput | >10% improvement |
Histogram 6 9s | 7% improvement @ 10% higher load |
Average latency | 4% improvement @ 10% higher load |
from chronicle-threads.
The most common case is a small number of medium handlers
The performance of these can be improved by loop unrolling for this use case.
from chronicle-threads.
The improved VanillaEventLoop
(85ebc2e) compared with only 4 medium handlers stacks up like this compared to IsolatedVanillaLoop
:
Vanilla | Isolated | |
---|---|---|
Throughput events/s | 172578247.7 | 187162429.1 |
Latency (us) @99.99% | 0.18 | 0.18 |
Mean latency (ns) | 16.491 | 15.500 |
from chronicle-threads.
There is also MediumEventLoop which Peter introduced in December. We should apply optimisations to this too or else get rid of it.
@peter-k-lawrey did you mean for EventGroup to use it like this?
core = priorities.stream().anyMatch(VanillaEventLoop.ALLOWED_PRIORITIES::contains)
? corePriorities.equals(EnumSet.of(HandlerPriority.MEDIUM))
? new MediumEventLoop(this, name + "medium-event-loop", pauser, daemon, binding)
: new VanillaEventLoop(this, name + "core-event-loop", pauser, 1, daemon, binding, priorities)
: null;
from chronicle-threads.
@peter-k-lawrey I've made the change above
from chronicle-threads.
@JerryShea and @minborg - I assume that this can now be closed, please reopen if you feel there is more to do.
from chronicle-threads.
Released in Chronicle-Threads-2.20.102, BOM-2.20.173
from chronicle-threads.
Related Issues (20)
- False positive monitorThreadDelayed reports on almost-idle thread HOT 2
- flaky test VanillaEventLoopTest.testEnsureRemoveInvokesLoopFinishedJustOnce HOT 2
- Make image background navy
- When EventGroup startup times out, provide more information about the state of the EventLoops HOT 1
- Add a systemProperties.adoc with a table of system properties (if there are any) HOT 1
- Tuning LongPauser to be less platform sensitive
- Add paragraph to adoc about Chronicle Threads
- Add to Pauser documentation
- Add pauser graph to documentation HOT 1
- MediumEventLoop silently terminates when an IllegalStateException is thrown on startup HOT 1
- The contract for EventHandler#loopFinished is violated a lot HOT 4
- Add Information to ReadMe from landing page
- Data race between handler.eventLoop(EventLoop) and first handler execution HOT 1
- Add support for collecting the current EventLoops and their Pausers HOT 1
- EventGroup sometimes times out on start HOT 5
- Blocking loop runs jobs before event group is alive HOT 3
- EventGroupStressTest is flaky HOT 1
- NoSuchFieldException JDK 20 HOT 3
- Detect if event loop is being closed from its own thread HOT 3
- Pluggable NotifyDiskLow strategy HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chronicle-threads.