-
Notifications
You must be signed in to change notification settings - Fork 5
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
Implement a file handle cache #54
Conversation
Would it be reasonable to make this a cache with a TTL and/or the cache invalidates on being serialized? |
TTL would be good, yes. In the case a loop is available, it should be easy to implement the expiry watchdog with an asyncio.sleep. |
To prevent constantly opening and closing in calls to cat_file. Also, fix up the vector read size code to work correctly lint
5abaf07
to
a209f38
Compare
@chrisburr if you can also give this a review that'd be good |
FWIW you can probably be much more aggressive with the default TTL, even if it's 5s you're not spamming the server with open requests at that point. Or do studies indicate this is not the case? |
5 seconds is very short, I've not
As it stands it looks like a file could be closed while a read is actively running? Maybe you need a semaphore around the file handle so it's only eligable for removal when the count of active users is zero. |
If we require the |
Ok, neither operation fails. I guess it just completes the read. In this case there shouldn't be any issue. |
@lobis (and/or @chrisburr ) can you review this? |
repinging this @lobis (and/or @chrisburr ) can you review this? |
To prevent constantly opening and closing in calls to cat_file, introduce a fs-level cache of open read-only file handles. If a file handle needs to be opened for writing, we first close any read-only handles to the same path.
Since fsspec by design keeps AbstractFileSystem objects alive indefinitely through a metaclass, we implement a TTL mechanism to expire our client's read-only handles so that other clients may have a chance of succeeding in opening the file for writing. If not, other clients may encounter: