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

Avoid writing gitattributes file unless necessary #2077

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

vinistock
Copy link
Member

Motivation

When studying the memory bloat for the Tapioca add-on, ObjectSpace.dump_all consistently reports the File.write line for writing the git attributes file as the place in the code retaining the most memory.

I did a few tests and it's something to do with the content. If I get rid of the content variable and just use an empty string, then this line no longer appears in the dump as the top retained memory.

I cannot explain why this is the case given that the heredocs used for the content are frozen strings. I honestly have no idea what's happening here. But avoiding writing the file if it's already there removes this line from the top offenders and no longer retains memory.

Implementation

Started checking if the file exists before writing it.

@vinistock vinistock added the refactor Code refactor with no behaviour change label Nov 20, 2024
@vinistock vinistock self-assigned this Nov 20, 2024
@vinistock vinistock requested a review from a team as a code owner November 20, 2024 15:38
@vinistock vinistock added bugfix and removed refactor Code refactor with no behaviour change labels Nov 20, 2024
@vinistock vinistock merged commit 768aab0 into main Nov 20, 2024
30 of 32 checks passed
@vinistock vinistock deleted the vs-avoid-writing-gitattributes-if-not-needed branch November 20, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants