4 ms·
It's an interesting technique that I haven't seen before in the context of a queue. It's not without drawbacks, relying on handling sigsegv is a pain to make p
by eloff 10y ago
It's an interesting technique that I haven't seen before in the context of a queue.
It's not without drawbacks, relying on handling sigsegv is a pain to make portable (libsigsegv helps!) HotSpot handles sigsegv, but I think it's possible to install your own handler as well by setting it before loading the JVM. When the JVM loads it will chain pre-existing signal handlers behind its own, and they'll be invoked if the signal doesn't pertain to HotSpot. LD_PRELOAD can be used to accomplish that. My information may only apply to an older version of HotSpot though, I don't know if that's still the case.
The other thing is relying on the TLB here becomes trickier with huge pages. It seems to me that the section and queue boundary trap pages are set just once at queue init and then never changed - so one could do the same with 2mb huge pages, without wasting memory, if the sections are sufficiently large. The problem is that requires the producer and consumer to be at least 2mb of queue apart, which is probably too much delay for many applications where latency is important. But I really don't see the need for huge pages here. A queue where both producer and consumer are repeatedly touching the same page seems like the ideal use case for the TLB anyway.
Not all applications can tolerate a sectioned queue though, for example what happens when the producer writes less than a full section of items to the queue and then pauses for a long time? The consumer won't be able to access that data until the producer finishes the section.
- stcredzero 10y agorelying on handling sigsegv is a pain to make portable Is there any effect due to virtualization?