Stefan Hajnoczi writes: > 1. Writing the trace buffer is currently synchronous - fwrite(3) is > used by the unlucky caller that fills up the trace buffer. Ideally > traces should never block and write-out would be asynchronous. With a > regular file I'm not sure how much of an issue this is to performance, > since the kernel could copy the trace buffer to the page cache and > write it out sometime later. I've avoided adding a dedicated thread > because it will make the code more complex - any thoughts?
I think the only reliable and non-multithreaded way to do it would be to use aio_write(3). Then, total buffer size and the threshold to trigger an aio_write should be tuned to match the current disk throughput in order to eliminate emulation stalls. But this doesn't sound much easier than a producer-consumer threading scheme. Lluis -- "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth