I would say that depends on the allocation pattern? If you allocate one value of size class 52 in your program, the current approach wastes 47K, while your suggestion wastes 293K.
In other words, your approach is only significantly more efficient, if the number of allocated object is just below a multiple of 37. It seems clearly more common, that the number is just below a multiple of 7. I don't find it at all hard to believe that this effect will usually outweigh the <1% overhead of allocating smaller spans. On Tue, 12 Aug 2025 at 13:22, Nghĩa Nguyễn <nghiant3...@gmail.com> wrote: > ------------------------------ > > As noted in the Go size classes table (source > <https://github.com/golang/go/blob/go1.24.0/src/runtime/sizeclasses.go#L58>), > size class 52 corresponds to objects of 9472 bytes each. Go allocates 7 > pages (7 × 8192 = 57344 bytes) for a span of this size class, which fits 6 > objects, leaving a tail waste of 512 bytes. > > Why doesn’t Go allocate 37 pages for this size class instead? That would > provide exactly 303104 bytes (37 × 8192), which fits exactly 32 objects of > 9472 bytes with no waste. Wouldn't this be a more efficient use of memory? > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion visit > https://groups.google.com/d/msgid/golang-nuts/b2b8b688-c71f-4e5e-bbca-d819389b10e1n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/b2b8b688-c71f-4e5e-bbca-d819389b10e1n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfE%3D8ekgkEf_VCtFNek26M287uE3HUkgtrRvGx9BQLNfiw%40mail.gmail.com.