Skip to content

Conversation

@Sytten
Copy link
Contributor

@Sytten Sytten commented Aug 21, 2025

Motivation

This was to remove the lockfile problem described in #7546

Solution

Moving away from cfg and into a feature that is only available when unstable is enabled.
It is a PITA for the CI I will admit, but this solution could also be applied to backtrace

@ADD-SP ADD-SP added A-tokio Area: The main tokio crate A-ci Area: The continuous integration setup labels Aug 22, 2025
@mox692
Copy link
Member

mox692 commented Aug 25, 2025

Regarding the error that io-uring crate is emitting, io-uring crate does not provide default bindings on architectures other than those explicitly listed here. The cross-tests that are currently failing in CI include 32-bit architectures that io-uring crate does not support, so some adjustments seem necessary.

I see two possible options:

  1. Exclude the io-uring feature in cross-tests where the crate is not supported.
    • This is essentially the same approach as the current master branch. In cross-tests, the tokio_uring cfg is not used. To achieve the same effect with features, instead of --all-features, we would use --features "full,test-util" (excluding io-uring). The downside is that we cannot make the build fail with compile_error! on unsupported architectures.
  2. Explicitly add supported architectures to the cfg.
    • Currently we do not, but it is possible to make io-uring available only under an explicit set of targets (perhaps this would be something like not(any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64", target_arch = "powerpc64"))). This approach is more explicit and makes unsupported builds fail properly, but it has the cost of adding more complex cfg conditions in the codebase.

I'm somewhat inclined to option 1 because:

  • Almost all major 64-bit architectures are supported, so practical issues should be minimal.
  • Option 2 might become outdated once io-uring expands its arch support in the future
  • Users can still use io_uring_use_own_sys as a workaround even if they're trying to use io-uring for unsupported arch.

@Darksonn @ADD-SP
Do you have any thoughts on this?

@ADD-SP
Copy link
Member

ADD-SP commented Aug 25, 2025

@mox692 I prefer the option 1, especially because "Almost all major 64-bit architectures are supported".

The downside is that we cannot make the build fail with compile_error! on unsupported architectures.

I don't fully understand, let's say I'm trying to locally compile tokio with io-uring enabled on 32-bit architectures, shouldn't the io-uring crate emit the compilation error? Or did I mis-understand this sentence?

@mox692
Copy link
Member

mox692 commented Aug 25, 2025

I don't fully understand let's say I'm trying to locally compile tokio with io-uring enabled on 32-bit architectures, shouldn't the io-uring crate emit the compilation error? Or did I mis-understand this sentence?

Ah you're right, I think io-uring will emit an error anyway.

@Darksonn
Copy link
Contributor

Yes, let's exclude it in cross-tests for now.

@Sytten
Copy link
Contributor Author

Sytten commented Aug 27, 2025

Trying another run, I expect we will still have some issues but should be better.

@Sytten
Copy link
Contributor Author

Sytten commented Aug 27, 2025

I think we are good! @ADD-SP @Darksonn

Copy link
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

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

I'd like to express concern about the increasing complexity, this PR introduces a new feature flag under the --cfg tokio_unstable?

The discussion is about whether to test both with io-uring and without io-uring. If we do, shall we also test all possible combinations for the three (tracing, taskdump and io-uring) unstable feature flags? Or we just add combinations for io-uring?

See #7547 (comment) for more context.

Copy link
Member

@mox692 mox692 left a comment

Choose a reason for hiding this comment

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

A couple of nits.

@Sytten
Copy link
Contributor Author

Sytten commented Aug 27, 2025

There something weird with cross-check-tier3, it should fail for the io-uring feature since I dont think it is supported on those targets but it doesnt?

@mox692
Copy link
Member

mox692 commented Aug 28, 2025

There something weird with cross-check-tier3, it should fail for the io-uring feature since I dont think it is supported on those targets but it doesnt?

That sounds wiered. I'll try to figure out what's happening.

@mox692
Copy link
Member

mox692 commented Aug 28, 2025

It looks like this is expected behavior. Tier 3 targets in ci are not linux, so io-uring crate isn't actually pulled in.

# This won't throw an error since this tier 3 target `armv7-sony-vita-newlibeabihf` isn't Linux, so the `io-uring` crate isn't even pulled in.
$ RUSTFLAGS="--cfg tokio_unstable" cargo build --features io-uring --target armv7-sony-vita-newlibeabihf

# This will throw an compile error from `io-uring` crate since it's linux but not supported arch, i686.
$ RUSTFLAGS="--cfg tokio_unstable" cargo build --features io-uring --target i686-unknown-linux-gnu

@Sytten
Copy link
Contributor Author

Sytten commented Aug 29, 2025

Make sense @mox692 . I reckon it is ready now. Let me know if there is any change necessary.

Copy link
Member

@mox692 mox692 left a comment

Choose a reason for hiding this comment

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

Looks good to me. I'll leave this a little while in case other members still have opinions for this.

Copy link
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

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

Overall looks good to me.

Comment on lines +290 to +293
- { os: windows-latest, features: "full,test-util" }
- { os: ubuntu-latest, features: "full,test-util" }
- { os: ubuntu-latest, features: "full,test-util,io-uring" }
- { os: macos-latest, features: "full,test-util" }
Copy link
Member

Choose a reason for hiding this comment

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

Can we also add a short comment to explain why did we use --features full,test-util instead of --all-features?

Comment on lines +123 to +124
cargo nextest run --features full,test-util
cargo test --doc --features full,test-util
Copy link
Member

Choose a reason for hiding this comment

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

Why did we need to add test-util here?

Comment on lines +665 to +666
cargo nextest run -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --features full,test-util
cargo test --doc -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --features full,test-util
Copy link
Member

Choose a reason for hiding this comment

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

Can we also add a short comment to explain why did we use --features full,test-util instead of --all-features?

# https://github.com/tokio-rs/tokio/issues/5373
- name: Check
run: cargo hack check -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --feature-powerset --depth 2 --keep-going
run: cargo hack check -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --feature-powerset --skip io-uring --depth 2 --keep-going
Copy link
Member

@ADD-SP ADD-SP Sep 1, 2025

Choose a reason for hiding this comment

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

Can we add a short comment about --skip io-uring?

inner: Kind::Std(options),
// TODO: Add support for converting `StdOpenOptions` to `UringOpenOptions`
// if user enables the `--cfg tokio_uring`. It is blocked by:
// if user enables `io-uring`. It is blocked by:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// if user enables `io-uring`. It is blocked by:
// if user enables `io-uring` cargo feature. It is blocked by:

nit

@mox692
Copy link
Member

mox692 commented Sep 14, 2025

@Sytten
Are you still working on this? I can push some commits to address the comments above, if you'd like.

This PR will be kind of important to define how users can opt in io_uring in the next release. We generally don't want to change the way to opt-in once we ship a new feature, even if it's unstable.

@Sytten
Copy link
Contributor Author

Sytten commented Sep 14, 2025

@mox692 feel free to do so. I was too busy this week. I might have time tonight, but it is a bit complicated right now

@mox692
Copy link
Member

mox692 commented Sep 15, 2025

It looks like I can’t edit this branch, so I opened another PR #7621.

@ADD-SP
Copy link
Member

ADD-SP commented Sep 19, 2025

Superseded by #7621 (derived from this PR), thanks for your contribution!

@ADD-SP ADD-SP closed this Sep 19, 2025
@Sytten Sytten deleted the ef-io-uring-feat branch September 19, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ci Area: The continuous integration setup A-tokio Area: The main tokio crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants