3 ms·
Although these are important real-world cases, I think this kind of high-throughput file processing mostly benchmarks something other than the core language des
by _delirium 17y ago
Although these are important real-world cases, I think this kind of high-throughput file processing mostly benchmarks something other than the core language design. More or less: 1) how good are the I/O libraries and string-processing libraries?; and 2) how obvious is it which ones to use, and how to use them, for peak performance in your use case? As he noted, he got a 4x speedup in Scala by just shuffling around his use of the Scala library functions, so this sort of benchmarking is quite sensitive to seemingly minor choices.
This kind of I/O benchmarking is also more sensitive than most to the particular choice of hardware. Results might come out totally differently on a different kind of hard drive, 32-bit v. 64-bit, different OS or filesystem, etc.
The various entries in the Wide Finder competition give a good overview of the kinds of tricks that can make a difference when you throw another wrench in the works by combining high-throughput I/O with multiprocessing (some of the tweaks aren't multiprocessing-specific, though): http://www.tbray.org/ongoing/When/200x/2007/09/20/Wide-Finder http://www.tbray.org/ongoing/When/200x/2007/09/20/Wide-Finde...
- barrkel 17y agoIndeed. And C gives you such crummy tools for string manipulation that you are almost forced to hand-write anything interesting, so it's not surprising that it ends up doing well.
- _delirium 17y agoThat's one way to avoid having slow or misused library functions kill you in benchmarks-- don't give the user many library functions. ;-)
- sandGorgon 17y agoWhat about Boost strings - http://www.boost.org/doc/libs/1_39_0/doc/html/string_algo.html http://www.boost.org/doc/libs/1_39_0/doc/html/string_algo.ht... and RE2 for regex - http://code.google.com/p/re2/ http://code.google.com/p/re2/
- _delirium 17y agoThose are both C++, not C, aren't they?
- JoachimSchipper 17y agoIf your non-crummy tools are so bad that C ends up eating your lunch by a factor of 100, I'm not sure that they really are non-crummy.
- barrkel 17y agoPowerful tools improve productivity because you have to do less work to get the job accomplished. But they have a reverse side: you need to be aware of how they work to use them efficiently, otherwise you'll end up with silly performance problems - e.g. I've seen naive string tokenization code that did substrings, and then deleted the matched substring from the start of the string, all in a loop. By providing the tools, it's easier to misuse them. When you have fewer tools, on the other hand, you need to think at a lower level and work more directly on the problem. You have a lot more work to do, but the probability that you're misusing the tools is smaller, because you'll be building the tools yourself, manually.
- _delirium 17y agoI wonder how much that actually accounts for C's generally good performance in these kinds of ad-hoc benchmarks. There's really two "low-level" things about C: 1) it's low-level in the actual language sense of being reasonably close to the metal; and 2) it has a pretty bare-bones standard library, requiring most algorithms to be hand-coded, if you don't link in a 3rd-party library. Mostly people focus on #1, but as you point out, #2 might actually be a big part of it. I don't actually mean this as a slight against C, fwiw. In some ways, coding in C feels liberating, because I'm culturally allowed to do the nasty special-case hack, instead of doing it The Right Way with the library function that checks all the edge cases and error conditions and whatever.
- barrkel 17y agoOn this theme, there was a kind of "code-off" between Rico Mariani (.NET performance architect at the time) and Raymond Chen (The Old New Thing blog, Windows user mode developer). Rico has a kind of index to it here: http://blogs.msdn.com/ricom/archive/2005/05/10/performance-quiz-6-chinese-english-dictionary-reader.aspx http://blogs.msdn.com/ricom/archive/2005/05/10/performance-q... It was interesting to see how little Rico had to do from the start to end up with quite a performant application. Eventually Raymond started pulling ahead, but IIRC it was when he started using memory mapped files for I/O. Here's a summary at version 5 of the unmanaged code: http://blogs.msdn.com/ricom/archive/2005/05/18/419805.aspx http://blogs.msdn.com/ricom/archive/2005/05/18/419805.aspx Version Execution Time (seconds) Unmanaged v1 1.328 Unmanaged v2 0.828 Unmanaged v3 0.343 Unmanaged v4 0.187 Unmanaged v5 With Bug 0.296 Unmanaged v5 Corrected 0.124 Unoptimized Managed port of v1 0.124 It was quite interesting.