-
Notifications
You must be signed in to change notification settings - Fork 994
Implement garbage collection of IdStrings
#5417
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
base: main
Are you sure you want to change the base?
Conversation
|
We would like to be able to call One way to do this would be to allocate a space of ID values (e.g., the negative values) to represent IDs that don't use the normal string storage or refcount array. Group these special IDs into fixed-size blocks (e.g. 256 IDs), where each block has a stored file/line/function name/autoidx-base and the string for an ID can be computed from the ID and its block's metadata. The refcounts for these negative IDs would be stored in a hashtable so only NEW_IDs that end up in One complicating factor is that |
5728732 to
b99f831
Compare
|
I ended up doing something simpler for To make the special treatment of Currently tests are failing because apparently any nontrivial change to the way ID indices are ordered causes tests to fail 🙁. |
b99f831 to
ff68fc6
Compare
|
Marking this as "ready for review" because although I'm not sure this PR is a slam-dunk as is, I think it's time for some feedback on this approach. |
ff68fc6 to
5212818
Compare
|
One nice thing we can do as part of this is get rid of |
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 haven't looked at the actual code changes yet, but as a perf-first PR, I'm considering it from a perf-first perspective: With this PR, running synth on jpeg from RTLIL regresses from 3.20 seconds to 3.39. With detailed statistics (driver option -d) I can see that opt_clean goes from 273 to 373ms runtime, and that stat reliably goes from 40ms to 104ms runtime. Note: I do all perf testing with clang and LTO
Please investigate if this is incidental or caused by something at the core of the implemented idea
5212818 to
2aaea10
Compare
|
Let's discuss it further in https://yosyshq.discourse.group/t/fixing-idstring-refcounting/94. |
|
BTW I'm pretty sure the test failures are because we're changing the order of ID string indices, and that changes test results. I did an experiment where I mixed a random seed into |
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.
Remaining CI failures:
- with C++20, constexpr
check_formatcan't doYOSYS_ABORT - on Windows, there's no compatible
from_charsdeclaration to the call you added, possibly due to standard library type conversions
…id a strlen when the parameter is a string constant
…en the parameter is a string constant
…unts This saves space and doesn't cost very much since we hardly ever have nonzero refcounts any more. It also allows for IdStrings with negative indexes, which we're going to add.
2fa8b0d to
17ab179
Compare
This is what happens now when the format string doesn't match the parameter types. Fixed.
I needed to use |
17ab179 to
054de3c
Compare
|
@widlarizer By the way I realized I don't actually have the jpeg pre-synth RTLIL, only the post-synth RTLIL, so I'm not actually running the same experiment as you. If you let me know where I can find the pre-synth RTLIL I can run a more accurate experiment. Thanks! |
If your work is part of a larger effort, please discuss your general plans on Discourse first to align your vision with maintainers.
https://yosyshq.discourse.group/t/fixing-idstring-refcounting/
What are the reasons/motivation for this change?
IdStringrefcounting bloats code, has measurable overhead, and would be even higher overhead if we made it thread-safe. It would be nice to get rid of it.Explain how this is achieved.
We may be better off instead garbage-collecting dead
IdStrings at opportune times by tracing the liveDesigns.This PR has the basics and passes Yosys'
make testbut is not yet complete. In particular I want to do something to optimizeNEW_ID.In this PR we only GC
IdStrings during top levelopt_cleans.I considered instead of tracing
Designs, making fields likeNamedObject::namebeOwningIdStrings. That change has ripple effects which would probably break third-party code, so at least for now, I'm sticking with tracing.