Hacker News new | ask | show | jobs
by packetlost 1036 days ago
A better interface/API is really what I meant. The performance characteristics are probably worth the tradeoff.
2 comments

Passing 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?
it depends. I believe map literals are stack allocated if they aren't shared across goroutines or globals.
While 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.
It'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.

I 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