We could first port the jemalloc metrics over to the legacy metrics utility (without disturbing proxy) or make a bridge between the implementations.
Later we could add the actual (de)allocation counts for example by sharded thread-local counters, as jemalloc does not seem to make this available by default. This part needs more investigation, is it error prone to provide such counting?
With pageservers switch to jemalloc following proxy's lead, in a recent memory leak it came up that we should have metrics from jemalloc.
Proxy already has implemented reading metrics of jemalloc in https://github.com/neondatabase/neon/blob/main/proxy/src/jemalloc.rs.
We could first port the jemalloc metrics over to the legacy metrics utility (without disturbing proxy) or make a bridge between the implementations.
Later we could add the actual (de)allocation counts for example by sharded thread-local counters, as jemalloc does not seem to make this available by default. This part needs more investigation, is it error prone to provide such counting?