Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
returningfory2
on Aug 22, 2023
|
parent
|
context
|
favorite
| on:
Structured logging with slog
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?
packetlost
on Aug 22, 2023
[–]
it depends. I
believe
map literals are stack allocated if they aren't shared across goroutines or globals.
masklinn
on Aug 23, 2023
|
parent
[–]
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.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: