From 0541ddc7e33c35a35efe85b6d6f603efb5bac8c8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 18 Nov 2006 18:56:30 +0000 Subject: [PATCH] * Turn off synchronisation between C and C++ I/O functions. This gives a huge speedup in operations that read or write from standard input/output. (So libstdc++'s I/O isn't that bad, you just have to call std::ios::sync_with_stdio(false).) For instance, `nix-store --register-substitutes' went from 1.4 seconds to 0.1 seconds on a certain input. Another victory for Valgrind. --- src/libmain/shared.cc | 2 ++ src/nix-store/main.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 00e197499..d135691a1 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -225,6 +225,8 @@ int main(int argc, char * * argv) std::cerr.rdbuf()->pubsetbuf(buf, sizeof(buf)); #endif + std::ios::sync_with_stdio(false); + try { try { initAndRun(argc, argv); diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc index 5a87806d0..8c2ff2279 100644 --- a/src/nix-store/main.cc +++ b/src/nix-store/main.cc @@ -632,7 +632,7 @@ static void opDump(Strings opFlags, Strings opArgs) } -/* A source that read restore intput to stdin. */ +/* A source that reads restore input from stdin. */ struct StdinSource : RestoreSource { virtual void operator () (unsigned char * data, unsigned int len)