Something is slowing down build times for metrics with large numbers of labels
Categories
(Toolkit :: Telemetry, defect, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox108 | --- | fixed |
People
(Reporter: chutten, Assigned: glandium)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
As nika reports in #build, the patches on bug 1790872 are having build durations that are timing out. Near as the investigation can find out, this is due to Rust compilation taking its sweet time.
The current best guess culprit is the thousands-strong vec!("label1".into(), ...)
invocation in the added metrics is having to do expensive type inference lookups to figure out what types it is going from and to... over and over again.
This macro invocation is generated by this RustEncoder.
It could be that switching to String::from
or .to_string()
or .to_owned()
will make the picture much easier for rustc
to see.
This bug is about pulling down the patchstack from bug 1790872 and trying out various approaches and their effects on build time and what it does to other Strings that go through the RustEncoder
.
Assignee | ||
Comment 1•2 years ago
•
|
||
So the core problem is that the closures for Lazy::new in metrics.rs end up massive, and inlining the large number of .into()
s is what's causing the build time explosion (this is, IIRC, a known problem). On the builds that take a long time to compile, it ends up inlining enough to be calling some RawVec function, while in the faster cases, it stops at calling Into::into
. The lesson here is that a creating a Vec<String>
from a large number of literal strings generates large functions. Creating an array of literals, and doing .iter().map().collect()
generates smaller code (the array needs to be const, otherwise the code generated is still uselessly large). But we can even go further and bring down the overhead significantly by using a single literal with a separate array of lengths. This saves about 70KB on the current build (before bug 1790872).
Assignee | ||
Comment 2•2 years ago
|
||
Comment 4•2 years ago
|
||
bugherder |
Description
•