3 ms·
A better interface/API is really what I meant. The performance characteristics are probably worth the tradeoff.
by packetlost 3y ago
A better interface/API is really what I meant. The performance characteristics are probably worth the tradeoff.
- returningfory2 3y agoPassing in a map would require an extra allocation for the map memory for each log line. I think the performance would probably not be great?
- packetlost 3y agoit depends. I believe map literals are stack allocated if they aren't shared across goroutines or globals.
- masklinn 3y agoWhile the hmap struct can be stack allocated if it does not escape, I’m pretty sure the buckets still need to be heap-allocated. I do not believe hmap has a “flat structure” variant which could live entirely on the stack, though I could be wrong.
- Ferret7446 3y agoIt's most definitely not. Logging is crucial for monitoring services, and making logging statements many times slower will either sink your service or push developers to avoid logging and making the service impossible to debug. Most log metadata will be attached by libraries and middleware, so service/application devs won't even see most of it.
- packetlost 3y agoI think you interpreted my comment the wrong way, I think the performance tradeoffs are worth the mediocre API design. My bad for making it ambiguous