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

[core] Compatibile function for file descriptor #50170

Merged
merged 7 commits into from
Feb 4, 2025

Conversation

dentiny
Copy link
Contributor

@dentiny dentiny commented Feb 1, 2025

This PR writes multiple compatible functions for file descriptors, which have been used elsewhere.

@dentiny dentiny added the go add ONLY when ready to merge, run all tests label Feb 1, 2025
@dentiny dentiny requested a review from jjyao February 1, 2025 05:07
@dentiny dentiny force-pushed the hjiang/compat-for-fd branch 3 times, most recently from f1e4cf0 to 50fc805 Compare February 1, 2025 08:24
Signed-off-by: dentiny <dentinyhao@gmail.com>
@dentiny dentiny force-pushed the hjiang/compat-for-fd branch from 50fc805 to 7f26146 Compare February 1, 2025 08:29
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
}
return Status::OK();
}
void Flush(MEMFD_TYPE_NON_UNIQUE fd) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Return Status like others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No fsyncgate is not recoverable and should exit abnormally directly

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think as a util, caller should decide whether it wants to exit abnormally or do something else. Otherwise why fsyncgate doesn't exit abnormally inside itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Otherwise why fsyncgate doesn't exit abnormally inside itself

What do you mean? It's a behavior, not a function call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you saying why fsync doesn't exit itself? It's because fsync behavior differs varies among filesystems, for example, ext-4 is known to clear dirty bit after a failed sync behavior, not sure about other fs.

Interface-wise, POSIX doesn't care about fs type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we really need to handle it via mimic the postgres and tigerbeetles' behavior, we will differentiate (1) windows vs unix; (2) error codes, I would like to keep the code simple, so just panic here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think they assumed fd is always valid. But we are writing a utility, I don't think we should assume that.

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 also declare the util function is used inside of ray (the filesystem function is not exposed externally);
anyway I updated the return value, PTAL

@dentiny dentiny requested a review from jjyao February 2, 2025 06:42
@dentiny
Copy link
Contributor Author

dentiny commented Feb 2, 2025

The failed unit test has nothing to do with my change, since it's not used in production even.

Signed-off-by: dentiny <dentinyhao@gmail.com>
Comment on lines 59 to 72
const std::string test_file_path = absl::StrFormat("%s.out", GenerateUUIDV4());

HANDLE handle = CreateFile(test_file_path.data(), // File path
GENERIC_WRITE, // Open for writing
0, // No sharing
NULL, // Default security
CREATE_ALWAYS, // Create new file (overwrite if exists)
FILE_ATTRIBUTE_NORMAL, // Normal file attributes
NULL // No template
);
ASSERT_NE(handle, INVALID_HANDLE_VALUE);
absl::Cleanup cleanup_test_file = [&test_file_path]() {
EXPECT_TRUE(std::filesystem::remove(test_file_path));
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can use the same ScopedTemporaryDirectory?

Actually with this PR, we don't need #if defined(__APPLE__) || defined(__linux__) for the test right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried for a few times and didn't get it worked, so fall back to the old way

Copy link
Contributor Author

@dentiny dentiny Feb 3, 2025

Choose a reason for hiding this comment

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

I think ifdef is needed anyway to get a fd / handle cross-platform

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I updated to stdout, which we already have a util function

@dentiny dentiny requested a review from jjyao February 3, 2025 18:46
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
@jjyao
Copy link
Collaborator

jjyao commented Feb 3, 2025

I merged #50173, could you update this PR to use the functions defined here and resolve the TODOs in that PR.

@dentiny
Copy link
Contributor Author

dentiny commented Feb 3, 2025

could you update this PR to use the functions defined here and resolve the TODOs in that PR.

I will have a followup PR to cleanup all cross-platform syscalls after all related PRs merged.

@jjyao jjyao merged commit 1bd76fc into ray-project:master Feb 4, 2025
4 of 5 checks passed
aslonnie added a commit that referenced this pull request Feb 4, 2025
dentiny added a commit to dentiny/ray that referenced this pull request Feb 4, 2025
Signed-off-by: dentiny <dentinyhao@gmail.com>
xsuler pushed a commit to antgroup/ant-ray that referenced this pull request Mar 4, 2025
Signed-off-by: dentiny <dentinyhao@gmail.com>
xsuler pushed a commit to antgroup/ant-ray that referenced this pull request Mar 4, 2025
xsuler pushed a commit to antgroup/ant-ray that referenced this pull request Mar 4, 2025
Signed-off-by: dentiny <dentinyhao@gmail.com>
xsuler pushed a commit to antgroup/ant-ray that referenced this pull request Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants