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
Optimize memory used by the publish
calls
#289
Conversation
…s reduced from 33.8 to 32.8 MiB
Reproduced the failure with: rm -rf build
mkdir build
cd build
cmake ..
make -j`nproc`
../tests/yast_spec.rb |
BTW I've tried enabling frozen string literals to see what memory effect it has, but fast_gettext does not like it, starting here $ ruby --enable=frozen-string-literal -r ../tests/test_helper.rb ../profiling/yast_import.rb |& o
/usr/lib64/ruby/gems/2.5.0/gems/fast_gettext-1.6.0/lib/fast_gettext/vendor/mofile.rb:52:in `force_encoding': can't modify frozen String (FrozenError)
from /usr/lib64/ruby/gems/2.5.0/gems/fast_gettext-1.6.0/lib/fast_gettext/vendor/mofile.rb:52:in `<class:MOFile>'
... |
First, frozen string literals are possible if I apply this diff--- /usr/lib64/ruby/gems/2.5.0/gems/fast_gettext-1.6.0/lib/fast_gettext/vendor/mofile.rb.orig 2023-04-03 14:03:16.711532621 +0200
+++ /usr/lib64/ruby/gems/2.5.0/gems/fast_gettext-1.6.0/lib/fast_gettext/vendor/mofile.rb 2023-04-03 14:06:38.496909306 +0200
@@ -46,11 +46,14 @@
:trans_sysdep_tab_offset
end
- MAGIC_BIG_ENDIAN = "\x95\x04\x12\xde"
- MAGIC_LITTLE_ENDIAN = "\xde\x12\x04\x95"
+ mbe = "\x95\x04\x12\xde"
+ mle = "\xde\x12\x04\x95"
if "".respond_to?(:force_encoding)
- MAGIC_BIG_ENDIAN.force_encoding("ASCII-8BIT")
- MAGIC_LITTLE_ENDIAN.force_encoding("ASCII-8BIT")
+ MAGIC_BIG_ENDIAN = mbe.dup.force_encoding("ASCII-8BIT")
+ MAGIC_LITTLE_ENDIAN = mle.dup.force_encoding("ASCII-8BIT")
+ else
+ MAGIC_BIG_ENDIAN = mbe
+ MAGIC_LITTLE_ENDIAN = mle
end
def self.open(arg = nil, output_charset = nil) Then, as I was documenting it, I looked at your Exportable optimization and realized that it can be improved 😄 (I've added the under_scores manually) before frozen path with frozen path: note that it does not affect the retained values with global string freeze (would need the above fix in fast_gettext) pairs instead of name+type hashes, without global string freeze pairs instead of name+type hashes, with global string freeze I really wonder how this performs on a real workload |
instead of two-keyed hashes, to further reduce memory consumption for this overhead
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.
more improvements
@jreidinger later, I think it is worth looking at the retained foo part of the |
Co-authored-by: Martin Vidner <mvidner@suse.cz>
✔️ Public Jenkins job #70 successfully finished |
✔️ Internal Jenkins job #58 successfully finished |
Problem
Agame and also yast consume quite bit of memory, so lets try to optimize it.
Solution
Add some profiling code and based on it, apply some optimization.
Optimization results ( testing on Leap15.4 so with ruby 2.5 ) just totals:
Original result:
after first optimization:
after second optimization:
So result is roughly saved 2650 KiB of allocated and in persistent it is 1021 KiB on testing sample that just require yast and imports some yast modules.