Closed Bug 1799751 Opened 2 years ago Closed 2 years ago

Something is slowing down build times for metrics with large numbers of labels

Categories

(Toolkit :: Telemetry, defect, P1)

defect

Tracking

()

RESOLVED FIXED
108 Branch
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.

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: chutten → mh+mozilla
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/196b79e65443 Reduce the size of code, data and relocations for Vec<String>s used in metrics. r=janerik
Blocks: 1799914
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 108 Branch
Blocks: 1810802
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: