go-pmem
go-pmem copied to clipboard
Change the type profiling implementation
Type profiling is used to keep track of how many times a datatype has been allocated. This is used to promote heavily allocated types to be specially cached in mcache so that future allocations would be fast. Currently a large static array of size 50,000 is used to track these stats. This is because the index of a type within a Go binary cannot be known at runtime currently, so an offset from a static location typeBase
is used to determine type index.
But using a large static array is not a good idea. It increases the binary size and also could cause runtime issues. For example, when etcd was compiled with go-pmem certain type fields were seen to overshoot the index value of 50,000.