Update rust-smallvec, use its try_reserve method
Categories
(Core :: CSS Parsing and Computation, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox85 | --- | fixed |
People
(Reporter: SimonSapin, Assigned: emilio)
References
Details
Attachments
(2 files)
… instead of hacking it from outside the crate: https://searchfox.org/mozilla-central/rev/41c3ea3ee8eab9ce7b82932257cb80b703cbba67/servo/components/fallible/lib.rs#101-163
| Reporter | ||
Comment 1•5 years ago
|
||
| Reporter | ||
Comment 2•5 years ago
|
||
Both smallvec and hashbrown have identical CollectionAllocErr types.
Dedupcicating them or adding a From conversion between them
would require a new dependency between these two creates.
Instead, this commit adds a third copy of CollectionAllocErr
in the fallible crate, with From conversions from the other two.
| Reporter | ||
Comment 3•5 years ago
|
||
I scheduled "stylebench" jobs for these commit on try and for their parent commit on central to get a perf.html comparison. The new code is mostly equivalent, except for using realloc instead of alloc + copy_nonoverlapping + dealloc. I expected only noise in the perf difference, or perhaps minor improvement from realloc. Instead the "Show only important changes" button shows multiple red entries (which I assume mean regression) and no improvement :(
The only other difference I can think of that could be meaningful is the lack of #[inline] and #[inline(never)] attributes in https://github.com/servo/rust-smallvec/pull/214. Emilio, do you think that could explain such a perf impact?
| Assignee | ||
Comment 4•5 years ago
|
||
Hard to say, SmallVec is generic so I expect inlining for almost everything to work just fine. Adding #[inline(always)] to the non-generic error conversions that are in that PR and in the patch from this bug may be worth it, as I think otherwise we might be paying a function call if those get called outside the fallible crate. But hard to say without looking at the generated code.
We use SmallVecs infallible methods quite pervasively too, I'd look at the generated code in the selector_map (that uses the fallible version), and for the cascade / invalidation / matching / style sharing code (which uses the infallible one).
| Assignee | ||
Comment 5•5 years ago
|
||
I had a hunch about reserve() getting inlined inside push() and thus blowing the size of some hot loops during style resolution.
I did some try pushes:
- https://treeherder.mozilla.org/#/jobs?repo=try&revision=bdf2d274334c51b296a8fc53fe8fb30676e1aeca (base, just central)
- https://treeherder.mozilla.org/#/jobs?repo=try&revision=d97158ba707266b74128b750a7e2ebb9fc1acb3c (your patches)
- https://treeherder.mozilla.org/#/jobs?repo=try&revision=472395874062282334adadfff93b422339fbf6ab (a patch making reserve cold from push)
- https://treeherder.mozilla.org/#/jobs?repo=try&revision=e82fe075ec1827f2c2942199aa161c56d4779412 (a patch going back to always malloc() + memmove instead of realloc()).
- https://treeherder.mozilla.org/#/jobs?repo=try&revision=1c29c605d43a5f572b3f5b8eda3430037504a6f2 (both of the above).
| Assignee | ||
Comment 6•5 years ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)
- https://treeherder.mozilla.org/#/jobs?repo=try&revision=472395874062282334adadfff93b422339fbf6ab (a patch making reserve cold from push)
So this one didn't help much, if so only marginally: https://treeherder.mozilla.org/perf.html#/compare?originalProject=try&originalRevision=bdf2d274334c51b296a8fc53fe8fb30676e1aeca&newProject=try&newRevision=472395874062282334adadfff93b422339fbf6ab&framework=10
- https://treeherder.mozilla.org/#/jobs?repo=try&revision=e82fe075ec1827f2c2942199aa161c56d4779412 (a patch going back to always malloc() + memmove instead of realloc()).
This one looks busted because I had the cargo patch in the other patch...
But with this one perf looks good again: https://treeherder.mozilla.org/perf.html#/compare?originalProject=try&originalRevision=bdf2d274334c51b296a8fc53fe8fb30676e1aeca&newProject=try&newRevision=1c29c605d43a5f572b3f5b8eda3430037504a6f2&framework=10
So it seems like realloc() is slower than malloc() + memmove at least from stylo, from multiple threads. Mike, is that expected? May it be related to the jemalloc arenas thing that we use from the style system or such?
| Assignee | ||
Comment 7•5 years ago
|
||
I tried to profile this but I couldn't get symbols for the stuff under replace_realloc, so not all that useful.
| Assignee | ||
Comment 8•5 years ago
|
||
https://perfht.ml/3aBnPqe is the uri just in case.
Comment 9•5 years ago
|
||
Try comparing when PHC is disabled?
| Assignee | ||
Comment 10•5 years ago
|
||
Base: https://treeherder.mozilla.org/#/jobs?repo=try&revision=6b17eb313e9e2714cc123e0682a51a58345631fc
Patch: https://treeherder.mozilla.org/#/jobs?repo=try&revision=d737b3965ebbeec389d75c56f0692ab76648369f
Base minus PHC: https://treeherder.mozilla.org/#/jobs?repo=try&revision=df5fb9b371a3bb91dab8149c4ecc07918da71f34
Patch minus PHC: https://treeherder.mozilla.org/#/jobs?repo=try&revision=4a0bd67e8593257d2a60c2b6e862ca9ce77ed376
| Assignee | ||
Comment 11•5 years ago
|
||
It doesn't seem like PHC significantly affects perf here: https://treeherder.mozilla.org/perf.html#/compare?originalProject=try&originalRevision=6b17eb313e9e2714cc123e0682a51a58345631fc&newProject=try&newRevision=4a0bd67e8593257d2a60c2b6e862ca9ce77ed376&framework=10
Comment 12•5 years ago
|
||
There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:SimonSapin, could you have a look please?
For more information, please visit auto_nag documentation.
| Reporter | ||
Comment 13•5 years ago
|
||
These patches (specifically using realloc instead of malloc + copy + free) cause a regression that still needs to be investigated / fixed, but I don’t know when I’ll get to this. If it helps triage I don’t mind marking this bug "resolved incomplete" or something similar, in the meantime.
| Assignee | ||
Comment 14•5 years ago
|
||
Bug 1681003 was the allocator bug.
Updated•5 years ago
|
| Assignee | ||
Updated•5 years ago
|
Comment 15•5 years ago
|
||
Updated•5 years ago
|
Comment 16•5 years ago
|
||
Comment 17•5 years ago
|
||
| bugherder | ||
| Assignee | ||
Updated•5 years ago
|
Comment 18•5 years ago
|
||
| bugherder | ||
Updated•3 years ago
|
Description
•