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

optimize disk cache io #21876

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

optimize disk cache io #21876

wants to merge 2 commits into from

Conversation

Kila2
Copy link

@Kila2 Kila2 commented Apr 3, 2024

Utilize NIO instead of InputStream. For MacOS, NIO copy can employ fcopyfile for non-blocking IO copy to optimize IO performance.

@Kila2 Kila2 requested a review from a team as a code owner April 3, 2024 03:24
@github-actions github-actions bot added team-Remote-Exec Issues and PRs for the Execution (Remote) team awaiting-review PR is awaiting review from an assigned reviewer labels Apr 3, 2024
@Kila2 Kila2 changed the title optimize disk cache io [WIP]optimize disk cache io Apr 3, 2024
@Kila2 Kila2 changed the title [WIP]optimize disk cache io optimize disk cache io Apr 3, 2024
@fmeum
Copy link
Collaborator

fmeum commented Apr 3, 2024

@tjgq Have there been any experiments at Google on replacing some of the custom filesystem functions with Java NIO? I recently used Files.move to replace the JavaIoFilesystem.renameTo implementation and wondered whether it would make sense to adopt it more generally.

Copy link
Contributor

@tjgq tjgq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sympathetic to the objective of this PR (the sendfile/fcopyfile optimization in NIO definitely sounds worthwhile), but I'd like to do some benchmarking of my own before we accept it. That will probably take a while, as I'm on vacation next week.

Comment on lines 337 to 342
// FIXME: Do we need it?
// try (FileOutputStream out = new FileOutputStream(outFile)) {
// // Fsync temp before we rename it to avoid data loss in the case of machine
// // crashes (the OS may reorder the writes and the rename).
// out.getFD().sync();
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need it unless you can convince me that the scenario described in the comment is not a concern (https://danluu.com/deconstruct-files/ is a good reference on what can go wrong when a system crashes in the middle of a filesystem operation).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the NIO source code. Only public static Path copy(Path source, Path target, CopyOption... options) throws IOException can optimize the IO operation, and there is no fsync method available.

@Kila2 Kila2 requested a review from a team as a code owner May 13, 2024 04:58
@Kila2 Kila2 requested review from aranguyen and removed request for a team May 13, 2024 04:58
@matthewjh
Copy link

Any update here? @Kila2 @fmeum @tjgq

@fmeum fmeum requested a review from tjgq August 23, 2024 08:01
@Kila2 Kila2 closed this Jan 17, 2025
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jan 17, 2025
@Kila2 Kila2 reopened this Jan 17, 2025
@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-Remote-Exec Issues and PRs for the Execution (Remote) team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants