RFR: 8357959: (bf) ByteBuffer.allocateDirect initialization can result in large TTSP spikes [v8]

Aleksey Shipilev shade at openjdk.org
Wed Jun 4 16:39:54 UTC 2025


On Wed, 4 Jun 2025 16:10:05 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> This may be a stupid question but why do we not just mmap large allocations in Unsafe.allocateMemory (with anonymous mappings)? These sections would then come pre-zero-initialized by the OS, no?

This is not a stupid question, but I think there are peculiarities down that path. I think we want native allocator to decide what is the mmap threshold (glibc malloc does it with configurable options). We want to make sure it is cross-platform or at least not very hairy. There might be no guarantee that all these "prezeroed" pages would not be mapped at the single zero page, which causes latency on first COW, and also likely throws off RSS accounting a bit. It might be worth exploring as deep-dive RFE. For now, it is cleaner (pun intended) to keep cleaning stuff ourselves.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/25487#issuecomment-2940691597


More information about the nio-dev mailing list