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

prefetch may select the wrong memory segment for multi-segment slices #14109

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

ChrisHegarty
Copy link
Contributor

This commit fixes a bug where by prefetch may select the wrong memory segment for multi-segment slices.

The issue was discovered when debugging a large test scenario, where the index input was backed by several memory segments. When sliced, a multi-segment index input uses an offset into the initial memory segment. This offset should be added to the prefetch offset to determine the absolute offset. The unfortunate part is that the bounds checks need to either be moved to the subclasses, or somehow coerced to look at segment byteSizes rather than length. I found the former to be more straightforward.

Copy link
Contributor

@uschindler uschindler left a comment

Choose a reason for hiding this comment

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

Looks fine. Thus is consistent to all other methods in subclasses.
Sorry for this code complexity, it's way too easy to add new methods but forget to look at code of methods. You're not the first one that broke this. But with normal read methods it's causing test failures, but prefetch just works.

Code is consistent so keep it like it is. The trap is there but when dealing with the IO layer you've to be careful.

@ChrisHegarty ChrisHegarty merged commit d4f0a32 into apache:main Jan 8, 2025
5 checks passed
@ChrisHegarty ChrisHegarty deleted the mseg_prefetch_bug branch January 8, 2025 09:30
ChrisHegarty added a commit that referenced this pull request Jan 8, 2025
…#14109)

This commit fixes a bug where by prefetch may select the wrong memory segment for multi-segment slices.

The issue was discovered when debugging a large test scenario, where the index input was backed by several memory segments. When sliced, a multi-segment index input uses an offset into the initial memory segment. This offset should be added to the prefetch offset to determine the absolute offset.
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.

3 participants