Commit d258b5ff authored by Alexei Svitkine's avatar Alexei Svitkine Committed by Chromium LUCI CQ

Optimize use of feature params in UKM recorder.

Feature params cannot change at runtime. Retrieve them only once,
instead of repeatedly.

We're seeing lots of crashes with SIGABRT on shutdown retrieving
UKM feature params by these code paths. SIGABRT may suggest that
it's just shutdown taking too long and it just happens to land
here (because retrieving params takes a bit of time). Eliminate
this possibility by caching these values.

This should slightly speed up UKM recording, including on shut
down. If shut down still takes too long and is the cause of the
SIGABRTs we're seeing, the stack traces should hopefully change
and the field trial param code won't be blamed anymore (perhaps
replaced by some other slow code, which can be fixed separately).

Bug: 1131877
Change-Id: I365e7a6fac5d3ef941cd0a26e9b280d03df6b28b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2615820
Commit-Queue: Robert Kaplow <rkaplow@chromium.org>
Auto-Submit: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841485}
parent 07ecb97f
......@@ -59,8 +59,9 @@ bool IsWhitelistedSourceId(SourceId source_id) {
// new ones being added.
size_t GetMaxSources() {
constexpr size_t kDefaultMaxSources = 500;
return static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
static auto value = static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
kUkmFeature, "MaxSources", kDefaultMaxSources));
return value;
}
// Gets the maximum number of Sources we can keep in memory at the end of the
......@@ -68,16 +69,18 @@ size_t GetMaxSources() {
// interval.
size_t GetMaxKeptSources() {
constexpr size_t kDefaultMaxKeptSources = 100;
return static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
static auto value = static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
kUkmFeature, "MaxKeptSources", kDefaultMaxKeptSources));
return value;
}
// Gets the maximum number of Entries we'll keep in memory before discarding any
// new ones being added.
size_t GetMaxEntries() {
constexpr size_t kDefaultMaxEntries = 5000;
return static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
static auto value = static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
kUkmFeature, "MaxEntries", kDefaultMaxEntries));
return value;
}
// Returns whether |url| has one of the schemes supported for logging to UKM.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment