News for hackers. Stuff that matters.
Re:Rust programs versus Go by simias on Wednesday May 16, 2018 @05:37AM (#17081079)
It's true that performance is not always the main metric to consider but in this case I'm not really sure that Go makes that much of a difference. Take the "regex-redux" benchmark for instance, compare the two versions:

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

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

I don't find the code complexity obviously worse for the Rust version, yet it runs a full order of magnitude faster in this benchmark.

Re:Rust programs versus Go by weavie on Wednesday May 16, 2018 @05:42AM (#17081098)
Go seems to perform really poorly in the regex-redux. Against both Node and Python Go is way faster (as one would expect) apart from with the regex-redux..

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

Does Go just suck with it's regex performance? Would this be easy to fix by just pulling in a C regex library?

Re:Rust programs versus Go by jerf on Wednesday May 16, 2018 @09:10AM (#17082065)
I disagree with the people saying the benchmarks game is useless. It mostly seems to conform to my own experiences with the various languages involved.

The exception is the regex benchmark, which has little to do with the languages and everything to do with the regex library used by the language. If the dynamic scripting languages were required to use regex engines implemented in pure Python/Perl/PHP/JS, their performance in the game would collapse on the regex benchmark.

Go's standard library provides a regex library that provides certain O() guarantees, but has a significantly larger constant factor than PCRE-like regexs. Benchmarks tend to hit cases where PRCE is faster, but it's not hard to construct a benchmark where the Go standard library will be arbitrarily faster than some of the other languages, because that's a characteristic of big-O differences.

(In general, one should always be careful of claims that some block of code is X times faster or slower than another; the comparison only has meaning if they're in the same big-O class, or at least de facto in the same big-O class, e.g., O(n logn) and O(n logn logn) are basically the same class in practice. It's also important to make sure the problem being benchmarked is large enough to get past the constant factors that may be involved. I'm not saying those aren't important, but if you want an "X-times faster" sort of comparison you need to shrink the constant factors into irrelevance first. I've seen cases where people blithely claim some bit of code is 100,000 faster than some other, but really, it's a big-O difference.)

Re:Rust programs versus Go by _ek94 on Wednesday May 16, 2018 @01:57PM (#17084737)
> Go's standard library provides a regex library that provides certain O() guarantees, but has a significantly larger constant factor than PCRE-like regexs.

While that is true, Rust's regex library makes the same guarantees.

I'd also like to push back on the idea that perf comparisons are meaningless if one implementation has degenerate cases. Pathological behavior in a backtracking engine happens very rarely, and backtrackers typically come with features that are not supplied by O(n) engines. Someone in the PCRE camp might complain that the benchmark isn't fair because go's engine can't handle backreferences. The different approaches come with different features (backreferences vs garenteed O(n) running time), but they do have a place where their problem domains overlap. It is not useless to examine how they perform in that area.

Re:Rust programs versus Go by jerf on Wednesday May 16, 2018 @02:14PM (#17084937)
"I'd also like to push back on the idea that perf comparisons are meaningless if one implementation has degenerate cases."

That's not what I said. I said, you can't use "X times faster" comparisons if the O() of the two algorithms in question are not more-or-less the same. That does not prevent you from still characterizing performance differences. You just can't do it via "X times faster" statements, because those are only well-defined for things separated by linear factors, and practically defined for things separated by practically linear factors. f(x) = x^2 is not "2 times bigger" than g(x) = x, or any number of "times bigger", whereas h(x) = 3x + 5 can be reasonably said to be "3 times bigger" than i(x) = x + 50, even though it is not the case that h(x) = 3i(x).

Re:Rust programs versus Go by igouy on Monday May 21, 2018 @10:58AM (#17118835)
>> The exception is the regex benchmark, which has little to do with the languages and everything to do with the regex library used by the language.

Perhaps that's "a truth" about regex :-)

>> If the dynamic scripting languages were required to…

Then we wouldn't be using them as scripting languages!

Re:Rust programs versus Go by weberc2 on Wednesday May 16, 2018 @09:32AM (#17082211)
> I disagree with the people saying the benchmarks game is useless. It mostly seems to conform to my own experiences with the various languages involved.

I think it can only tell you about the performance cieling, and even then it can't tell you that for languages like Go where fairly obvious optimizations (like arenas) are prohibited while all manner of clever tricks are permitted for other languages.

Your remarks on performance comparisons were really insightful.

Re:Rust programs versus Go by igouy on Monday May 21, 2018 @11:02AM (#17118866)
>> obvious optimizations (like arenas) are prohibited

No, not prohibited.

Which widely-used third-party Go library do you suggest people use to implement Go binary-trees programs?

Re:Rust programs versus Go by weberc2 on Wednesday May 23, 2018 @11:34AM (#17134970)
> No, not prohibited.

Yes, prohibited

> Which widely-used third-party Go library do you suggest people use to implement Go binary-trees programs?

What does this have to do with my post?

Re:Rust programs versus Go by igouy on Friday May 25, 2018 @01:19PM (#17155870)
>> What does this have to do with my post?

You falsely claim that Go arenas are prohibited.

Show that there is a widely-used third-party Go library that provides arenas, which could be used to implement Go binary-trees programs, to support your claim.

Re:Rust programs versus Go by tex0 on Wednesday May 16, 2018 @05:58AM (#17081165)
The benchmark is using some third party PCRE lib. This is probably necessary because Go's RE2 lacks some features, but it's not a good comparison.
Re:Rust programs versus Go by burntsushi on Wednesday May 16, 2018 @09:17AM (#17082107)
> This is probably necessary because Go's RE2 lacks some features

No, it's because PCRE is faster than Go's standard library regex engine on this particular benchmark. There is another entry for Go (called just `Go` I believe) that uses Go's "regexp" package.

The regexredux benchmark itself does not require any "fancy" features. It can be satisfied by pure regular expressions.

Re:Rust programs versus Go by chatmasta on Wednesday May 16, 2018 @05:42AM (#17081101)
What stuck out to me about the regex-redux benchmark is that PHP is faster than both of them! Is that because PHP is effectively a scripting language over C, especially for well-defined tasks like regex matching?
Re:Rust programs versus Go by burntsushi on Wednesday May 16, 2018 @09:04AM (#17082025)
I don't know personally. In Oct 2017, the PHP version was slower: http://web.archive.org/web/20171027211857/http://benchmarksg...

Today, it is faster: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

As far as I can tell, the source code of the benchmark didn't change at all. The only difference between them is that former uses PHP 7.1 and the latter uses PHP 7.2.

So... I would start at the differences between PHP 7.1 and PHP 7.2. I would also first attempt to reproduce the result locally, to rule out changes in environment in the benchmark game (speculatively speaking).

Re:Rust programs versus Go by weavie on Wednesday May 16, 2018 @05:44AM (#17081107)
You aren't really going to experience Rusts complexity when your program is essentially just a single function, so it probably isn't really a fair comparison..
Re:Rust programs versus Go by v_lisivka on Wednesday May 16, 2018 @05:57AM (#17081161)
When programs grows in complexity, Rust shines. Extra guarantees are very handy when code refactored. It hard to compile Rust code, but when it compiled, it usually works (or quickly points out to problem).

I actually use it in parallel with C/C++ legacy code, and I just trying to avoid C/C++ as much as I can, because I newer saw segfault in safe Rust code so far.

Re:Rust programs versus Go by smcl on Wednesday May 16, 2018 @05:59AM (#17081168)
Especially when you're just reading some pre-written code. I've rarely (never?) seen any complaints about how reading Rust is hard ... but lots which say that writing the code itself can be frustrating