Open Bug 1927580 Opened 6 days ago Updated 4 days ago

FOG Rust Labeled submetric instances are recreated on every call to `get`

Categories

(Toolkit :: Telemetry, enhancement, P1)

enhancement

Tracking

()

ASSIGNED

People

(Reporter: chutten, Assigned: chutten)

Details

(Theoretically this is a defect for any rust test depending on the result of get matching across calls, but as we don't advertise that capability nor have any tests exercising that, it's an Enhancement for the performance impact)

When you call get() on a labeled metric, you get a submetric. If that get comes from C++ or JS it goes through FFI which uses the submetric maps to always return you the same instance for a given labeled metric and label. If that get comes from Rust, it creates a new FOG metric instance to wrap the (cached) Glean SDK metric instance returned from the inner get.

This was fine while these submetrics were zero-sized or at least cheap. But new labeled types are a little more expensive (looking at you labeled_timing_distribution) and are likely to get heavier over time.

So let's move the submetric map handling to impl Sealed::from_glean_metric from macros.rs to reduce the memory fingerprint of using the Rust API and to support having every submetric reachable by its submetric id across all three languages.

Summary: FOG Rust Labeled submetric indices are recreated on every call to `get` → FOG Rust Labeled submetric instances are recreated on every call to `get`
You need to log in before you can comment on or make changes to this bug.