Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor metrics memory optimizations #2554

Commits on Nov 26, 2024

  1. metrics: Store register_ref in metric_groups_impl registration list

    The list of registered metrics that each `metric_groups_impl` stores is
    represented by a `metric_id` per registered metric. `metric_id` is quite
    a large struct as it contains the full name and label set. Hence, this
    list causes a measurable memory overhead.
    
    Instead just store a shared_ptr to the registration itself which we can
    use to reference the `metric_id` and hence save a lot of memory per
    registration (16 bytes vs. 136+ bytes).
    StephanDollberg committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    05b20c8 View commit details
    Browse the repository at this point in the history
  2. metrics: Don't store a metrics impl sp per registered metric

    Each registered metric stores a shared pointer to the metrics impl such
    that the metrics impl stays alive while there are metrics still
    registered.
    
    This adds 16 bytes of overhead per `registered_metric`. To reduce that
    we can move the shared_ptr to `metric_groups_impl` which is alive as
    long as the registered metrics are alive.
    StephanDollberg committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    c8d0881 View commit details
    Browse the repository at this point in the history