Performance patches in Go 1.11
docs.google.com
docs.google.com
You do cut yourself of from the more advanced optimizations simply for man-hour reasons. I'm guessing it's a trade off they are willing to make.
I have to say that I really dislike the kind of large pattern matching they added for the hash table clear. C compilers do that as well for e.g. memset/copy or bit rotate instructions.
IME it's really brittle and would be more beneficial as some kind of a lint ("you could replace this bunch of code by a call to clear()").
It makes the code simpler and won't inexplicably slow down next time someone does a tautological refactoring.
I've seen some computational-intensive code received a ~10% performance boost thanks to the heavy wizardry of code generation in GCC in past years (but, see also: masklinn's comments). Once gccgo implements Go 1.11, it may be a good idea to run the benchmark and get some new numbers.
They are also actively working on a third, llvm based implementation: https://go.googlesource.com/gollvm/
i'm actually happy with the situation. there is literally only one way to clear a map, and it is fast.
Which, actually, is brilliant design! Now, I can find all map clearings with one operation. (I need to implement that syntactic search/rewrite tool I miss from Smalltalk.)
A 50%+ reduction in programmer work is nothing to be sneezed at.
Go is a crippled language because it lacks generics and generalized higher-order types. The stated reasons for this are to make the compiler easier to implement. Maybe they wouldn't have had such implementation difficulties if they had just gone with the compiler backend the industry has standardized on, freeing up developer resources to make Go a language suitable for big development tasks and competitive with C++, C#, etc.
If folks agreed on a design finding resources to get them added wouldn't be hard.
Not sure what you're trying to imply with your last sentence, but Go is used by many companies large and small for big development tasks. I work for a company where most of the backend systems are written in Go.
The Go team is not against adding generics, and there have been proposals for them. They have simply not landed on a proposal that they feel is a strong fit for the language.
func ReadDir(dirname string) ([]os.FileInfo, error) {
f, err := os.Open(dirname)
if err != nil {
return nil, err
}
list, err := f.Readdir(-1)
f.Close()
if err != nil {
return nil, err
}
return list, nil
}
I much prefer a language and stdlib that stays stable over years, even at the cost of some nice new features/improvements - the place for code to move fast and break things (if you like that sort of thing) is much higher up the stack.Golang's ReadDir reads directory entries, stats all files, and sorts the list. If all you want is the directory entries directly, try godirwalk (also much faster for walking!): https://godoc.org/github.com/karrick/godirwalk#ReadDirents
I'm beginning to wonder if there will become more value in "lifting" binaries to LLVM IR, applying all opts to them, and re-compiling them. McSema does this[1] albeit you have to setup IDA and what not. Has anyone applied this to Go programs and measured its benefits for their specific use cases?
0 - https://github.com/cretz/go-mental-poker 1 - https://github.com/trailofbits/mcsema
Or am I wrong, and does LLVM not do inlining?
Edit: I'm a silly person, Go doesn't use LLVM. I've been wrong about that for some time!
On the one hand, that allows very fast compilation & codegen, on the other hand the optimisations are fairly limited. It also doesn't benefit from improvements done by other users, but doesn't saddle you with their issues[0].
There's also a Go implementation on top of GCC (gccgo), however while it generates high-quality code historically it wasn't really better than gc due to lacking escape analysis (so it did a ton more heap allocations than the reference) and having a lackluster GC.
[0] Rust has had its own LLVM fork for as long as the project has existed, for both fixing issues it hit which haven't yet been fixed upstream and implementing features it needs which have not been or can not be upstreamed
On the other hand, in a world that devs only believe in stuff when others actually implement it in production, it is nice to see that their toolchain is self sufficient without the usual C or C++ dependency.
Many language designers opt for implementing their toolchains in C or C++ just for mere convinience, and it is ok so.
However it creates the wrong perception among those without compiler development knowledge, that C and C++ are the only way to implement a toolchain.
I was so sure it used LLVM!
In more sophisticated languages, you might get inlining done multiple times, as some inlining decisions are easier with code knowledge, while others are better when the optimizer only sees IR.
PS: I'm the author of those prove patches.
How did you prioritize which BCE’s to include? (Or were these all that had a ticket?)
>This is fun and is easier than optimizing gcc / llvm, since the majority of the Go compiler, runtime and standard library is written in Go
If the slides are available today, and are viewable in a web-browser, I don't mind too much. Presumably it's either this or nothing.
If there's already a finished blog post in conventional format, then sure, no sense linking to a slideshow.
It's pretty bad. More so because Google Slide has a PDF export, but despite every browser having a built-in PDF viewer they force the download.
It's JavaScript-heavy and all that, but it works fine, no?