upb icon indicating copy to clipboard operation
upb copied to clipboard

Add upb_Arena_SpaceAllocated function

Open casperisfine opened this issue 3 years ago • 3 comments

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.

casperisfine avatar Aug 10 '22 08:08 casperisfine

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.

haberman avatar Aug 10 '22 13:08 haberman

We should also expose a upb_Arena_DebugRefCount() that just returns the ref count.

Done.

casperisfine avatar Aug 10 '22 14:08 casperisfine

@haberman apologies for not double checking, should be good to go now.

casperisfine avatar Aug 16 '22 06:08 casperisfine

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 avatar Sep 12 '22 23:09 haberman

@haberman rebased

casperisfine avatar Sep 13 '22 07:09 casperisfine

Thanks!

casperisfine avatar Sep 13 '22 15:09 casperisfine