question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Terrible Golang performance

See original GitHub issue

Stackoverflow: 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:closed
  • Created a year ago
  • Comments:101 (53 by maintainers)

github_iconTop GitHub Comments

3reactions
jimidlecommented, Aug 13, 2022

These fixes require Go 1.18+ but that should be no problem, given go’s backward compatibility guarantees.

2reactions
jimidlecommented, Aug 10, 2022

Thanks, @kaby76 for tracking this down! yeah, I was under impression Go target was kinda screwed up.

Does anybody know Go well enough to fix this hash issue?

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found