-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip phase tracking notifiers at registration time rather than post time #66
base: 6.2.x
Are you sure you want to change the base?
Skip phase tracking notifiers at registration time rather than post time #66
Conversation
…rs-at-registration-time
I genuinely don't know how to test this. EventBus is still really foreign to me. But the code looks sane. I'll leave this to Lex. |
TLDR the PR is marked as a draft with minimal explanation because I was trying to troubleshoot what turned out to be a JVM bug. Allow me to elaborate what this PR does and how... First off, EventBus has a feature called "phase tracking" - this is basically telling events what priority they're in, which is used to prevent cancelling during the monitor phase. It does this by adding extra listeners for each priority that run just before the user defined listeners. Currently, the phase tracking notifiers are always registered, even if the EventBus they're associated with has phase tracking disabled. To effectively disable these notifiers, it does an if check and class comparison for every listener on every post. This PR makes it so that if check is unnecessary as it instead lets the In theory this should provide a nice performance uplift to posting, as it decreases the array size returned by the getListeners() method, makes the loop more predictable to the JIT and reduces the amount of work to do on each iteration. In practice, posting a single listener is faster with this PR but posting hundreds is counter-intuitively slower. I have absolutely no idea why and at this point I'm convinced it's a JVM bug. To test this, run the JMH task with |
That's rough |
I have a suspission it has to do with the field becoming package private and list.phaseTracking not being final. |
Superseded by #69, which completely redesigns EventBus. Re-open if you want this as a candidate for a 6.2 release. |
This removes the need for additional checks per listener when posting.