Bug 1812452 - Increase the min profiler buffer limit to 128MiB r=florian,geckoview-reviewers,m_kato

Differential Revision: https://phabricator.services.mozilla.com/D181654
This commit is contained in:
Nazım Can Altınova 2023-06-23 09:17:43 +00:00
parent 3a2eb320d7
commit dde20574dc
3 changed files with 19 additions and 20 deletions

View File

@ -695,20 +695,21 @@ public class GeckoThread extends Thread {
// Putting default values for now, but they can be overwritten.
// Keep these values in sync with profiler defaults.
int interval = 1;
// 8M entries. Keep this in sync with `PROFILER_DEFAULT_STARTUP_ENTRIES`.
int capacity = 8 * 1024 * 1024;
// We have a default 8M of entries but user can actually put less entries
// with environment variables. But even though user can put anything, we
// have a hard cap on the minimum value count, because if it's lower than
// this value, profiler could not capture anything meaningful.
// The default capacity value is the same with the min capacity, but users
// can still enter a different capacity. We also keep this variable to make
// sure that the entered value is not below the min capacity.
// This value is kept in `scMinimumBufferEntries` variable in the cpp side:
// https://searchfox.org/mozilla-central/rev/fa7f47027917a186fb2052dee104cd06c21dd76f/tools/profiler/core/platform.cpp#749
// This number is not clear in the cpp code at first, so lets calculate:
// scMinimumBufferEntries = scMinimumBufferSize / scBytesPerEntry
// expands into
// scMinimumNumberOfChunks * 2 * scExpectedMaximumStackSize / scBytesPerEntry
// and this is: 4 * 2 * 64 * 1024 / 8 = 65536 (~512 kb)
final int minCapacity = 65536;
// This number represents 128MiB in entry size.
// This is calculated as:
// 128 * 1024 * 1024 / 8 = 16777216
final int minCapacity = 16777216;
// ~16M entries which is 128MiB in entry size.
// Keep this in sync with `PROFILER_DEFAULT_STARTUP_ENTRIES`.
// It's computed as 16 * 1024 * 1024 there, which is the same number.
int capacity = minCapacity;
// Set the default value of no filters - an empty array - which is safer than using null.
// If we find a user provided value, this will be overwritten.

View File

@ -117,9 +117,9 @@ class SpliceableJSONWriter;
static constexpr PowerOfTwo32 BASE_PROFILER_DEFAULT_ENTRIES =
# if !defined(GP_PLAT_arm_android)
MakePowerOfTwo32<8 * 1024 * 1024>(); // 8M entries = 64MB
MakePowerOfTwo32<16 * 1024 * 1024>(); // 16M entries = 128MiB
# else
MakePowerOfTwo32<2 * 1024 * 1024>(); // 2M entries = 16MB
MakePowerOfTwo32<4 * 1024 * 1024>(); // 4M entries = 32MiB
# endif
// Startup profiling usually need to capture more data, especially on slow
@ -128,9 +128,9 @@ static constexpr PowerOfTwo32 BASE_PROFILER_DEFAULT_ENTRIES =
// https://searchfox.org/mozilla-central/source/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoThread.java
static constexpr PowerOfTwo32 BASE_PROFILER_DEFAULT_STARTUP_ENTRIES =
# if !defined(GP_PLAT_arm_android)
mozilla::MakePowerOfTwo32<64 * 1024 * 1024>(); // 64M entries = 512MB
mozilla::MakePowerOfTwo32<64 * 1024 * 1024>(); // 64M entries = 512MiB
# else
mozilla::MakePowerOfTwo32<8 * 1024 * 1024>(); // 8M entries = 64MB
mozilla::MakePowerOfTwo32<16 * 1024 * 1024>(); // 16M entries = 128MiB
# endif
// Note: Keep in sync with GeckoThread.maybeStartGeckoProfiler:

View File

@ -35,10 +35,8 @@ constexpr static uint32_t scMinimumNumberOfChunks = 4;
// Firefox processes).
constexpr static uint32_t scMaximumChunkSize = 1024 * 1024;
// We should be able to store at least the minimum number of the smallest-
// possible chunks.
constexpr static uint32_t scMinimumBufferSize =
scMinimumNumberOfChunks * scMinimumChunkSize;
// Limit to 128MiB as a lower buffer size usually isn't enough.
constexpr static uint32_t scMinimumBufferSize = 128u * 1024u * 1024u;
// Note: Keep in sync with GeckoThread.maybeStartGeckoProfiler:
// https://searchfox.org/mozilla-central/source/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoThread.java
constexpr static uint32_t scMinimumBufferEntries =