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

fix: build on windows #684

Merged
merged 19 commits into from
Sep 5, 2024
Merged

fix: build on windows #684

merged 19 commits into from
Sep 5, 2024

Conversation

spector-9
Copy link
Contributor

@spector-9 spector-9 commented Sep 3, 2024

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.

  • I have written the necessary rustdoc comments
  • I have added the necessary unit tests and integration tests
  • I have passed make all (or make fast instead if the old tests are not modified) in my local environment.
  • the specific steps in the makefile are not compatible with windows. Ran cargo test though*

close #263

- 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))?;
Copy link
Contributor Author

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.

Copy link
Collaborator

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)

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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. 🤣

@MrCroxx
Copy link
Collaborator

MrCroxx commented Sep 3, 2024

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. 🥰

foyer-storage/src/device/direct_fs.rs Outdated Show resolved Hide resolved
foyer-common/src/fs.rs Outdated Show resolved Hide resolved
foyer-storage/src/device/direct_file.rs Outdated Show resolved Hide resolved
@MrCroxx MrCroxx added the feature New feature or request label Sep 4, 2024
@MrCroxx MrCroxx added this to the v0.12 milestone Sep 4, 2024
@MrCroxx MrCroxx changed the title Fix: Build on windows fix: build on windows Sep 4, 2024
@MrCroxx
Copy link
Collaborator

MrCroxx commented Sep 4, 2024

the specific steps in the makefile are not compatible with windows. Ran cargo test though*

BTW, what build system is most widely used on Windows? Is powershell script okay to replace Makefile?

@spector-9 spector-9 force-pushed the windows_fix branch 3 times, most recently from 88accc3 to db5cc49 Compare September 4, 2024 05:26
@spector-9
Copy link
Contributor Author

spector-9 commented Sep 4, 2024

the specific steps in the makefile are not compatible with windows. Ran cargo test though*

BTW, what build system is most widely used on Windows? Is powershell script okay to replace Makefile?

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.

@spector-9 spector-9 requested a review from MrCroxx September 4, 2024 06:10
- Use write_all instead of write to handle amount of bytes written
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
foyer-common/src/fs.rs 66.66% 1 Missing ⚠️
Files with missing lines Coverage Δ
foyer-storage/src/device/direct_file.rs 85.94% <100.00%> (+0.23%) ⬆️
foyer-storage/src/device/direct_fs.rs 88.76% <100.00%> (+0.19%) ⬆️
foyer-storage/src/large/generic.rs 88.61% <ø> (ø)
foyer-common/src/fs.rs 25.92% <66.66%> (-5.11%) ⬇️

... and 1 file with indirect coverage changes

Copy link
Collaborator

@MrCroxx MrCroxx left a 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.

foyer-storage/src/device/direct_file.rs Outdated Show resolved Hide resolved
foyer-storage/src/device/direct_file.rs Outdated Show resolved Hide resolved
@spector-9
Copy link
Contributor Author

@MrCroxx Let me know if I need to do something else. Thanks for your help.

@MrCroxx
Copy link
Collaborator

MrCroxx commented Sep 5, 2024

@MrCroxx Let me know if I need to do something else. Thanks for your help.

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 ~

Copy link
Collaborator

@MrCroxx MrCroxx left a 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 . 🥰

@MrCroxx MrCroxx merged commit 9581d99 into foyer-rs:main Sep 5, 2024
21 of 22 checks passed
@MrCroxx MrCroxx modified the milestones: v0.12, v0.11 Sep 5, 2024
@MrCroxx MrCroxx mentioned this pull request Sep 5, 2024
3 tasks
@MrCroxx
Copy link
Collaborator

MrCroxx commented Sep 5, 2024

https://x.com/CroxxMr/status/1831599811273093490

🥰 @spector-9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

is support on windows?
2 participants