{"action":"created","issue":{"url":"https://api.github.com/repos/knu/ruby-domain_name/issues/6","labels_url":"https://api.github.com/repos/knu/ruby-domain_name/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/knu/ruby-domain_name/issues/6/comments","events_url":"https://api.github.com/repos/knu/ruby-domain_name/issues/6/events","html_url":"https://github.com/knu/ruby-domain_name/pull/6","id":103098823,"number":6,"title":"Memory refactor","user":{"login":"dgilperez","id":264590,"avatar_url":"https://avatars.githubusercontent.com/u/264590?v=3","gravatar_id":"","url":"https://api.github.com/users/dgilperez","html_url":"https://github.com/dgilperez","followers_url":"https://api.github.com/users/dgilperez/followers","following_url":"https://api.github.com/users/dgilperez/following{/other_user}","gists_url":"https://api.github.com/users/dgilperez/gists{/gist_id}","starred_url":"https://api.github.com/users/dgilperez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgilperez/subscriptions","organizations_url":"https://api.github.com/users/dgilperez/orgs","repos_url":"https://api.github.com/users/dgilperez/repos","events_url":"https://api.github.com/users/dgilperez/events{/privacy}","received_events_url":"https://api.github.com/users/dgilperez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-25T19:31:45Z","updated_at":"2015-09-17T15:58:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/knu/ruby-domain_name/pulls/6","html_url":"https://github.com/knu/ruby-domain_name/pull/6","diff_url":"https://github.com/knu/ruby-domain_name/pull/6.diff","patch_url":"https://github.com/knu/ruby-domain_name/pull/6.patch"},"body":"Hi!\r\n\r\nI was playing with [derailed_benchmarks](https://github.com/schneems/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 to `domain_name`. \r\n\r\nI 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`. \r\n\r\nThis PR is my take towards this. Please let me know what do you think. \r\n\r\nThe output of `bundle exec derailed bundle:mem` (locally adding `derailed` as a development dependency) was: \r\n\r\n    TOP: 2.4141 MiB\r\n      domain_name: 2.3789 MiB\r\n        domain_name/etld_data: 2.0859 MiB\r\n\r\nAnd after the changes here is: \r\n\r\n    TOP: 0.7109 MiB\r\n      domain_name: 0.668 MiB\r\n        yaml: 0.4609 MiB\r\n          psych: 0.457 MiB\r\n\r\nBeing half of the memory actually been used by `yaml`, which will be already a dependency quite a lot of apps already down there. \r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/knu/ruby-domain_name/issues/comments/141131525","html_url":"https://github.com/knu/ruby-domain_name/pull/6#issuecomment-141131525","issue_url":"https://api.github.com/repos/knu/ruby-domain_name/issues/6","id":141131525,"user":{"login":"dgilperez","id":264590,"avatar_url":"https://avatars.githubusercontent.com/u/264590?v=3","gravatar_id":"","url":"https://api.github.com/users/dgilperez","html_url":"https://github.com/dgilperez","followers_url":"https://api.github.com/users/dgilperez/followers","following_url":"https://api.github.com/users/dgilperez/following{/other_user}","gists_url":"https://api.github.com/users/dgilperez/gists{/gist_id}","starred_url":"https://api.github.com/users/dgilperez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgilperez/subscriptions","organizations_url":"https://api.github.com/users/dgilperez/orgs","repos_url":"https://api.github.com/users/dgilperez/repos","events_url":"https://api.github.com/users/dgilperez/events{/privacy}","received_events_url":"https://api.github.com/users/dgilperez/received_events","type":"User","site_admin":false},"created_at":"2015-09-17T15:58:07Z","updated_at":"2015-09-17T15:58:07Z","body":"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](http://docs.ruby-lang.org/en/2.1.0/marshal_rdoc.html#label-Stream+Format) say: \r\n\r\n> The first two bytes of the stream contain the major and minor version, each as a single byte encoding a digit. The version implemented in Ruby is 4.8 (stored as “x04x08”) and is supported by ruby 1.8.0 and newer.\r\n\r\n> Different major versions of the Marshal format are not compatible and cannot be understood by other major versions. Lesser minor versions of the format can be understood by newer minor versions. Format 4.7 can be loaded by a 4.8 implementation but format 4.8 cannot be loaded by a 4.7 implementation. \r\n\r\nSo 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 ... \r\n\r\nAnyway, the main reason for using Marshall is speed, and although that is a [clear advantage](http://blog.pivotal.io/labs/labs/marshal-dump-vs-yaml-dump) for `.dump`, that is probably not the point here. Deserializing is also reportedly faster with Marshal, but [not that much](http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/). \r\n\r\nI may be missing a whole bunch of points here anyway. Let me know if you want me to use `Yaml` instead."}}