5 ms·
V8 performance can beat C sometimes
- jonrx 13y agoCongralutations! :-) (And the program is IMHO clearer than the C implementation)
- pmelendez 13y agoTo the V8 team and the implementer of the testing program. Disclaimer: I had anything to do with this, I just thought it was interesting enough to post it.
- NathanKP 13y agoThe code for the C implementation is incredibly verbose compared to the code for the JS implementation. JS: http://benchmarksgame.alioth.debian.org/u64/program.php?test=regexdna&lang=v8&id=2 http://benchmarksgame.alioth.debian.org/u64/program.php?test... C: http://benchmarksgame.alioth.debian.org/u64/program.php?test=regexdna&lang=gcc&id=1 http://benchmarksgame.alioth.debian.org/u64/program.php?test...
- unwind 13y agoThat's just ... absurd, in comparison at least. It uses TCL and glib?! I'll go out on a limb here and claim that this C program is not the shortest possible equivalent to the JS version.
- igouy 13y agoThat isn't the only C program shown :-) http://benchmarksgame.alioth.debian.org/u64/program.php?test=regexdna&lang=gcc&id=4 http://benchmarksgame.alioth.debian.org/u64/program.php?test... http://benchmarksgame.alioth.debian.org/u64/program.php?test=regexdna&lang=gcc&id=2 http://benchmarksgame.alioth.debian.org/u64/program.php?test...
- majke 13y agoIf I read this benchmark right: v8 regexps are faster than TCL regexps. Hardly surprising.
- detrino 13y agoNo this is not V8 performance beating C. This is V8 calling a regexp library written in C++. C just happens to be using a different library that is slower.
- lambda 13y agoThis isn't V8 beating C; this is one regex library being faster than another (both written in C or C++).
- pmelendez 13y agoAs far as I know Irregexp[1] compiles on V8 byte code so you can't use it isolated without V8. Please, let me know if you find the opposite. [1] http://blog.chromium.org/2009/02/irregexp-google-chromes-new-regexp.html http://blog.chromium.org/2009/02/irregexp-google-chromes-new...
- z92 13y ago> Irregexp[1] compiles on V8 byte code I was thinking: but V8 doesn't have byte code. Then opened the link: "After optimization we generate native machine code which uses backtracking to try different alternatives."
- pmelendez 13y agoWell I might got it wrong but I got the bytecode reference from here: http://v8.googlecode.com/svn/trunk/src/interpreter-irregexp.cc http://v8.googlecode.com/svn/trunk/src/interpreter-irregexp.... Skimming the code it does look like they are interpreting byte code from Irregexp but I would need to read further to say it for sure.
- ahomescu1 13y agoIt's not JavaScript bytecode, but regex bytecode. V8 parses regular expressions to regex ASTs, takes them through some more intermediate forms, then finally to a special regex bytecode. That bytecode is either interpreted, or JIT compiled (depending of some build options, I think). You can look at a list of bytecodes in [1], and at the x64 JIT in [2]. 1 - http://code.google.com/p/v8/source/browse/trunk/src/bytecodes-irregexp.h http://code.google.com/p/v8/source/browse/trunk/src/bytecode... 2 - http://code.google.com/p/v8/source/browse/trunk/src/x64/regexp-macro-assembler-x64.cc http://code.google.com/p/v8/source/browse/trunk/src/x64/rege...
- 13y ago
- deleted 13y ago[deleted]
- jwineinger 13y agoThe V8 version used nearly 50% more memory than the C version. It is well known that you can often get faster execution times at the cost of increased memory usage.
- igouy 13y agoMore like 30%
- anjanb 13y agowhy is golang so much slower compared to Java ? Is it because the language is immature or because the language libraries are immature ?
- chimeracoder 13y agoGo not only uses a different library for processing regular expressions, but a different algorithm altogether. It is slower in some cases than the standard PCRE implementations but faster in others. http://code.google.com/p/re2/ http://code.google.com/p/re2/
- igouy 13y agoGo program using PCRE http://benchmarksgame.alioth.debian.org/u64/program.php?test=regexdna&lang=go&id=8 http://benchmarksgame.alioth.debian.org/u64/program.php?test...
- jonnii 13y agoQuickly, everyone convert their C to javascript!
- danso 13y agoAnyone else read this as "VB" as in, "Visual Basic"? Now that I would bookmark :)
- vezzy-fnord 13y agoYes, I got the same impression.
- jbverschoor 13y agoSo ruby java lua and python are all about the same?
- varelse 13y agoRather than argue back and forth about which regex implementation is better here, I'd simply note the absence of multicore numbers for V8 and that the crappy Tcl library beats single-threaded Javascript when run multicore. It would be interesting, however, to compare the performance here to that of the "grep" command on the same expressions. I'd be surprised at anything short of a total smackdown of Javascript V8. I would expect an even bigger smackdown if one invoked GPUs: http://bkase.github.io/CUDA-grep/finalreport.html http://bkase.github.io/CUDA-grep/finalreport.html Even more interesting would be an OpenCL implementation that did exactly what V8 is doing to the regexes (Why? Because it can). And total aside, this is why I don't participate in TopCoder competitions - they never let you have any real fun.
- _random_ 13y agoThe idea was obviously to pick a test and environment that would make it look like V8 can beat something other than interpreted JS. Otherwise it would've been the complete package: string manipulation, numerical computation, multi-core etc.