tcmalloc: add method to update heap sampling period

Tcmalloc supports changing the heap sampling period at run-time.
However, the only way to achieve this is by changing the value of
a global flag, tcmalloc_sample_parameter, which is not thread safe
in C++11. Moreover, the flag is hard to use from code outside the
tcmalloc code base, as it requires re-declaring the flag.

Add two static methods to the Sampler class to get and set the sampling
period atomically. Expand the malloc extension methods GetNumericProperty
and SetNumericProperty to query and update the sampling period from outside
the tcmalloc code base.

BUG=b:120800880
TEST=Unit tests pass

Change-Id: I2bb448f2d14af628923567a289b2a3234d6955e3
Reviewed-on: https://chromium-review.googlesource.com/c/1375392
Reviewed-by: Will Harris <wfh@chromium.org>
Commit-Queue: Gabriel Marin <gmx@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#617914}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 8ba2aae7693b700290d3cb8f6df381f86ca686e7
4 files changed
tree: 4c8e5868987492489e2ceaa02e0c9aa29371316c
  1. src/