-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix: build on windows #684
Conversation
- use fs4 crate to get available space rather than using custom function to make it crossplatform.
- Manually seek and read/write. Rather than using read_at and write_at.
- Scope unused function to unix
let original = file.stream_position()?; | ||
file.seek(std::io::SeekFrom::Start(offset))?; | ||
let read = file.read(buf.as_mut())?; | ||
file.seek(std::io::SeekFrom::Start(original))?; |
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.
We can skip this if you are sure that we don't need to seek the file to beginning because this is trying to emulate read_at behavior.
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.
Hi, @spector-9 . I'm not familar with Windows API. On Linux, positioned read/write will bypass modification of fd, which is lighter and faster.
foyer aims to be a hybrid cache with optimal performance. seek io is not acceptable. (BTW, I think there is concurrent bug without a lock to protect seek and io)
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.
@MrCroxx Hi,
That's why I tried to keep unix and windows separate. On windows there's no read_at so there's no other option than to seek and call synchronous_read under the hood also synchronous_read moves the cursor to whatever happens to be the last position.
To be more ergonomic I can call seek_read rather than manually seeking and then reading. I might also be able to remove the final seek that move the cursor to original position if it's not needed.
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.
Oh, sorry about that. Seems my ios safari browser plugin distribes the github diff and I mistook the add and remove (realky wired...). I'll do a careful review tomorrow.
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.
It revented the color in dark mode. 🤣
Hi, @spector-9 . Thank you very much for your contribution! It would be great to have foyer run on Windows. But I cannot get bandwidth to do it. This PR helps a lot!! I'll review it tomorrow. Thank you again for this PR. 🥰 |
BTW, what build system is most widely used on Windows? Is powershell script okay to replace Makefile? |
88accc3
to
db5cc49
Compare
db5cc49
to
1f23bf5
Compare
Co-authored-by: Croxx <[email protected]>
Honestly I would suggest since this is a rust project use something like nurfile so script/shell is cross-platform. Atleast that's what I use for my projects. If not then I can take a look at makefile and see what can be done to make it work on windows, in a separate PR. |
70654c4
to
a8bd000
Compare
- Use write_all instead of write to handle amount of bytes written
Codecov ReportAttention: Patch coverage is
|
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.
Generally LGTM. Thank you for your contribution again. 🥰
Would you mind my helping you solve the problems above? Besides, I want to setup the CI pipeline on windows.
f287802
to
830ff16
Compare
830ff16
to
99ac2ee
Compare
@MrCroxx Let me know if I need to do something else. Thanks for your help. |
Signed-off-by: MrCroxx <[email protected]>
Hi @spector-9 , Thank you a lot for the contribution. I'll update this branch to try to setup CI on Windows to see if it works. I'm sorry that this may bring you some inconvenience. You need to update your local branch if needed. If this CI passed, this PR will be merged ASAP. Thank you again. 🥰 Wish you enjoy using and developing foyer ~ |
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
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.
CI on Windows passed! Thank you, @spector-9 . 🥰
Currently foyer fails to compile on windows systems. This fixes the errors by adding some line that are cross platform or by adding crates that provide cross platform functionality.
make all
(ormake fast
instead if the old tests are not modified) in my local environment.close #263