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

Let's make file I/O more efficient #223

Open
JustinCappos opened this issue May 3, 2024 · 1 comment
Open

Let's make file I/O more efficient #223

JustinCappos opened this issue May 3, 2024 · 1 comment
Assignees

Comments

@JustinCappos
Copy link
Member

Currently there is a lot of unneeded code in our file system handling which is left over from RepyV2's file interface.

One good thing to address to start with is to remove a lot of unneeded code in Emulfile. Since this is only being called by RustPOSIX with names like linddata.XXX, etc. and operates on a directory it is assumed to control, it really doesn't need most of this checking. I propose this function is changed to only open the file descriptor and set up the object without making any other system calls.

One complication for this plan is how lseek relies on filesize, which is set in this function. One option would be to simply lseek everytime this is called, but this would be inefficient because most lseeks in a program are likely within the file bounds.

To have an efficient solution for this problem without recording the actual file size, I propose that filesize is changed to something like sizeisatleast and for lseek to be called to check if you seek to a position greater than sizeisatleast. This way, a minimal number of lseek operations need to be performed on a file descriptor, while one will not seek past the end of file during a call to write, read, etc.

Of course ftruncate and truncate also need to be modified to update sizeisatleast. fstat also should likely be modified in this case since it reads the actual file size from disk.

@rennergade
Copy link
Contributor

I believe this PR addressed a lot of this, but we still could definitely further clean-up file.rs

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