don't round up sizes for large allocation when sampling
This closes #723. Since rounding up prior to sampling is introducing possibility of arithmetic overflow, we're just not doing it. It introduces some error (up to 4k), but since we're dealing with at least 256k allocations, we're fine.
This commit is contained in:
parent
4f3410e759
commit
7dd4af6536
|
@ -1154,8 +1154,13 @@ inline void* do_malloc_pages(ThreadCache* heap, size_t size) {
|
|||
bool report_large;
|
||||
|
||||
Length num_pages = tcmalloc::pages(size);
|
||||
size = num_pages << kPageShift;
|
||||
|
||||
// NOTE: we're passing original size here as opposed to rounded-up
|
||||
// size as we do in do_malloc_small. The difference is small here
|
||||
// (at most 4k out of at least 256k). And not rounding up saves us
|
||||
// from possibility of overflow, which rounding up could produce.
|
||||
//
|
||||
// See https://github.com/gperftools/gperftools/issues/723
|
||||
if (heap->SampleAllocation(size)) {
|
||||
result = DoSampledAllocation(size);
|
||||
|
||||
|
|
Loading…
Reference in New Issue