Open Bug 1886702 Opened 2 years ago Updated 1 year ago

use_counter_metrics.yaml takes more than a second to load

Categories

(Toolkit :: Telemetry, defect, P4)

defect

Tracking

()

People

(Reporter: sergesanspaille, Assigned: sergesanspaille)

References

Details

Attachments

(1 file)

In [11]: %timeit json.load(open("/home/ssp/sources/mozilla-unified/dom/base/use_counter_metrics.json"))
6.54 ms ± 32.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

In [12]: %timeit yaml.safe_load(open("/home/ssp/sources/mozilla-unified/dom/base/use_counter_metrics.yaml"))
1.72 s ± 169 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [13]: %timeit yaml.load(open("/home/ssp/sources/mozilla-unified/dom/base/use_counter_metrics.yaml"), Loader=yaml.CSafeLoader)
211 ms ± 823 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

where use_counter_metrics.json is an automatic translation of use_counter_metrics.yaml

Component: Glean: SDK → DOM: Core & HTML
Product: Data Platform and Tools → Core

The json version loads at the order of millisecond while the yaml
version loads within a second.

Hey,

why is this change needed given bug 1886479 ?

Note that this change might have impact on the ingestion and will need to be reviewed by a telemetry peer.

The best component for this is perhaps Toolkit::Telemetry.

Flags: needinfo?(sguelton)

This blocks bug 1886479 because a quater of the time spent in glean_parser is spent parsing this file.

Component: DOM: Core & HTML → Telemetry
Flags: needinfo?(sguelton)
Product: Core → Toolkit

(In reply to [:sergesanspaille] from comment #3)

This blocks bug 1886479 because a quater of the time spent in glean_parser is spent parsing this file.

Why aren't the changes in bug 1886479 not sufficient? Why do we need to read the YAML file and then produce a JSON?

Flags: needinfo?(sguelton)

As Alessio said we definitely need to double-check that it works in our pipeline if we get the JSON file (for our use case JSON is a subset of YAML and thus our parsers should handle it just fine, but we still need to make sure that we don't expect a .yaml file suffix somewhere).

For why the patch is the way it is I understand:

dom/base/use_counter_metrics.yaml is generated using a mach command and checked-in. This change also generates the JSON file.
glean_parser seems to correctly handle JSON files already, so swapping it out in the metrics_index.py, which is used to generate code at build time, continues to work.

If we want to land this, there's still a bunch of changes along the way we will have to fix first:

Attachment #9392466 - Attachment description: Bug 1886702 - Generate a json version of use_counter_metrics.yaml r=emilio → Bug 1886702 - Generate a json version of use_counter_metrics.yaml r=emilio!

I've submitted https://github.com/mozilla/glean_parser/pull/679 to make the json parser add the same fields as the yaml parser, although there's no hook in the json parser to grab the lineno, so I just set them to null.
I've also updated the attached review to use the glean?util.yaml_load loader before dumping the resulting object to json, so that we remain consistent with any extra step there.

Flags: needinfo?(sguelton)

Thanks! I checked in with Serge ot understand the "why" better. The tracking bug 1646939 has some context:
The export task runs before every compile and currently takes ~20s or so. The glean_parser invocation is 1-2s of that, so definitely a significant part. Reducing that would help overall (of course compared to compile it's a little amount of time, but this task runs often!).

We will have the C yaml parser soon, which reduces the time somewhat. The JSON patches are not too hard, but we'll defer them for now due to our current workload.

The severity field is not set for this bug.
:chutten, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(chutten)

Hey, Jan-Erik, do you have an easy way to check how much of a difference the C parser made in the now-in-m-c v13.0.1?

Flags: needinfo?(chutten) → needinfo?(jrediger)

:sergesanspaille, got any tracking on how much the c parser now improved things?

Flags: needinfo?(jrediger) → needinfo?(sguelton)

On my laptop: from 5.4s to 2.4s \o/

Flags: needinfo?(sguelton)
Severity: -- → S4
Priority: -- → P4
See Also: → 1918118
No longer blocks: 1886479
Depends on: 1886479
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: