3 ms·
The way I understood it the “slowness” came from using interface{} in the queue implementation. With generics you get a performance boost from annihilating the
by nokamok 5y ago
The way I understood it the “slowness” came from using interface{} in the queue implementation. With generics you get a performance boost from annihilating the run-time overhead. Yes?
- masklinn 5y ago> With generics you get a performance boost from annihilating the run-time overhead. Yes? I don't know whether creating an interface{} has a runtime cost (though it may if the type pointer has to be looked up at runtime?), however there's also a memory overhead: I didn't look at everything but the first two benches (pushfront and pushbach) use `int` values, which are 32 bits. But interface{} is 2 words (128 bits). This quadruples the memory requirements, meaning the backing buffer may well need either more reallocations, or to make larger allocations & have to span multiple cache lines.
- nokamok 5y agoI think you’re on to something. Just reread this article: https://blog.gopheracademy.com/advent-2018/interfaces-and-reflect/ https://blog.gopheracademy.com/advent-2018/interfaces-and-re... And there’s definitely an overhead associated with the interface type due to run-time reflection. I guess generics does away with this.