Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

FEAT: pool size statistics #676

Closed
pbalcer opened this issue Oct 25, 2017 · 0 comments
Closed

FEAT: pool size statistics #676

pbalcer opened this issue Oct 25, 2017 · 0 comments
Assignees
Milestone

Comments

@pbalcer
Copy link
Member

pbalcer commented Oct 25, 2017

pool size statistics

Rationale

To complement the manual mode of pool grow mention in the #382, the user needs the ability to tell when to call the function to increase the size of the pool.

Description

The answer to the question "How much free space is left in the pool" is difficult. One has to consider that objects are not linearly arranged in the heap, which means that there's simply no single region of free space but many small regions that are continuously being tracked by the allocator. Even if we assume that the total amount of free space is a good enough measure, counting that free space is still very time consuming and potentially racey operation. And even if we return a value, that value might be invalid right after we finish calculating, because other threads might be allocating memory.

Still, a rough estimate of free space might be useful for administrative tasks. For this purpose, we will expose a API that will return the ratio of the sum of sizes of allocated objects to the current size of the heap.

API Changes

There will be one new CTL entry points:

  • heap.stats.allocated_curr - the number of allocated bytes

Implementation details

The sum of sizes of allocated objects will be tracked in runtime by the means of atomic increment, and will be eventually persisted in the pool. This is a trade-off between accuracy and time complexity of the statistic gathering.

The eventual nature of the persistent statistic means that it might drift over time if crashes often happen at unfortunate times. Initially, there will be no mechanism to correct for that drift.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant