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

Huge memory consumption when running on large repository with many codeowners rules #18

Open
adammichalik opened this issue Feb 18, 2021 · 9 comments

Comments

@adammichalik
Copy link

I have a large repository, containing ~500 000 files (in a large directory tree). Running codeowners -u on it requires allowing around 8 GB RAM to NodeJS (--max_old_space_size=8000) and I see it increasing as the scan progresses. It's an issue both for running locally an in an automatic pipeline.

I didn't expect filesystem traversal to require linearly increasing memory usage. Is there a reason for it?

@beaugunderson
Copy link
Owner

beaugunderson commented Feb 18, 2021 via email

@beaugunderson
Copy link
Owner

@adammichalik will require a quick rewrite to change this from "collect, filter, map" to a streaming API but I think that's a better match here; please ping me again if I lose track of this :)

@beaugunderson
Copy link
Owner

beaugunderson commented Feb 24, 2021 via email

@adammichalik
Copy link
Author

I tried 5.0.1, but it blows up on an out of memory error just the same. I will try to create a good testing repository sometime next week to support this case.

@beaugunderson
Copy link
Owner

beaugunderson commented Feb 24, 2021 via email

@beaugunderson
Copy link
Owner

@adammichalik OK, try 5.1.0; tried on a directory structure of 7.3 million files and never got above 2gb of consumption; it's also quite a bit faster as I switched to a stream approach (and that 2gb of consumption is the high-water mark for buffered stream contents, I think... I've addressed any possible memory leaks)

@adammichalik
Copy link
Author

I did more digging and the issue seems to stem from the combination of the size of the CODEOWNERS file and the repo itself. If I place an empty CODEOWNERS file in it, the -u command runs blazingly fast and with no issues. With a CODEOWNERS file with 1571 rules, as in my real project, I get an out of memory error. See sample file:
CODEOWNERS.zip

@beaugunderson
Copy link
Owner

beaugunderson commented Feb 25, 2021 via email

@adammichalik adammichalik changed the title Huge memory consumption when running on large repository Huge memory consumption when running on large repository with many codeowners rules Mar 4, 2021
@donbeattie
Copy link

donbeattie commented Nov 3, 2021

I've run into the same issue. We have a monolith in one of our repos and we are using the CODEOWNERS file to claim ownership across 60 teams. Any progress on a fix for this? Any temporary workarounds you could suggest? Thanks!

UPDATE: Updating node to v17.0.1 solved the problem for me without adjusting memory settings.

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

No branches or pull requests

3 participants