Skip to content

GH-4084: Fix ByteBufferPool sizing in Fuseki's Jetty Server#4088

Open
divyankshah wants to merge 1 commit into
apache:mainfrom
divyankshah:fix/gh-4084-bytebufferpool
Open

GH-4084: Fix ByteBufferPool sizing in Fuseki's Jetty Server#4088
divyankshah wants to merge 1 commit into
apache:mainfrom
divyankshah:fix/gh-4084-bytebufferpool

Conversation

@divyankshah

Copy link
Copy Markdown

Fixes #4084

Fuseki builds its Jetty Server with new Server(threadPool), which wires in a
default ArrayByteBufferPool capped at 64KB. Fuseki configures a 5MB
outputBufferSize, so every output buffer exceeds the pool's max capacity and gets
discarded on release instead of reused, causing continuous DirectMemory churn under
load. Full analysis in #4084.

This fixes it in JettyServer.jettyServer(...), the shared factory both
JettyHttps.java and FusekiServer.java call, so neither file needs changes.
Constructs an ArrayByteBufferPool sized to
FusekiSystemConstants.jettyOutputBufferSize and passes it into
Server(ThreadPool, Scheduler, ByteBufferPool) at construction time (adding the pool
via addBean() afterward doesn't work, since the default pool is already wired in
during construction).

Added a test asserting the built server's pool max capacity covers the configured
output buffer size. Full jena-fuseki-main suite passes (799/799).

Fuseki builds its Jetty Server with new Server(threadPool), which wires
in a default ArrayByteBufferPool capped at 64KB. Fuseki configures a 5MB
outputBufferSize, so output buffers exceed the pool's max capacity and
are discarded on release instead of reused, causing continuous
DirectMemory churn under load.

Fixed in JettyServer.jettyServer(...), the shared factory both
JettyHttps.java and FusekiServer.java call, so neither file needs
changes. Constructs an ArrayByteBufferPool sized to
FusekiSystemConstants.jettyOutputBufferSize and passes it into
Server(ThreadPool, Scheduler, ByteBufferPool) at construction time,
since adding the pool via addBean() afterward has no effect (the
default pool is already wired in during construction).
}
}

public static Server jettyServer(int minThreads, int maxThreads) {

@AniRamadoss AniRamadoss Jul 24, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Did we also want to address the other route that Andy mentioned on #4084 (comment) ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @AniRamadoss, Thank you for asking - yes, it's covered. FusekiServer.java#L1907 calls
JettyServer.jettyServer(minThreads, maxThreads), the same shared factory I fixed. Since
the pool construction now lives inside that factory, both JettyHttps.java and
FusekiServer.java inherit the fix automatically also neither file needed direct changes,
it is dependent on JettyServer.java.

I confirmed this by tracing both call sites before submitting, also happy to paste the
exact call chain here if it's useful for review.

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.

[Jena 4.x] - Fuseki Memory Churn When Serving HTTP Responses

2 participants