Skip to content

Remove the print_debug and build-metadata cargo features - #1980

Open
ludfjig wants to merge 3 commits into
hyperlight-dev:mainfrom
ludfjig:remove-print-debug-build-metadata
Open

ludfjig wants to merge 3 commits into
hyperlight-dev:mainfrom
ludfjig:remove-print-debug-build-metadata

Conversation

@ludfjig

@ludfjig ludfjig commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

This PR removes two host cargo features and tidies up feature lists.

  • Remove the print_debug feature and the exported debug! macro. The macro called tracing::debug! and also printed to stdout in debug builds. Its cfg was evaluated in the caller's crate, so the print never worked for external users.
  • Remove the build-metadata feature and its built and git2 build dependencies. The feature logged build details on the first sandbox creation. Its git fields were empty for crates.io users.
  • Clean up feature lists:
    • The std feature of hyperlight-common no longer pulls in tracing.
    • Guest crates only list features of their direct dependencies. The resolved features are unchanged.
    • Remove the empty hyperlight-libc features table and stale feature names in hack/clippy-package-features.sh.

Dropping git2, which builds libgit2 from C, speeds up a clean debug build of hyperlight-host with default features on 8 cores:

Before After Change
Wall time 65.6 s 42.5 s −35%
CPU time 319 s 209 s −34%
Crates compiled 131 120 −11
Target directory 847 MB 788 MB −7%

Breaking: Crates that enable print_debug or build-metadata must remove them. Replace hyperlight_host::debug! with tracing::debug!.

Closes #1979

print_debug made the exported debug! macro also print to stdout in
debug builds. tracing::debug! already emits the same message. The
macro's cfg is evaluated in the caller's crate, so it never printed
for external users.

Signed-off-by: Ludvig Liljenberg <[email protected]>
build-metadata used built with git2 to log build details on the
first sandbox creation. Its git fields were empty for crates.io users.

Dropping git2, which builds libgit2 from C, speeds up a clean debug
build of hyperlight-host with default features on 8 cores. Wall time
drops 35%, from 65.6 s to 42.5 s. CPU time drops 34%, from 319 s to
209 s. The build compiles 11 fewer crates, and the target directory
shrinks 7%, from 847 MB to 788 MB.

Signed-off-by: Ludvig Liljenberg <[email protected]>
* Enabling std on hyperlight-common no longer pulls in tracing.
* Feature lists name only the crates each package uses directly.
* Drop the empty hyperlight-libc features table and stale feature
  names from the clippy script.

Signed-off-by: Ludvig Liljenberg <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 18:00
@ludfjig
ludfjig requested a review from danbugs as a code owner October 23, 2026 18:00
@ludfjig ludfjig added the kind/refactor For PRs that restructure or remove code without adding new functionality. label Oct 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

Static review found no blocking issues, and the removals are consistent across callers, feature forwarding, build recipes, and documentation.

No open issues 🎉

What changed in this PR

This PR reduces Hyperlight host build overhead by removing two Cargo features and their logging machinery. It also simplifies feature forwarding and documents the breaking changes.

Changes:

  • Remove print_debug, hyperlight_host::debug!, and build-metadata logging with its build dependencies.
  • Simplify guest feature lists and keep common-crate tracing optional.
  • Update build recipes, coverage documentation, and the changelog.
File Description
src/​tests/​rust_guests/​witguest/​Cargo.toml Simplifies guest feature forwarding.
src/​tests/​rust_guests/​simpleguest/​Cargo.toml Simplifies guest feature forwarding.
src/​tests/​rust_guests/​dummyguest/​Cargo.toml Simplifies memory-profile forwarding.
src/​hyperlight_libc/​Cargo.toml Removes the empty features table.
src/​hyperlight_host/​src/​sandbox/​uninitialized.rs Removes build logging, uses tracing directly, and ungates tracing tests.
src/​hyperlight_host/​src/​sandbox/​trace/​context.rs Uses tracing::debug! directly.
src/​hyperlight_host/​src/​lib.rs Removes the debug macro and build-metadata machinery.
src/​hyperlight_host/​Cargo.toml Removes both features and the built dependency.
src/​hyperlight_host/​build.rs Removes metadata generation and the debug-print configuration alias.
src/​hyperlight_guest_bin/​Cargo.toml Simplifies tracing feature forwarding.
src/​hyperlight_common/​Cargo.toml Keeps tracing optional when enabling std.
Justfile Removes obsolete features from checks and test commands.
hack/​clippy-package-features.sh Removes stale feature exclusions.
docs/​how-to-run-coverage.md Aligns documented feature combinations with coverage commands.
CHANGELOG.md Documents feature removals and migration guidance.
Cargo.lock Removes unused build-metadata dependencies.

Review effort: Balanced

@ludfjig

ludfjig commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@simongdavies I know you have said in the past that build-metadata can be useful, but I don't agree. Applications can check their cargo.lock to see what version they use, and if they really want to include it in their tracing at runtime, they can do that too for any dependency they care about. I don't think hyperlight needs special feature for this

@hyperlight-gh-bot

Copy link
Copy Markdown

Benchmark Results

Measured commit: 7a74694c5e9d
Baseline commit: 8a7e6b8794fe

kvm / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 744.61 ns (➖ 1.03x faster)
vec_bytes 592.03 ns (➖ 1.02x slower)
372.30 µs (➖ 1.01x faster)

payload_allocation

slot_pool_segmented
262144 524.75 ns (➖ 1.23x faster)
65536 145.21 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 81.36 ms (➖ 1.01x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
7.76 ns (➖ 1.01x slower) 7.69 ns (➖ 1.00x faster) 7.72 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 93.13 µs (➖ 1.00x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.16 µs (➖ 1.00x faster) 7.06 µs (➖ 1.02x faster)
65536 2.05 µs (➖ 1.07x slower) 1.92 µs (➖ 1.10x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 6.31 µs (➖ 1.06x faster) 6.26 µs (➖ 1.03x faster)
8192 1.00 µs (➖ 1.01x faster) 1.03 µs (➖ 1.04x faster)
262144 28.32 µs (➖ 1.05x slower)
kvm / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 748.29 ns (➖ 1.06x faster)
vec_bytes 572.53 ns (➖ 1.02x faster)
730.89 µs (➖ 1.04x faster)

payload_allocation

slot_pool_segmented
262144 594.24 ns (➖ 1.01x faster)
65536 205.56 ns (➖ 1.01x faster)

sandboxes

create_initialized_and_drop
medium 86.12 ms (➖ 1.01x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
8.06 ns (➖ 1.01x faster) 7.94 ns (➖ 1.03x faster) 8.05 ns (➖ 1.02x faster)

snapshot_files

load_snapshot_unverified
small 48.49 µs (➖ 1.10x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 8.90 µs (➖ 1.02x faster) 8.90 µs (➖ 1.01x faster)
65536 2.55 µs (➖ 1.02x faster) 2.54 µs (➖ 1.02x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.31 µs (➖ 1.03x faster) 8.34 µs (➖ 1.02x faster)
8192 849.27 ns (➖ 1.03x faster) 840.54 ns (➖ 1.01x faster)
262144 33.95 µs (➖ 1.03x faster)
mshv3 / amd (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 915.15 ns (➖ 1.00x slower)
vec_bytes 704.53 ns (➖ 1.01x slower)
322.50 µs (➖ 1.01x slower)

payload_allocation

slot_pool_segmented
262144 673.84 ns (➖ 1.03x faster)
65536 185.30 ns (➖ 1.02x slower)

sandboxes

create_initialized_and_drop
medium 60.68 ms (➖ 1.06x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
9.89 ns (➖ 1.00x faster) 9.88 ns (➖ 1.17x faster) 9.91 ns (➖ 1.00x slower)

snapshot_files

load_snapshot_unverified
small 86.69 µs (➖ 1.01x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 9.25 µs (➖ 1.01x slower) 9.57 µs (➖ 1.04x slower)
65536 2.61 µs (➖ 1.03x faster) 2.47 µs (➖ 1.00x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.12 µs (➖ 1.01x faster) 8.10 µs (➖ 1.05x faster)
8192 1.27 µs (➖ 1.02x faster) 1.25 µs (➖ 1.03x faster)
262144 34.73 µs (➖ 1.06x faster)
mshv3 / intel (Linux) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 935.14 ns (➖ 1.01x slower)
vec_bytes 670.71 ns (➖ 1.00x slower)
1.02 ms (➖ 1.13x faster)

payload_allocation

slot_pool_segmented
262144 725.73 ns (➖ 1.15x slower)
65536 192.12 ns (➖ 1.30x faster)

sandboxes

create_initialized_and_drop
medium 76.48 ms (➖ 1.05x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
9.06 ns (➖ 1.00x faster) 9.10 ns (➖ 1.06x faster) 8.97 ns (➖ 1.02x faster)

snapshot_files

load_snapshot_unverified
small 49.55 µs (➖ 1.12x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.99 µs (➖ 1.01x faster) 7.96 µs (➖ 1.01x faster)
65536 2.30 µs (➖ 1.00x slower) 2.30 µs (➖ 1.01x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 7.48 µs (➖ 1.01x faster) 7.45 µs (➖ 1.01x faster)
8192 905.68 ns (➖ 1.02x faster) 918.98 ns (➖ 1.00x slower)
262144 40.08 µs (➖ 1.03x slower)
hyperv-ws2025 / amd (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 1.13 µs (➖ 1.01x faster)
vec_bytes 824.66 ns (➖ 1.09x slower)
1.95 ms (➖ 1.02x slower)

payload_allocation

slot_pool_segmented
262144 815.30 ns (➖ 1.04x faster)
65536 233.65 ns (➖ 1.06x faster)

sandboxes

create_initialized_and_drop
medium 82.90 ms (➖ 1.03x faster)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
10.78 ns (➖ 1.01x faster) 10.64 ns (➖ 1.14x faster) 10.61 ns (➖ 1.25x faster)

snapshot_files

load_snapshot_unverified
small 700.88 µs (➖ 1.20x slower)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 9.42 µs (➖ 1.09x slower) 8.58 µs (➖ 1.00x slower)
65536 2.76 µs (➖ 1.09x slower) 2.48 µs (➖ 1.02x faster)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.79 µs (➖ 1.02x slower) 9.17 µs (➖ 1.03x slower)
8192 1.53 µs (➖ 1.02x faster) 1.38 µs (➖ 1.00x slower)
262144 38.03 µs (➖ 1.01x faster)
hyperv-ws2025 / intel (Windows) (➖ stable)

No benchmark improved or regressed.

Benchmark Results

function_call_codec

encode_control decode_vec_bytes_copy
byte_chunks 1.18 µs (➖ 1.00x slower)
vec_bytes 758.23 ns (➖ 1.01x faster)
3.25 ms (➖ 1.01x slower)

payload_allocation

slot_pool_segmented
262144 740.00 ns (➖ 1.01x faster)
65536 212.69 ns (➖ 1.01x slower)

sandboxes

create_initialized_and_drop
medium 119.65 ms (➖ 1.04x slower)

slot_pool

alloc_dealloc_1500 alloc_dealloc_4096 alloc_dealloc_128
10.67 ns (➖ 1.11x slower) 10.32 ns (➖ 1.03x slower) 9.70 ns (➖ 1.00x faster)

snapshot_files

load_snapshot_unverified
small 574.66 µs (➖ 1.18x faster)

virtq_readonly

slot_pool_segmented_fragmented slot_pool_segmented
262144 7.53 µs (➖ 1.01x faster) 7.48 µs (➖ 1.01x slower)
65536 2.32 µs (➖ 1.04x slower) 2.49 µs (➖ 1.03x slower)

virtq_readwrite

slot_pool_segmented_fragmented slot_pool_segmented
65536 8.29 µs (➖ 1.01x slower) 8.40 µs (➖ 1.02x faster)
8192 1.39 µs (➖ 1.03x faster) 1.09 µs (➖ 1.05x slower)
262144 42.89 µs (➖ 1.03x slower)

Reported by cargo ci bench-report --candidate run:39999720120 --config-file bench_report.toml.

This branch has not been deployed

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

Labels

kind/refactor For PRs that restructure or remove code without adding new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the print_debug and build-metadata host cargo features

2 participants