Skip to content
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

Revert "Remove unnecessary synchronization when creating Resource instances #34476

Merged
merged 1 commit into from
Jul 4, 2023

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Jul 3, 2023

Turns out that #34339 is worse for performance...

Verified by @franz1981.

The reason is that the creation of the BeanInstance costs more than the volatile read

@franz1981
Copy link
Contributor

BeanInstance costs more than the volatile read

Yep, the relevant profile data show this stack trace (that wasn't present prior the mentioned changes):
image
The violet bar is io/quarkus/resteasy/reactive/common/runtime/ArcBeanFactory.createInstance

And the cost of such is (for Techempower plaintext, which is heavily CPU bound) is ~9% of the cpu cost for io/quarkus/resteasy/reactive/server/runtime/QuarkusResteasyReactiveRequestContext.invokeHandler, and given that the test is CPU bound, it directly translate in a ~9% max throughput drop (from 4.5 M req/sec to 4.1 M req/sec).
Other scenarios (not CPU limited) would likely experience a minor drop, likely, but it still seems a work we can save.

@geoand
Copy link
Contributor Author

geoand commented Jul 3, 2023

Just adding for posterity on why this is faster:

Each JAX-RS method will be handled by its own InstanceHandler which in turn creates the CDI bean (which is a singleton by default) that includes the aforementioned method. It follows that we don't need to keep calling Arc for each request to get that instance

Copy link
Contributor

@franz1981 franz1981 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the synchronized block happen just once per endpoint, it's not that important to improve it (at a first analysis)

@geoand geoand added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jul 3, 2023
@geoand geoand merged commit 5d1fc20 into main Jul 4, 2023
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jul 4, 2023
@geoand geoand deleted the revert-34339-rr-instance branch July 4, 2023 06:25
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants