quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Contention on io.vertx.core.http.impl.Http1xServerConnection

Open Sanne opened this issue 6 months ago • 6 comments

Describe the bug

Have been profiling a sample Quarkus application under load; as load increases we have a scalability problem as the contention grows on a lock round io.vertx.core.http.impl.Http1xServerConnection:

Image

( The above is a flamegraph created by running asynch-profiler with options -e lock )

Expected behavior

There should be no significant contention limiting scalability.

N.B. This benchmark has different scenarious: the ones which hit a fully reactive endpoint don't have any contention, the problem seems to affect endpoints which have to perform some blocking operation, in this case queries over Hibernate ORM (blocking).

Sanne avatar Jun 11 '25 13:06 Sanne

@barreiro

franz1981 avatar Jun 11 '25 14:06 franz1981

cc @vietj

geoand avatar Jun 12 '25 08:06 geoand

The comment at the top of the class might be interesting:

  • This class is optimised for performance when used on the same event loop. However it can be used safely from other threads.
  • The internal state is protected using the synchronized keyword. If always used on the same event loop, then
  • we benefit from biased locking which makes the overhead of synchronized near zero.

gsmet avatar Jun 12 '25 08:06 gsmet

In vertx 5 this will be gone, but till that moment, we can still hit this

franz1981 avatar Jun 12 '25 08:06 franz1981

Is anyone planning to work on this?

Sanne avatar Jun 15 '25 16:06 Sanne

@Sanne I asked @barreiro to investigate on it

franz1981 avatar Jun 15 '25 16:06 franz1981

I think we can accept Luis patch, indeed this code was written assuming event-loop and non blocking was mainly used.

In Vert.x 5, this has been replaced by the outbound message queue that uses atomics + batching

vietj avatar Jun 19 '25 21:06 vietj

Thanks @vietj and @barreiro ! Looking forward to it, I'm eager to test some other performance improvements and this one is a key piece of a larger plan.

Incidentally, I'm also looking forward to Quarkus using Vert.x 5...

Sanne avatar Jun 20 '25 07:06 Sanne