Skip to content

bazel: upgrade liburing to 2.14#29955

Merged
travisdowns merged 2 commits intoredpanda-data:devfrom
travisdowns:td-uring-upgrade
Apr 1, 2026
Merged

bazel: upgrade liburing to 2.14#29955
travisdowns merged 2 commits intoredpanda-data:devfrom
travisdowns:td-uring-upgrade

Conversation

@travisdowns
Copy link
Copy Markdown
Member

@travisdowns travisdowns commented Mar 25, 2026

Upgrade liburing from 2.5 to 2.14. Includes a patch to work around
out-of-source build issues (bazelbuild/bazel-central-registry#8079)
until we can pick up the upstream fix (axboe/liburing#1558).

We don't currently use liburing, so this is a no-op upgrade to stay
current.

I ran all unit tests with uring (see other commit) and had no new failures (one test failed even w/o io_uring, I think disk cache corruption).

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v26.1.x
  • v25.3.x
  • v25.2.x

Release Notes

  • none

Copilot AI review requested due to automatic review settings March 25, 2026 14:10
@travisdowns travisdowns marked this pull request as draft March 25, 2026 14:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades the Bazel BCR liburing dependency from 2.5 to 2.14 and applies a temporary patch to the upstream BCR build definition to avoid in-source build assumptions (to work around known out-of-source build issues).

Changes:

  • Bump liburing Bazel module version to 2.14 and apply a local patch via single_version_override.
  • Add a liburing BUILD patch to run configure without changing CWD (symlink-based out-of-source workaround) and to avoid relying on realpath.
  • Refresh MODULE.bazel.lock to reflect the new module versions/resolution.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
bazel/thirdparty/liburing.patch Adjusts upstream module’s BUILD.bazel to work around out-of-source build issues and propagate Bazel C/C++ flags into configure.
MODULE.bazel Upgrades liburing to 2.14 and applies the patch using single_version_override.
MODULE.bazel.lock Updates resolved module metadata/hashes for the new dependency graph.

@travisdowns travisdowns marked this pull request as ready for review March 25, 2026 15:29
Copy link
Copy Markdown
Member Author

@travisdowns travisdowns left a comment

Choose a reason for hiding this comment

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

Some notes for reviewers on the test.bzl changes.

Comment thread bazel/test.bzl
return select({
"//bazel:io_uring_enabled": ["--reactor-backend=io_uring"],
"//conditions:default": [],
})
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is extracted into its own function because it's used in two places: _redpanda_cc_test (unit tests) and redpanda_cc_bench (benchmark smoke tests). Both are Seastar-based and accept --reactor-backend.

Comment thread bazel/test.bzl

test_data, test_env = _test_options()
cc_test(
name = name,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This must go here (after line 155) and not earlier because select() returns a Starlark select type that is not iterable or mutable. The code above iterates args in _has_flags() (line 140-142), calls args.append() (lines 145-146), and checks if args truthiness (line 154) — all of which require a plain list. Once we concatenate the select(), the result can only be passed to a rule attribute.

Comment thread bazel/test.bzl
)

args = ["$(rootpath :{})".format(binary_name)] + args
args = ["$(rootpath :{})".format(binary_name)] + args + _reactor_args()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For benchmarks, the reactor arg is concatenated into args here so it flows through to both the py_binary (the actual benchmark runner, line 496) and the py_test smoke test (line 509, via test_args which is derived from args on line 505). The select() + list concatenation chains work fine in Starlark as long as the final value lands in a rule attribute.

@StephanDollberg
Copy link
Copy Markdown
Member

Why don't we enable it unconditionally? Isn't that what we do in cmake land? That's why we have the seastar patch to change order.

Copy link
Copy Markdown
Member Author

@travisdowns travisdowns left a comment

Choose a reason for hiding this comment

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

Reviewer notes for the liburing patch.

"src/include/liburing/io_uring_version.h",
],
cmd = """
- export CC=$(CC) CXX=$(CC)++
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We now pass CFLAGS="$(CC_FLAGS)" so that the configure step picks up the sysroot and target flags from the Bazel toolchain. Without this, configure's feature-detection probes compile against the host system headers instead of the hermetic toolchain, which can produce wrong results (e.g. detecting __kernel_timespec or open_how incorrectly).

+ # We do an out-of-source build of liburing here, so that
+ # CWD does not change and CC and other relative paths work
+ # (e.g. those embedded in sysroot). Currently, liburing
+ # doesn't support out of source builds, so we fake it
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the core of the patch. The upstream BCR BUILD.bazel does pushd into the package directory to run configure, which changes CWD away from the execroot. That breaks CC because Bazel's CC wrapper path is relative to the execroot, not the package dir.

Instead we do an out-of-source build: stay in the execroot (so CC works) and symlink the two files that configure expects to find in CWD (Makefile.common and liburing.spec). This is a workaround until upstream liburing supports out-of-source builds properly (axboe/liburing#1558).

+ mkdir -p src/include/liburing
+ $$pkg_dir/configure --use-libc

# collect the outputs
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The upstream patch used realpath --relative-to=$(BINDIR) to copy generated headers from the package dir back to the output locations. That doesn't work with our out-of-source layout since the generated files are now in the execroot, not the package dir. ${out#$(RULEDIR)/} strips the output-dir prefix to get the relative path of each generated file, which is already correct relative to CWD.

done
""",
- toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"],
+ toolchains = [
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Adding @bazel_tools//tools/cpp:cc_flags makes $(CC_FLAGS) available in the genrule cmd. This is the standard Bazel mechanism for propagating toolchain flags (like --sysroot) into genrules.

@travisdowns
Copy link
Copy Markdown
Member Author

travisdowns commented Mar 25, 2026

Why don't we enable it unconditionally? Isn't that what we do in cmake land? That's why we have the seastar patch to change order.

Support is built-in to seastar by default (I think that's what you are asking). See the .bazelrc for comments, LMK if that is unclear.

@StephanDollberg
Copy link
Copy Markdown
Member

Support is built-in to seastar by default (I think that's what you are asking). See the .bazelrc for comments, LMK if that is unclear.

Oh yes I didn't read the comment to the end.

rockwotj
rockwotj previously approved these changes Mar 25, 2026
Upgrade from 2.5 to 2.14 with a patch to work around out-of-source
build issues (bazelbuild/bazel-central-registry#8079) which itself is
hard to fix until BCR picks up axboe/liburing#1558.
Add a bool_flag //bazel:io_uring (default false) that passes
--reactor-backend=io_uring to all unit tests and benchmarks when
enabled. Usage: bazel test //... --config=io_uring
@travisdowns
Copy link
Copy Markdown
Member Author

travisdowns commented Mar 25, 2026

70738a2 is rebase to fix build conflict

@vbotbuildovich
Copy link
Copy Markdown
Collaborator

CI test results

test results on build#82342
test_class test_method test_arguments test_kind job_url test_status passed reason test_history
PartitionMovementTest test_cross_core_movements {"cloud_storage_type": 1} integration https://buildkite.com/redpanda/redpanda/builds/82342#019d2646-8eb0-47e4-9f1e-b661f2234176 FLAKY 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0000, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3487, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=PartitionMovementTest&test_method=test_cross_core_movements

@travisdowns travisdowns merged commit 609937b into redpanda-data:dev Apr 1, 2026
18 checks passed
@WillemKauf
Copy link
Copy Markdown
Contributor

ERROR: /home/willem/.cache/bazel/_bazel_willem/6fc2d9663f4e6fbf4046ab3d95678674/external/liburing+/BUILD.bazel:48:11: Compiling src/queue.c failed: (Exit 1): cc_wrapper.sh failed: error executing CppCompile command (from target @@liburing+//:uring) external/toolchains_llvm++llvm+current_llvm_toolchain/bin/cc_wrapper.sh -U_FORTIFY_SOURCE '--target=x86_64-unknown-linux-gnu' '-march=westmere' -U_FORTIFY_SOURCE -fstack-protector ... (remaining 38 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/liburing+/src/queue.c:5:
In file included from external/liburing+/src/syscall.h:13:
In file included from external/liburing+/src/include/liburing.h:17:
bazel-out/k8-fastbuild/bin/external/liburing+/src/include/liburing/compat.h:55:3: error: redefinition of enumerator 'P_ALL'
   55 |   P_ALL,                /* Wait for any child.  */
      |   ^
external/+non_module_dependencies+x86_64_sysroot/usr/include/x86_64-linux-gnu/sys/wait.h:76:3: note: previous definition is here
   76 |   P_ALL,                /* Wait for any child.  */
      |   ^

https://redpandadata.slack.com/archives/C07HD9U0EHL/p1775011039916519

@WillemKauf
Copy link
Copy Markdown
Contributor

#30029

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants