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

RunOnVirtualThread should avoid using Netty FastThreadLocals #39061

Closed
franz1981 opened this issue Feb 28, 2024 · 4 comments · Fixed by #39704
Closed

RunOnVirtualThread should avoid using Netty FastThreadLocals #39061

franz1981 opened this issue Feb 28, 2024 · 4 comments · Fixed by #39704
Labels
area/vertx area/virtual-threads Issue related to Java's Virtual Threads kind/bug Something isn't working
Milestone

Comments

@franz1981
Copy link
Contributor

franz1981 commented Feb 28, 2024

During the jackson serialization we currently uses (off-heap) pooled ByteBufs using Netty's pooled allocator, but this could be inefficient, because pooled ByteBuf still uses Recyclers at https://github.com/netty/netty/blob/4ba1c3e7e190bdc9bdd0ece237042f16e843c797/buffer/src/main/java/io/netty/buffer/PooledUnsafeDirectByteBuf.java#L39, which are using https://github.com/netty/netty/blob/4ba1c3e7e190bdc9bdd0ece237042f16e843c797/common/src/main/java/io/netty/util/Recycler.java#L180 which uses FastThreadLocals.

This is visibile in this flamergraphs as well:
Screenshot from 2024-02-28 16-23-58

Possible solutions are:

  1. fixing Netty
  2. bytecode rewrite it on us, again
  3. thanks to Batching buffer with minChunkSize #32858 we could avoid allocating PooledBuffer(s) for virtual thread(s) and just use unpooled heap-based ones (which doesn't use the Recycler - in short, what Vertx usually does BTW)
@franz1981 franz1981 added the kind/bug Something isn't working label Feb 28, 2024
@quarkus-bot quarkus-bot bot added the area/virtual-threads Issue related to Java's Virtual Threads label Feb 28, 2024
Copy link

quarkus-bot bot commented Feb 28, 2024

/cc @cescoffier (virtual-threads), @ozangunalp (virtual-threads)

@franz1981
Copy link
Contributor Author

@cescoffier @dmlloyd I'll soon open something related fast-thread locals vs blocking thread pool as well

@franz1981
Copy link
Contributor Author

@vietj too

@cescoffier
Copy link
Member

Let's avoid (2) - we went that route, it still hurts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertx area/virtual-threads Issue related to Java's Virtual Threads kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants