Terrible Golang performance
See original GitHub issueStackoverflow: https://stackoverflow.com/questions/72266899/golang-performance-issues
Google group: https://groups.google.com/g/antlr-discussion/c/OdhAIsy2GfI
Example code: https://github.com/movelazar/perf-repro
A simple rule such as:
1 EQ 2 OR
1 EQ 2 OR
1 EQ 2 OR
1 EQ 2 OR
1 EQ 2
takes exponentially longer to parse the more 1 EQ 2 OR
clauses there are. This does not happen in python (by my testing) or CSharp, Dart, Java (by stackoverflow comment).
On my machine, # of lines vs parse time:
11: 0.5s
12: 1.2s
13: 3.2s
14: 8.1s
15: 21.9s
16: 57.5s
Given that Python doesn’t face this issue I can’t imagine I’m doing something terrible in my grammar.
Issue goes away if I put parens on things but that’s not a real solution.
On 4.10.1, first noticed with 4.9.1.
Any help is greatly appreciated. Surprised I can’t find others with this issue.
Issue Analytics
- State:
- Created a year ago
- Comments:101 (53 by maintainers)
Top Results From Across the Web
Golang: 4 Go Language Criticisms - Toptal
I was really surprised to find that it had horribly bad performance on bigger messages which was due to the message copying behavior...
Read more >We Need To Talk About The Bad Sides of Go : r/programming
My imagination suggested that this was a decision to make the compiler's job easier, leading to good performance rather than a preferred syntax....
Read more >GoLang — The Good, the Bad and the Ugly | Geek Culture
This article discusses the good, the bad, and the ugly sides of the Go programming language.
Read more >Go: the Good, the Bad and the Ugly - Sylvain Wallez
They found in Go a way to have great performance and reduced memory/cpu/disk footprint. And more static typing too, which was new to...
Read more >Go performance from version 1.2 to 1.18 - Hacker News
I'd say it is probably because we are all worst at writing code than we'd like to imagine. So writing necessarily complex code,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
These fixes require Go 1.18+ but that should be no problem, given go’s backward compatibility guarantees.
I am pretty sure I do 😃. Now, do I have the time? Hmmm - I did the C runtime for v3 because nobody else had the time… It sounds like the consensus is that the Go runtime may need either a rewrite or some serious work.
What would those with an interest in the Go runtime vote for? A new runtime, or a revamp.
I can look at the hashing anyway - though this looks more like an oversight in how go and hashing works (that’s a guess - I have not looked at the problem that @kaby76 describes, but that description looks sound to me). I also agree with earlier comments that the structs and embedded structs may not be organized as well as they might - but that probably is better taken care of with a rewrite.