-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Memory refactor #6
Conversation
👍 |
Cool, but I'd like to know how this would reduce memory footprint before anything. Is that the cost of running the code to build a large hash and then keep the byte code that is only run once? Just curious, but how much of it will stay on memory forever? Yaml would be fine, but I'm not fond of distributing Marshal'd binary because it will enforce you to build a gem with the oldest ruby supported in order to make sure to generate a binary that is readable by any version of ruby. |
etld_data = { 'data_date' => etld_data_date, 'data' => parse(dat) } | ||
|
||
File.open(yaml_file, 'w:utf-8') do |yaml| | ||
yaml.write etld_data.to_yaml |
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 think Yaml.dump(etld_data, yaml)
would be better because it'd save the generation of a large string.
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.
Done!
… rake task and fix bug in data update
About the second part of your question, if I understand correctly how Marshalling works, there should be no problem with ruby >= 1.8.0, as the docs say:
So we might have problems with people using Marshal 4.7 (previous to ruby 1.8), but even if we want to support that (do we?), we may generate the file with that format ... Anyway, the main reason for using Marshall is speed, and although that is a clear advantage for I may be missing a whole bunch of points here anyway. Let me know if you want me to use |
About the first part of the question, I'm not entirely sure. May I politely ask @schneems about his opinion? |
@knu I just pushed a non-marshall version that performs about as well. |
Hey @knu, did you have time to review this? Thanks 😄 |
Hi @knu any news on this? |
So sorry for the delay. Could you rebase this on master? |
Hi!
I was playing with derailed_benchmarks gem in one of my projects, looking to reduce its memory footprint, and I noticed
rest-client
was using quite a few, mainly because of it's dependency todomain_name
.I was looking at your code and noticed that we could improve that by using marshaling rather than a huge constant in
lib/domain_name/etld_data.rb
.This PR is my take towards this. Please let me know what do you think.
The output of
bundle exec derailed bundle:mem
(locally addingderailed
as a development dependency) was:And after the changes here is:
Being half of the memory actually been used by
yaml
, which will be already a dependency quite a lot of apps already down there.Thanks!