Skip to content
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

Memoize the key of instance_variable_set #411

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ooooooo-q
Copy link

I used memory_profiler to check where rubyXL was using a lot of memory, and fixed it.

"@#{v[:accessor]}" generates two String objects, which can be expensive depending on the access frequency, so we memoized it.

Result

rubyXL 3.4.20 (with Ruby 3.1.0)

  • write file
    • Total allocated: 16.41 MB (335760 objects)
    • Total retained: 6.58 kB (128 objects)
  • read file
    • Total allocated: 24.26 MB (340069 objects)
    • Total retained: 6.23 kB (57 objects)

memoize "@#{v[:accessor]}"

  • write file
    • Total allocated: 14.06 MB (276927 objects)
    • Total retained: 23.97 kB (558 objects)
  • read file
    • Total allocated: 21.82 MB (279137 objects)
    • Total retained: 23.62 kB (487 objects)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant