On Mon, 16 Feb 2026 19:44:15 GMT, Johan Sjölen <[email protected]> wrote:
> I guess the cost of the altsigstacks are mostly from all of those mmap calls? > We could amortize those by making them in multiples, that might take down the > cost enough to make this worth it to have by default. Future PR thoughts. Unfortunately, any form of central chunked freelist or similar would need to be lockless, since you would not want to have synchronisation inside a frequent operation like thread start. That adds complexity. But the main point is that it would not bring anything. This feature can never be anything other than optional, since it increases cost per Java thread by at least one or a few pages. That is because every application java thread (which are the majority of threads) will with high probability hit its signal handler during normal operation (eg when a safepoint happens). So they will all use their respective signal stacks, which means the first pages of each signal stack will always be paged in. These added costs per thread will never be acceptable, so it cannot be switched on by default. At least not in release builds. > src/hotspot/os/posix/threadAltSigStack_posix.cpp line 44: > >> 42: // Note: the first thread initializing this would be the main thread >> which >> 43: // still runs single-threaded. It is invoked after initial argument >> parsing. >> 44: static size_t value = 0; > > with just slightly more code you get a thread safe static (called Scott > Meyers' singleton) > > https://godbolt.org/z/zd3E5dxT4 What would be the advantage? ------------- PR Comment: https://git.openjdk.org/jdk/pull/29559#issuecomment-3976611386 PR Review Comment: https://git.openjdk.org/jdk/pull/29559#discussion_r2867151461
