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

[Profiler] Allow .balloc/.pprof allocations comparison #4145

Merged
merged 9 commits into from
May 30, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ AllocationsProvider::AllocationsProvider(
_sampledAllocationsCountMetric = metricsRegistry.GetOrRegister<CounterMetric>("dotnet_sampled_allocations");
_sampledAllocationsSizeMetric = metricsRegistry.GetOrRegister<MeanMaxMetric>("dotnet_sampled_allocations_size");
_totalAllocationsSizeMetric = metricsRegistry.GetOrRegister<SumMetric>("dotnet_total_allocations_size");

// disable sub sampling when recording allocations
_shouldSubSample = !_pConfiguration->IsAllocationRecorderEnabled();
}


Expand All @@ -66,7 +69,8 @@ void AllocationsProvider::OnAllocation(uint32_t allocationKind,
_allocationsSizeMetric->Add((double_t)objectSize);
_totalAllocationsSizeMetric->Add((double_t)allocationAmount);

if ((_sampleLimit > 0) && (!_sampler.Sample()))
// remove sampling when recording allocations
if (_shouldSubSample && (_sampleLimit > 0) && (!_sampler.Sample()))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class AllocationsProvider
GenericSampler _sampler;
int32_t _sampleLimit;
IConfiguration const* const _pConfiguration;
bool _shouldSubSample;
std::shared_ptr<CounterMetric> _allocationsCountMetric;
std::shared_ptr<MeanMaxMetric> _allocationsSizeMetric;
std::shared_ptr<CounterMetric> _sampledAllocationsCountMetric;
Expand Down
4 changes: 4 additions & 0 deletions profiler/src/Tools/AllocSimulator/AllocSimulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private bool ParseAllocations(string filename)
private void ReadStringTable(FileStream fileStream, ref int pos)
{
int currentString = 0;
byte[] stringBuffer = new byte[1024]; // expect type names less than 1024 characters long
byte[] stringBuffer = new byte[2048]; // expect type names less than 2048 characters long
int currentChar = 0; // = length of the string after \0 is read
byte[] buffer = new byte[1];

Expand Down
7 changes: 6 additions & 1 deletion profiler/src/Tools/AllocSimulator/IUpscaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ public interface IUpscaler
{
public void OnAllocationTick(string type, int key, long size, long allocationsAmount);

public IEnumerable<AllocInfo> GetAllocs();
public IEnumerable<AllocInfo> GetUpscaledAllocs();

public IEnumerable<AllocInfo> GetSampledAllocs();

public void Upscale(AllocInfo sampled, ref AllocInfo upscaled);

}
}
Loading