News for hackers. Stuff that matters.
Re:Manual Memory Management in Go using jemalloc by mish15 on Sunday November 22, 2020 @06:35PM (#25182109)
You can do this in pure Go though, you just need to manage the allocator yourself. That is a significant technical undertaking, but once done the advantages are huge. No GC overhead, no cgo. Done properly you can even have multiple readers and writers working concurrently in the same allocation space.
Re:Manual Memory Management in Go using jemalloc by chewxy on Sunday November 22, 2020 @08:59PM (#25182886)
OK you piqued my curiosity. How?
Re:Manual Memory Management in Go using jemalloc by mish15 on Monday November 23, 2020 @02:42AM (#25184405)
You just mmap memory as a slice. You can grow and shrink it, flush to disk if backed by a file, etc. In code it’s just a slice. Tough part is you need to allocate, control bounds, binary encode/decode, struct align, defrag, etc. It’s hard work, but the performance is 100% worth it if performance is your main goal.
Re:Manual Memory Management in Go using jemalloc by chewxy on Wednesday November 25, 2020 @12:01AM (#25206181)
TIL mmap'd memory is invisible to Go's GC
Re:Manual Memory Management in Go using jemalloc by yencabulator on Sunday November 22, 2020 @10:19PM (#25183276)
malloc isn't magic, just mmap some memory to dole out.