Add upb_Arena_SpaceAllocated function
Ref: https://github.com/protocolbuffers/protobuf/pull/10291
Ruby types defined though native extensions should register a function that report their memory footprint in bytes.
This feature is used by various memory profiling tools.
As suggested by @haberman.
NB: the implementation is a bit simpler than what we had in https://github.com/protocolbuffers/protobuf/pull/10291, here we return the arena allocated size, but we don't care about fused arenas. I think dividing by the number of fused arena is an implementation detail of the Ruby extension.
This looks good. We should also expose a upb_Arena_DebugRefCount() that just returns the ref count. The members of upb_Arena should be private from the perspective of the Ruby extension. Putting Debug in the name will make clear that the return is for informational purposes only, and shouldn't be used to control any logic.
We should also expose a
upb_Arena_DebugRefCount()that just returns the ref count.
Done.
@haberman apologies for not double checking, should be good to go now.
Would you be able to pull the latest changes from main? I've fixed the GitHub Actions to work properly for external contributors. Sorry for the hassle on this CL, we were still in the process of getting our CI system healthy.
@haberman rebased
Thanks!