-
Notifications
You must be signed in to change notification settings - Fork 8
Pool file handles to prevent "too many open files" errors #161
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
jeskesen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. with a couple of comments/questions
|
|
||
| time_az_ms, frame_write_times_az = run_acquire_zarr_test(data, az_path, t_chunk_size, xy_chunk_size) | ||
|
|
||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a commented block of code meant to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thank you.
| #include <string> | ||
|
|
||
| namespace zarr { | ||
| class FileHandle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to look at this for a bit before figuring out what its function is (wrapping the platform-specific file handles into a class C++ can work with). Perhaps a comment to that effect?
So, why go through all that effort when std::filesystem exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I need to use the platform-specific functions to get finer control and better performance. For example, #156 is not possible using the standard library.
Introduces a
FileHandlePoolclass (similar toThreadPoolandS3ConnectionPoolto manage file handle allocation and prevent exhausting OS limits during concurrent file I/O. This PR actually increases in some cases the number of open files that acquire-zarr may have at a time, due to the old scheme being limited by a fixed, more or less arbitrary, constant.Changes
FileHandleandFileHandlePoolclasses to manage file handle lifecyclegetrlimit(RLIMIT_NOFILE)on POSIX,_getmaxstdio()on Windows)FileSinkconstructor,ArrayBaseconstructors, and the variousmake_file_sinkoverloads require astd::shared_ptr<FileHandlePool>. These changes are BREAKING but internal.