-
Notifications
You must be signed in to change notification settings - Fork 298
Use archive.bulk() to avoid EMFILE errors
#118
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
Conversation
As per the documentation, the `archive.bulk()` call promises to avoid EMFILE errors (too many open files).
|
Class. Have you manually tested this yeah? I assume we can't realistically create a test for this. |
|
Sorry I should have mentioned that I have only had the chance to test this on windows for now. I can test on osx at work tomorrow. |
|
Cool. So you have a test app on Windows which causes an EMFILE error and it's gone with this change? That's good. Unfortunately there are still EMFILE errors when we do copying with ncp. I created graceful-ncp (which depends on graceful-fs instead of plain fs) to get around this. It's implemented on the graceful-ncp branch. I'm not sure if this is the right way to go and I haven't tested it thoroughly enough with a test app with a lot of files, yet. |
|
Just from skimming the readme, it appears as if |
|
I saw that but we have no idea how many files the user has. Ideally, we'd love the limit to be infinite 😛. Once graceful-fs encounters an EMFILE error, it just retries after a timeout. This seems like a better way to do it; it doesn't matter which platform the end user is on / how many files they have. I looked through the ncp issues and it seems the maintainer is really keen on avoiding dependencies so that's why he won't use graceful-fs. |
|
I suppose then it comes down to just testing. I will pull down your branch tomorrow, apply this patch and see if there are any errors. I can invoke an EMFILE 100% of the time on our project if my glob patterns are generous enough. Should be possible to write a test for it as well, don't you think? Create a bunch of files with junk in it, and then zip them and copy them. However, it almost feels like these tests should live in the respective repositories. |
|
Sounds good. I got all of that except for this bit:
|
|
What I meant was that it's probably more useful if the graceful-npc repo was to have a test that verifies the expected behaviour, that is copying a lot of files without hitting EMFILE. And likewise, it would probably more useful, if the archiver repo had a test verifying that the |
|
I have tested this by the way and it works fine. |
|
Yeah that makes sense. What exactly did you test so? |
|
I tested using your graceful ncp branch with my patch applied on a project that through EMFILEs 100% of the time and now doesn't. |
|
Great. This is what I think needs to be done:
|
|
Sounds good, to bridge the interim we are using my fork's graceful-ncp branch which has the patch applied in our package.json. Works fine. Let me know if I can be of further help to push this along. |
|
If you could create a PR from your patch into our graceful-ncp branch, then I'll merge it right away and test when I get a chance. |
|
What was the app like that gave the EMFILE for you? How many files did you have roughly? (that'll also be handy to know for tests for graceful-ncp itself). I tried with a lot of files but in the end resorted to switching from Windows to Mac and running |
|
archiver uses
|
|
Sounds like we need a queuing / throttling mechanism that has a max size
|
|
i may have spoken a bit prematurely. i was thinking at it a little differently. zip creation is a serial process and as such archiver does stream source by source. thus at any given time, there should only be 6 files open from FS ( src, dest, up to 4 stat workers) assuming your using v0.12. that said there could be multiple files contents in the internal buffer at one time waiting to be drained to your dest. are you sure the EMFILE originates from archiver? |
|
i should mention that if archiver didn't use |
|
Pretty sure we have this in a very good state now. Works reliably for me now, even if I reduce my |
|
there is a slight overhead using |
|
@ctalkington we're using 0.10. I'll bump to 0.12 when I get a chance. |
|
Bumped to archiver@0.13. Closing this in favour of #123 |
As per the documentation, the
archive.bulk()call promises to avoidEMFILE errors (too many open files).