News for hackers. Stuff that matters.
Re:Go performance from version 1.2 to 1.18 by tapirl on Thursday February 03, 2022 @10:06PM (#30202324)
convenient to show your benchmarks?
Re:Go performance from version 1.2 to 1.18 by dekelpilli on Thursday February 03, 2022 @10:29PM (#30202483)
Not OP, but Benchmarks Game has a performance test based on regex: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

The top times for the mentioned languages are:

Rust: 0.78s

Ruby: 12.33s

Java: 5.34s

Go: 3.80s

Python: 1.34s

Re:Go performance from version 1.2 to 1.18 by azth on Thursday February 03, 2022 @11:10PM (#30202764)
The Java and golang numbers are not apples to apples. The Java solution is using the standard library code, while golang's is calling out to native code (wrapper C library) as far as I can tell. Same with Python.
Re:Go performance from version 1.2 to 1.18 by igouy on Friday February 04, 2022 @01:11PM (#30210663)
Other programs are shown:

    Python #2  1.34s PCRE2
    Go #5      3.80s PCRE
    Java #3    5.34s
    Java #6    5.39s
    Java #1    8.49s
    Python #1  9.25s "standard library"
    Go #4     15.60s PCRE
    Go #3     26.86s "standard library"
    Go #1     27.01s "standard library"
Re:Go performance from version 1.2 to 1.18 by adgjlsfhk1 on Thursday February 03, 2022 @11:17PM (#30202802)
To be fair to non-Javas, the java version is using Java code because Java sucks at calling out to faster languages.
Re:Go performance from version 1.2 to 1.18 by zmmmmm on Friday February 04, 2022 @12:28AM (#30203236)
Oh yes, that Python code looks so idiomatic:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:Go performance from version 1.2 to 1.18 by pmontra on Friday February 04, 2022 @12:48AM (#30203332)
Can't comment on that but why are these people putting spaces after commas (correct) and not to the left and right of the assignment sign = ? It's so weird to read a=b
Re:Go performance from version 1.2 to 1.18 by viraptor on Friday February 04, 2022 @12:39AM (#30203289)

    regex=PCRE2.pcre2_compile_8(pattern, c_size_t(len(pattern)), c_uint32(0),
   byref(c_int()), byref(c_size_t()), None)
As far as FFI goes, I would say this looks amazingly simple.
Re:Go performance from version 1.2 to 1.18 by oefrha on Friday February 04, 2022 @03:26AM (#30204223)
That’s very straightforward translation of C code using pcre to Python using ctypes. It doesn’t look great because the ugliness isn’t wrapped in a library. But Python ctypes definitely isn’t hard to use. It is unsafe as hell though.
Re:Go performance from version 1.2 to 1.18 by igouy on Friday February 04, 2022 @01:17PM (#30210735)
Re:Go performance from version 1.2 to 1.18 by igouy on Friday February 04, 2022 @01:56PM (#30211286)
Seems to be OK in pidigits — Java #3 program

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

    C gcc #6 0.56s
    Java  #3 0.79s
Re:Go performance from version 1.2 to 1.18 by azth on Thursday February 03, 2022 @11:55PM (#30203034)
There's JNI that exists now. And Project Panama will be a big improvement.
Re:Go performance from version 1.2 to 1.18 by esprehn on Friday February 04, 2022 @11:46AM (#30209190)
That's interesting that Ruby is as slow as it is, the regex engine (Onigmo) is written in C. I wonder where the bottleneck is compared to the other languages.
Re:Go performance from version 1.2 to 1.18 by zmmmmm on Friday February 04, 2022 @12:41AM (#30203295)
Seems to be mainly a test of compiling regexes, rather than executing them. Which is a bit pointless because few applications would not pre-compile regexes ... and then it would actually be penalising languages that put more effort into optimisation and hence perform better in the real world at execution.
Re:Go performance from version 1.2 to 1.18 by burntsushi on Friday February 04, 2022 @09:39AM (#30207273)
Why would you even say this? It is certainly not a test of compiling regexes. Go and profile any one of those programs. You'll see that the majority of time is spent executing the search, not the compilation.

Look at the runtimes being mentioned here. We're talking on the order of seconds. The benchmark itself calls for 15 pretty simple regexes to be compiled. Regex compilation of 1ms or longer would be considered slow I think. So that's 15ms. That's nearly nothing compared to the full runtime of the benchmark. Even if you assumed each regex took 10ms on average to compile, you're still only looking at 150ms total.

I say this as the author of Rust's regex engine and as someone who has spent a non-trivial time looking at and thinking about this particular benchmark.

Re:Go performance from version 1.2 to 1.18 by zmmmmm on Friday February 04, 2022 @08:29PM (#30216084)
Apologies, you're correct. I mistook the use of Pattern.compile chained with replaceAll to mean that it was compiling the regex every time it used it.
Re:Go performance from version 1.2 to 1.18 by xpressvideoz on Thursday February 03, 2022 @10:14PM (#30202382)
Unfortunately, the test code belongs to the company I work for so I cannot take it out. It was done to determine what language we should use for an internal tool. I hope to conduct another benchmark one day, publicly this time.