-
Notifications
You must be signed in to change notification settings - Fork 175
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
Improve performance of LowerTypes renaming #2024
Conversation
m: ModuleTarget, | ||
instance: DefInstance, | ||
namespace: Namespace, | ||
instRenames: mutable.ListBuffer[(Instance, Instance)], |
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.
since you are appending, should this better be an ArrayBuffer?
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.
ListBuffer
has constant time for both prepend and append: https://www.scala-lang.org/api/2.12.11/scala/collection/mutable/ListBuffer.html. I use ListBuffer
whenever I want to mutably build up an immutable Seq
because ListBuffer.toList
is free (copy on write to the underlying buffer).
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.
Cool. I learned something!
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.
Yeah it's pretty neat. I think once we're on 2.13 I might shift to using VectorBuilder
since Vector
is much better in 2.13.2
and has better memory characteristics than List
.
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 as long as all tests pass.
a347503
to
165f7ef
Compare
They were passing but failed because I made |
165f7ef
to
a5877ed
Compare
This is done by having LowerTypes uses two RenameMaps instead of one for each module. There is one for renaming instance paths, and one for renaming everything within modules. Also add some utilities: * TargetUtils for dealing with InstanceTargets * RenameMap.fromInstanceRenames
a5877ed
to
b9dde5e
Compare
This is done by having LowerTypes uses two RenameMaps instead of one for each module. There is one for renaming instance paths, and one for renaming everything within modules. Also add some utilities: * TargetUtils for dealing with InstanceTargets * RenameMap.fromInstanceRenames (cherry picked from commit 15013df)
* Improve performance of LowerTypes renaming (#2024) This is done by having LowerTypes uses two RenameMaps instead of one for each module. There is one for renaming instance paths, and one for renaming everything within modules. Also add some utilities: * TargetUtils for dealing with InstanceTargets * RenameMap.fromInstanceRenames (cherry picked from commit 15013df) * Add MiMa waiver Co-authored-by: Jack Koenig <koenig@sifive.com>
In addition to the added tests, I tested this with 3 different designs, diffing the Verilog and output annotation files and saw the results were identical. Also, pretty sure this is correct because I originally used the
InstanceKeyGraph
from after transformation inLowerTypes
instead of before, and 2/3 of my designs failed.Also, not very scientific, but a design that was running very slowly during renaming in LowerTypes had it's total FIRRTL runtime reduced from
36m45s
to20m45s
, so a massive win.Contributor Checklist
Type of Improvement
API Impact
This adds some new public utilities
Backend Code Generation Impact
No impact
Desired Merge Strategy
Release Notes
Improve performance and memory use of
LowerTypes
Reviewer Checklist (only modified by reviewer)
Please Merge
?