Replace Canonical JSON JavaScript implementation with canonical_json Rust crate
Categories
(Firefox :: Remote Settings Client, enhancement)
Tracking
()
People
(Reporter: leplatrem, Unassigned)
References
Details
(Whiteboard: [remote-settings])
In order to share the same Canonical JSON serializer implementation between the server and the clients, we can replace the current toolkit/modules/CanonicalJSON.jsm with the canonical_json crate.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1659419
And https://blog.mathieu-leplatre.info/leveraging-rust-in-python-and-javascript.html
| Reporter | ||
Comment 1•2 years ago
|
||
I would be interested to know the performance impact of canonical json serialization of huge collections like security-state/intermediates, and see whether it would make sense to replace the current code with our Rust crate.
On my modern machine, it seems reasonable:
>> const { RemoteSettingsWorker } = ChromeUtils.importESModule("resource://services-settings/RemoteSettingsWorker.sys.mjs");
>> const resp = await fetch("https://firefox.settings.services.mozilla.com/v1/buckets/security-state/collections/intermediates/changeset?_expected=00000");
>> const {changes: records, timestamp} = await resp.json();
>> console.time("cjson"); await Promise.all(Array(500000).map(() => RemoteSettingsWorker.canonicalStringify(records, timestamp))); console.timeEnd("cjson");
10:46:29.478 cjson: 687.18ms - timer ended
But how to measure how it would affect browsing and battery on modest devices?
Comment 2•2 years ago
|
||
(In reply to Mathieu Leplatre [:leplatrem] from comment #1)
But how to measure how it would affect browsing and battery on modest devices?
Is it possible to have 2 versions with an about:config pref to control which one gets used?
To see if it affects browsing, the only way I see would be to profile the browser with the 2 different versions and see if we see differences. It would be easier if there are profiler markers around the code we care about.
For the impact on battery, we can try power profiling. On Android we get better power profiling data on Pixel 6+ devices, which I would not qualify as "modest", but that might already give an idea.
| Reporter | ||
Updated•1 year ago
|
Updated•1 year ago
|
Description
•