-
Notifications
You must be signed in to change notification settings - Fork 637
Speedup Computation for whether Aggregates containsProbe #4656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Caching these recursive type properties is a good call, thanks!
Only doubt is if a Data is re-used or mutated to be probe-y, but not sure that's a thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is reasonable as is but there are a couple of possible improvements:
- Specialize this on Vec to only check the sample element
- Consider doing it live with some normal traversal. This is tricky to figure out the right place so I'm not sure it's worth untangling at the moment, but e.g. we do that for if something contains a flipped [1]. That spot won't quite work because we do
containsProbe
on unbound types, but maybe we can figure out a similar approach.
and uses of This will increase the object size of anything that's an Aggregate to accommodate the new field -- offhand I don't know the best recommendation but IIRC @jackkoenig went around with some tricks to reduce size needed for lazy vals in common objects? Or thereabouts? |
I'm not too worried about an extra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val ret: T = if (!data.mustClone(prevId)) data else data.cloneType.asInstanceOf[T]
This is a problem though, good eye @dtzSiFive
@mwachs5 please add a test for this, I'm struggling to suggest the precise check but given an Aggregate that is taking advantage of the !mustClone, it will have its containsProbe
memoized to false but then it will be mutated to itself be a Probe.
I think there are a couple of ways to fix this.
- Do the
.containsProbe
check after "maybe clone" part. But I don't think this is the best way because I think this mix of laziness and mutation could come up in a different place some day. - Change the value we're memoizing to be "containsChildProbe" or something since that can never change--then the
containsProbe
check is "am I a probe OR do I containChildProbe".
Actually it does seem like the intent of "containsProbe" is already asking about Aggregates containing children that are probes. But it's inconsistent, because "containsProbe" on a non-Aggregate does check if it locally is a Probe. In theory, an Element could never "contain" a probe.
Same "is or contains a probe" use in ChiselEnum:
|
i like the "contains child probe" formulation, will do that. And will add some tests specifically for this |
I am going with containsProbe means "is or contains a probe". Added a bunch of tests for this. I renamed the aggregate variable to be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
Changed milestone to 6.x because probes didn't exist until then.
* save the elementContainsProbes for an Aggregate to speed up various computations * add unit tests for ContainsProbe (cherry picked from commit c9cecfa)
✅ Backports have been created
|
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Add a private containsProbe var to Aggregate and use it to speed up containsProbe checks.
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
and clean up the commit message.Create a merge commit
.