From e029e76c20dbad56e19daddf69168115250a7955 Mon Sep 17 00:00:00 2001 From: vuule Date: Fri, 29 Apr 2022 11:44:29 -0700 Subject: [PATCH 1/2] flush before creating a process to drop caches --- cpp/benchmarks/io/cuio_common.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/benchmarks/io/cuio_common.cpp b/cpp/benchmarks/io/cuio_common.cpp index 7d356263220..4f97d4a6333 100644 --- a/cpp/benchmarks/io/cuio_common.cpp +++ b/cpp/benchmarks/io/cuio_common.cpp @@ -145,6 +145,8 @@ std::vector segments_in_chunk(int num_segments, int num_chunks, // Executes the command and returns stderr output std::string exec_cmd(std::string_view cmd) { + // Prevent the output from the command from mixing with the original process' output + fflush(nullptr); // Switch stderr and stdout to only capture stderr auto const redirected_cmd = std::string{"( "}.append(cmd).append(" 3>&2 2>&1 1>&3) 2>/dev/null"); std::unique_ptr pipe(popen(redirected_cmd.c_str(), "r"), pclose); From 4f217078ee81d1a37b0868ec50c58d452faa8911 Mon Sep 17 00:00:00 2001 From: vuule Date: Fri, 29 Apr 2022 15:24:18 -0700 Subject: [PATCH 2/2] switch to std fflush --- cpp/benchmarks/io/cuio_common.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/benchmarks/io/cuio_common.cpp b/cpp/benchmarks/io/cuio_common.cpp index 4f97d4a6333..da64c1bbf3c 100644 --- a/cpp/benchmarks/io/cuio_common.cpp +++ b/cpp/benchmarks/io/cuio_common.cpp @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -146,7 +147,7 @@ std::vector segments_in_chunk(int num_segments, int num_chunks, std::string exec_cmd(std::string_view cmd) { // Prevent the output from the command from mixing with the original process' output - fflush(nullptr); + std::fflush(nullptr); // Switch stderr and stdout to only capture stderr auto const redirected_cmd = std::string{"( "}.append(cmd).append(" 3>&2 2>&1 1>&3) 2>/dev/null"); std::unique_ptr pipe(popen(redirected_cmd.c_str(), "r"), pclose);