Optimize Valid, Decoupled, and Irrevocable by using () => gen#5205
Open
jackkoenig wants to merge 2 commits intomainfrom
Open
Optimize Valid, Decoupled, and Irrevocable by using () => gen#5205jackkoenig wants to merge 2 commits intomainfrom
jackkoenig wants to merge 2 commits intomainfrom
Conversation
This involves a change to the type of the default constructor to pass a function instead of just a Data object. This fixes an O(n^2) issue where gen needed to be cloned twice. Once because the compiler plugin has to be conservative and clone, but then second because gen is an eager argument, it is constructed before the Output(...) invocation so Output also has to clone. By using () => gen, the compiler plugin will no longer clone the Data. The function will be called in a way that Output can detect if the result is fresh or not so it will only be cloned once.
Contributor
Author
|
I'm waiting for some numbers from @trmckay to see how much this helps in practice. I don't love this whack-a-mole style of fixing this problem but that more complete solutions are hard... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an API deprecation but it's effect is a performance improvement. See the release notes for the explanation.
The performance problem being fixed here is a really tough one, it can come up in user-defined types and I don't think there's an easy way to fix it in Chisel for all users. Fixing it for Valid, Decoupled, and Irrevocable (but mainly Valid because users sometimes nest that) helps, and it provides an example of what to do, but the fundamental problem remains. I don't really know how to fix it fundamentally other than by:
Aligned/FlippedorField- then autoclonetype wouldn't need to clonegen: () => Tpattern rather thangen: T(we could do this in compiler plugin as a warning)Using this little benchmark that I had an AI generate: https://gist.github.com/jackkoenig/12f6d6bfeee04f00404e4563898957ae
Deep nesting comparison (depth 8 vs depth 1):
Contributor Checklist
docs/src?Type of Improvement
Desired Merge Strategy
Release Notes
This involves a change to the type of the default constructor to pass a function instead of just a Data object. This fixes an O(n^2) issue where gen needed to be cloned twice. Once because the compiler plugin has to be conservative and clone, but then second because gen is an eager argument, it is constructed before the Output(...) invocation so Output also has to clone. By using () => gen, the compiler plugin will no longer clone the Data. The function will be called in a way that Output can detect if the result is fresh or not so it will only be cloned once.
Reviewer Checklist (only modified by reviewer)
3.6.x,5.x, or6.xdepending on impact, API modification or big change:7.0)?Enable auto-merge (squash)and clean up the commit message.Create a merge commit.