Skip to content

Rewrite bazel-diff in Rust - #449

Open
csmoe wants to merge 2 commits into
Tinder:masterfrom
csmoe:rust-1
Open

Rewrite bazel-diff in Rust#449
csmoe wants to merge 2 commits into
Tinder:masterfrom
csmoe:rust-1

Conversation

@csmoe

@csmoe csmoe commented Aug 10, 2026

Copy link
Copy Markdown

I'm not here to argue that Rust is the right language for this project, and I'd rather not relitigate that.

This started as a user problem: Our graph has ~140k targets, and from prior experience with bazel at that size, peak memory was our real worry. So I tried a native port to see if it helped(benchmark based on the bazel-build/bazel repo):

Implementation Mean wall time Range Median peak RSS
Kotlin 2.732 ± 0.128 s 2.467–2.921 s 889.15 MiB
Rust candidate 0.461 ± 0.023 s 0.429–0.508 s 140.66 MiB

The Rust candidate was 5.92x faster and used 84.2% less peak RSS.

CPU: Intel Xeon Platinum 8336C
OS: Linux 5.4 debian buster

AI NOTICE: I looked for a policy on LLM-assisted contributions and didn't find one in the repo. If this PR crosses a line you haven't had to write down yet, I apologize for putting it in front of you — please just close it, that's fine. I'd rather you not spend review time on something you didn't want.

Replace the Kotlin production binary and native E2E suite with a Rust implementation using buffa for Bazel protobufs. Update Bazel, Cargo, CI, release, documentation, and service tooling around the Rust binary.

@tinder-maxwellelliott tinder-maxwellelliott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a great start, thanks for doing this. I am going to merge in #450 first to make sure that this PR has the necessary test coverage.

Comment thread tools/BUILD
Comment on lines +58 to +72
# The benchmark shells out to Bazel, so only its pure parsing/statistics helpers run under
# `bazel test`. Invoke the real benchmark directly to avoid nesting Bazel under Bazel.
py_library(
name = "benchmark_lib",
srcs = ["benchmark.py"],
imports = ["."],
visibility = ["//visibility:private"],
)

py_test(
name = "benchmark_test",
srcs = ["benchmark_test.py"],
python_version = "PY3",
deps = [":benchmark_lib"],
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we just inject the Kotlin and rust versions via runfiles in these targets and run them directly? Seems odd to double bazel here

Comment thread Makefile
Comment on lines 23 to +25
format:
bazel run //cli/format
cargo fmt --all

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets add a format pipeline to auto fix the rust after we merge code

@tinder-maxwellelliott

Copy link
Copy Markdown
Collaborator

Updated this from latest main to get coverage enforcement working. Lets update the rust targets to have the necessary coverage enforcement logic and default to 90% throughout

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.

2 participants