-
Notifications
You must be signed in to change notification settings - Fork 1k
Memory-efficient zlib usage across Liberty file consumers #4834
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
povik
left a comment
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've only reviewed gzip.cc/gzip.h, it looks fine except for the nits
| int bytes_read = Zlib::gzread(gzf, buffer, buffer_size); | ||
| if (bytes_read <= 0) { | ||
| if (Zlib::gzeof(gzf)) | ||
| return traits_type::eof(); |
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.
Reading https://en.cppreference.com/w/cpp/io/basic_streambuf/underflow we might need to do something about "On failure, the function ensures that either gptr() == nullptr or gptr() == egptr." because the invariant of when this function is called is weaker, it is "The public functions of std::streambuf call this function only if gptr() == nullptr or gptr() >= egptr()."
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.
Nice catch, now I setg(eback(), egptr(), egptr()); before returning eof
93c6d2d to
b85dda9
Compare
|
e455f4f to
3afbd48
Compare
|
Is there a reason |
|
@KrystalDelusion since that's code I really only moved around without really changing, I think that's a followup issue - if I was more aware of it I may have refactored it to use @whitequark wasn't there a WASI blocker in relation to |
3afbd48 to
980a0a1
Compare
There was yeah. I think I would say this is probably no longer a blocker but someone™ needs to build and test the Wasm port. |
I take it that's more than just the WASI test build included in CI? |
Hm. So it doesn't work in |
|
Sounds good to me, thanks for testing @KrystalDelusion! |
In ASIC flows, Liberty files provided in the PDK can be very large and are often compressed with gzip. Prior to this PR, the only pass that accepted
.lib.gzwasread_liberty, just likeread_verilogaccepts.v.gzetc.-liberty filenamearguments to passes likeclockgateanddfflibmapdidn't use the decompression code.The
decompress_gzipfunction also has been reading the entirety of the uncompressed file into RAM (into a stringstream). This is now fixed by implementing angzip_istreammuch like the pre-existinggzip_ostream. It has one byte of guaranteedunget()which is sufficient for our Liberty parsing. Using gzstream was ruled out because it's LGPL.The PR carries also some shuffling of things around which should have limited impact on plugin devs since the new
kernel/io.hheader is included inkernel/yosys_common.h.This will resolve #4830 but only on the Yosys side. The Yosys
abcpass only hands off the paths specified withabc -liberty pathtoabcbutabcdoesn't support.lib.gzwhich is surprising since it does have its own vendored zlib and wrapper around it used for aiger