Skip to content

io: use posix_fadvise() instead of readahead() #404

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

Merged
merged 1 commit into from
Nov 6, 2018
Merged

io: use posix_fadvise() instead of readahead() #404

merged 1 commit into from
Nov 6, 2018

Conversation

adierking
Copy link
Contributor

readahead() is a Linux-specific system call, and many C libraries (e.g.
Android's Bionic) do not declare it by default. A more-portable alternative is
to use posix_fadvise() with POSIX_FADV_WILLNEED. This is functionally
equivalent to readahead() on Linux.

Additionally, on FreeBSD, Dispatch is currently using fcntl() with F_RDAHEAD.
This is not exactly equivalent to Darwin's F_RDADVISE. Using posix_fadvise()
should work better here too.

@adierking
Copy link
Contributor Author

cc @MadCoder @compnerd

@compnerd
Copy link
Member

@swift-ci please test

readahead() is a Linux-specific system call, and many C libraries (e.g.
Android's Bionic) do not declare it by default. A more-portable alternative is
to use posix_fadvise() with `POSIX_FADV_WILLNEED`. This is functionally
equivalent to readahead() on Linux.

Additionally, on FreeBSD, Dispatch is currently using fcntl() with `F_RDAHEAD`.
This is not exactly equivalent to Darwin's `F_RDADVISE`. Using posix_fadvise()
should work better here too.
@compnerd
Copy link
Member

I think that this is the right approach to make this more portable. Any opinions @MadCoder or @parkera?

@ktopley-apple
Copy link
Contributor

@swift-ci please test

1 similar comment
@compnerd
Copy link
Member

@swift-ci please test

@compnerd
Copy link
Member

@MadCoder - okay to merge?

@compnerd
Copy link
Member

compnerd commented Nov 5, 2018

@ktopley-apple - okay to merge this as well?

@ktopley-apple ktopley-apple merged commit 3e4ea66 into swiftlang:master Nov 6, 2018
@adierking adierking deleted the readahead branch December 2, 2018 00:33
rokhinip pushed a commit that referenced this pull request Nov 5, 2021
io: use posix_fadvise() instead of readahead()
Signed-off-by: Kim Topley <ktopley@apple.com>
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

Successfully merging this pull request may close these issues.

4 participants