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

Reduce memory allocated when rendering the index page #559

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

fatkodima
Copy link
Contributor

When rendering an index page, coverband makes a lot of unneeded allocations.

Before

Total allocated: 349.10 MB (1788664 objects)

After

Total allocated: 212.79 MB (1134381 objects)

So, it is now 40% less in my case.

@@ -222,8 +222,8 @@ def search_paths=(path_array)
# Don't allow the ignore to override things like gem tracking
###
def ignore=(ignored_array)
ignored_array.map { |ignore_str| Regexp.new(ignore_str) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here was an attempt to convert keys to regexps, but because of the bug, this line was a no-op.

ignored_array.map { |ignore_str| Regexp.new(ignore_str) }
@ignore = (@ignore + ignored_array).uniq
ignored_array = ignored_array.map { |ignore_str| Regexp.new(ignore_str) }
@ignore |= ignored_array
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I think we want to assign here with a uniq... the purpose of this is that folks can add overrides to ignores... traditionally those have always been strings... so it is good to fix the bug, but I think we still need the (@ignore + ignored_array).uniq type logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ignore |= ignored_array is the same as @ignore = (@ignore + ignored_array).uniq.
Correct me if I am wrong.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha you are correct, I just don't use the single |= very often... this works

Copy link
Owner

@danmayer danmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one issues on how ignore is extended

@danmayer
Copy link
Owner

thanks it is great to get performance and memory enhancing PRs, I appreciate all the effort digging in on this @fatkodima

@danmayer danmayer merged commit 4b408af into danmayer:main Oct 16, 2024
80 checks passed
@fatkodima fatkodima deleted the memory_optimizations branch October 16, 2024 18:31
@danmayer
Copy link
Owner

this and all the other changes you submitted @fatkodima are in the 6.1.3 release https://github.com/danmayer/coverband/releases/tag/v6.1.3

@fatkodima
Copy link
Contributor Author

Thank you! ❤️ Was waiting for it, going to try tomorrow.

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.

2 participants