This is an archive of the discontinued LLVM Phabricator instance.

[pseudo] Store reduction sequences by pointer in heaps, instead of by value.
ClosedPublic

Authored by sammccall on Jun 21 2022, 3:20 PM.

Details

Summary

Copying sequences around as the heap resized is significantly expensive.

This speeds up glrParse by ~35% (2.4 => 3.25 MB/s)

Diff Detail

Event Timeline

sammccall created this revision.Jun 21 2022, 3:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2022, 3:20 PM
sammccall requested review of this revision.Jun 21 2022, 3:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2022, 3:20 PM
hokein accepted this revision.Jun 22 2022, 7:19 AM
hokein added inline comments.
clang-tools-extra/pseudo/lib/GLR.cpp
208

I start to have a nervous feeling that we're going to add more and more intermediate data structure, which increases the complexity of the code, but I think the improvement is large enough to justify.

220

nit: add a default value nullptr

269

Just an idea (no action required)

If we want to do further optmization, here if a sequence have multiple Bases, we will have multiple elements in Sequences -- they have the form of (F, PushSpec{N, Seq}) where only N (the base node) is different.

  • if we change the PushSpec::Base to store the child node of Base, we could save a bunch of space in Sequences. (The base can be retrieved dynamically from the child->parents()).
317

What's XXX?

This revision is now accepted and ready to land.Jun 22 2022, 7:19 AM
sammccall marked 2 inline comments as done.Jun 23 2022, 10:40 AM
sammccall added inline comments.
clang-tools-extra/pseudo/lib/GLR.cpp
208

Agree :-(

269

This is interesting! Essentially the reason we do the DFS eagerly (and pay to store its results) is we have to establish the Family via the start token, but this means we have to go only as far as the end of the sequence, rather than one further. (One further feels "cleaner" somehow, but who cares...)

I'll give this a try (not in this patch)

317

Oops, this was left-over from when Sequences stored by pointer and FamilySequences stored by value. Removed.

This revision was landed with ongoing or failed builds.Jun 23 2022, 10:41 AM
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
sammccall added inline comments.Jun 23 2022, 11:10 AM
clang-tools-extra/pseudo/lib/GLR.cpp
269

This is a ~5% speedup, for almost no extra code (just some comments).
Landed as 466eae6aa3574aea6604d42666f099025718ffa4