4 ms·
What makes it slower?
by philosopher1234 4y ago
What makes it slower?
- platzhirsch 4y agoMy guess is that over the years many optimizations have gone into SQLite that would take a lot of effort to catch up to.
- cdogl 4y agoIt’s hard for Go to beat C in a straight benchmark - Go is garbage collected and allocations often have extra overhead due to the memory layout of interfaces.
- icholy 4y agoIn addition, a lot of optimizations (like loop unrolling) are left on the table to preserve Go's fast compile times.
- pjmlp 4y agoGccgo is the answer here.
- Patrickmi 4y agoGccgo at its core may be fast but when it comes to how the go frontend interpret it to gcc ir that pales in comparison than just straight up optimizating the Go compiler There’ll more opportunities for more optimizations since they move to SSA ir since 1.5 and in turn compile time will definitely go down
- 59nadir 4y agoI was surprised with the announcement that Go's standard compiler had register allocation for function arguments[0] added to it. This seemed like table stakes for a very long time but it really illustrated just how Go's compiler is much, much simpler than most in many areas. On one hand it makes you wonder how much could be squeezed out of Go and how many basic things they're still leaving out of the compiler. On the other it tells part of the story of why Go compiles fast with the backdrop that despite this lack of work by the compiler people use Go productively all day and deliver services they are happy with from a performance perspective. [0] - https://go.dev/doc/go1.17#compiler https://go.dev/doc/go1.17#compiler (2021-08)
- zimpenfish 4y agoI wonder if they'll ever switch to a "normal = fast compile, low optimisation; release = slow compile, high optimisation" model like Rust. Although I suppose other languages already have the "high optimisation" parts covered (rust, julia, python+numpy, etc.) which might make it a fool's errand.
- Mawr 4y agoIt goes to show the impact of optimizing from top-down instead of bottom-up can have. Go was designed with performance in mind ("mechanical sympathy") as opposed to most other GC languages for which performance was an afterthought. If you get high-level language constructs right, you'll get great performance by default, even with a simple compiler: - structs instead of objects - value types - exposed pointers - straightforward allocation semantics Most compilers out there are busy fighting bad language designs. There's only so much a compiler can do when faced with fat objects hidden behind a spider web of pointers. So they have to do these microoptimizations to claw back at least some performance.
- pjmlp 4y agoIt is a matter of skill, Go can do manual memory management and stack allocation just as well.
- kaba0 4y agoAlso, Go barely optimizes code, that’s how it compiles as fast.
- pkolaczk 4y agoNot only Go compiler is not as good at optimisation as C/C++/Rust/Zig/D compilers, but also Go FFI to C has significant overhead, which means there is often not much point in using low-level Linux APIs for performance advantage. Same problem like with Java. And in a database system you quite likely want a fine degree of control with non-standard stuff.
- deleted 4y ago[deleted]
- yencabulator 4y agoHowever, it is absolutely plausible for Go-calling-Go to beat Go-calling-C-via-CGo, since CGo has plenty of overhead.
- cube2222 4y agoOther than what the other responders said, since it uses a C to Go compiler, I'd imagine the Go code that's generated isn't as fast as handwritten Go code could be.
- Patrickmi 4y ago[dead]