Closed Bug 1632469 Opened 5 years ago Closed 5 years ago

Update rust-smallvec, use its try_reserve method

Categories

(Core :: CSS Parsing and Computation, task)

task

Tracking

()

RESOLVED FIXED
85 Branch
Tracking Status
firefox85 --- fixed

People

(Reporter: SimonSapin, Assigned: emilio)

References

Details

Attachments

(2 files)

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.

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?

Flags: needinfo?(emilio)

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).

Flags: needinfo?(emilio)

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:

(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)

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

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?

Flags: needinfo?(mh+mozilla)

I tried to profile this but I couldn't get symbols for the stuff under replace_realloc, so not all that useful.

https://perfht.ml/3aBnPqe is the uri just in case.

See Also: → 1632972

Try comparing when PHC is disabled?

Flags: needinfo?(mh+mozilla) → needinfo?(emilio)

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.

Flags: needinfo?(simon.sapin)

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.

Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(simon.sapin)
Resolution: --- → INCOMPLETE

Bug 1681003 was the allocator bug.

Assignee: simon.sapin → emilio
Status: RESOLVED → REOPENED
Depends on: 1681003
Resolution: INCOMPLETE → ---
Attachment #9142706 - Attachment description: Bug 1632469 - Update rust-smallvec to 1.4.0 → Bug 1632469 - Update smallvec.
Keywords: leave-open
Attachment #9142707 - Attachment description: Bug 1632469 - Use `SmallVec::try_reserve` → Bug 1632469 - Use `SmallVec::try_reserve`.
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f4ee87577e77 Use `SmallVec::try_reserve`. r=manishearth
Keywords: leave-open
Status: REOPENED → RESOLVED
Closed: 5 years ago5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch
Flags: needinfo?(mh+mozilla)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: