gem5 icon indicating copy to clipboard operation
gem5 copied to clipboard

base: reduce write syscalls in stats output

Open heshpdx opened this issue 4 months ago • 0 comments

std::endl flushes the output stream which invokes the write syscall. Replacing this with "\n" causes the writes to be buffered until they fill the entire memory page or buffer, and then they get flushed automatically. So this patch switches the behavior from "many small writes" to "a few large writes". This can help when many invocations of gem5 are finishing at the same time and dumping gobs and gobs of statistics.

You can check the output of strace to see what is happening. Each of the 1000s of statistics is writing ~100 bytes at a time to disk serially. This patch turns that into writes of 8192 byte chunks for my run. The perf benefit would be seen at the end of a run where your system is loaded with simulations (e.g. in a refrate style run).

@powerjg

heshpdx avatar Sep 07 '25 05:09 heshpdx