You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When you create a SdkMeterProviderBuilder and specify an ExemplarFilter, which is off, you would expect there won't be any memory allocations made since exemplars are not being collected in effect.
It happens in multiple locations, where an aggregator is created with an exemplar reservoir. In all places, it is wrapped with a filtered reservoir, but it's created either way without considering the filter might be off.
For a single aggregator with 100k attributes, it's 70 MB of memory not needed.
Describe the solution you'd like
Since the filter is not an enum, there's no way to know from it whether it's off or not.
Also, some filters might not introduce any sampling for certain attributes but are not declared as off.
I suggest changing the argument of ExemplarReservoir<T> original in ExemplarReservoir.filtered() , to a function providing that (Supplier<ExemplarReservoir<T>>). FilteredExemplarReservoir methods would ensure private ExemplarReservoir<T> reservoir; is initialized before use. Initialization would be done using the supplier.
Lazy init.
Describe alternatives you've considered
None at the moment
Additional context
None at the moment
The text was updated successfully, but these errors were encountered:
asafm
changed the title
Exemplas pre-allocates memory even when exemplars are not used
Exemplars pre-allocates memory even when exemplars are not used
Jun 29, 2023
Nice find. I wonder if we can lazily initialize somewhere deeper down in the reservoir itself to keep the code flow the same. Something like this this: 823e46c
I believe so.
For FixedSizeExemplarReservoir, we can start with null value for ReservoirCell[] storage;
In offerLongMeasurement and offerDoubleMeasurement, I'll call ensureInitialized(), which will check if null, and if so, init the array as the c'tor does:
this.storage = new ReservoirCell[size];
for (int i = 0; i < size; ++i) {
this.storage[i] = new ReservoirCell(clock);
}
I thought of lazy init easy item in the array, but the selector gets access to the array in full, so there is not interface to hide behind.
Is your feature request related to a problem? Please describe.
When you create a
SdkMeterProviderBuilder
and specify anExemplarFilter
, which is off, you would expect there won't be any memory allocations made since exemplars are not being collected in effect.It happens in multiple locations, where an aggregator is created with an exemplar reservoir. In all places, it is wrapped with a filtered reservoir, but it's created either way without considering the filter might be off.
Example:
For a single aggregator with 100k attributes, it's 70 MB of memory not needed.
Describe the solution you'd like
Since the filter is not an enum, there's no way to know from it whether it's off or not.
Also, some filters might not introduce any sampling for certain attributes but are not declared as off.
I suggest changing the argument of
ExemplarReservoir<T> original
inExemplarReservoir.filtered()
, to a function providing that (Supplier<ExemplarReservoir<T>>
).FilteredExemplarReservoir
methods would ensureprivate ExemplarReservoir<T> reservoir;
is initialized before use. Initialization would be done using the supplier.Lazy init.
Describe alternatives you've considered
None at the moment
Additional context
None at the moment
The text was updated successfully, but these errors were encountered: