Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"src/dlopen-note",
"src/fat",
"src/json",
"src/uapi16",
"src/varlink",
"tools",
"tests/crash",
Expand All @@ -23,6 +24,7 @@ default-members = [
"src/dlopen-note",
"src/fat",
"src/json",
"src/uapi16",
"src/varlink",
"tests/crash",
]
Expand All @@ -49,6 +51,7 @@ lexopt = "0.3.2"
libc = "0.2.191"
# 0.11.1 and later need rustc 1.88.
sha2 = { version = "0.11.0", default-features = false }
uapi16 = { path = "src/uapi16" }
varlink = { path = "src/varlink" }

[workspace.lints.rust]
Expand All @@ -71,6 +74,9 @@ lexopt.workspace = true
libc.workspace = true
varlink.workspace = true

[dev-dependencies]
uapi16.workspace = true

[lints]
workspace = true

Expand Down
23 changes: 15 additions & 8 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ With rustup, `cargo +1.85.0` selects rustc 1.85:

`cargo test` runs:

- the unit tests of the library and of the json, varlink, dlopen,
dlopen-note and blkid crates,
- the unit tests of the library and of the json, uapi16, varlink,
dlopen, dlopen-note and blkid crates,
- the integration tests in tests/,
- the crash consistency harness.

Expand Down Expand Up @@ -225,12 +225,19 @@ bench/compare.sh compares two ufat binaries, BASE and HEAD:
bench/compare.sh BASE HEAD
bench/compare.py "$BENCH_DIR/out"

It runs ten small workloads: assemble, populate, check and manifest with
trees of 10000 files and with an ESP, and two Varlink calls. Every
workload runs once under cachegrind, which counts the instructions, and
once under strace, which counts the system calls. Then it runs nine
times with each binary, alternating, for the wall time, the peak RSS and
the bytes read and written. It needs valgrind and strace.
It runs eleven small workloads: assemble, populate, check and manifest
with trees of 10000 files and with an ESP, a plan from the manifest of
such a tree, and two Varlink calls. Every workload runs once under
cachegrind, which counts the instructions, and once under strace, which
counts the system calls. Then it runs nine times with each binary,
alternating, for the wall time, the peak RSS and the bytes read and
written. It needs valgrind and strace.

HEAD writes the manifests of the workloads that read a manifest,
assemble/esp-stream, plan/wide-manifest and varlink/Assemble-esp-stream,
and BASE reads them too. So BASE has to read what HEAD writes. That
holds as long as both binaries have the same manifest reader. Against an
older BASE those workloads can fail.

bench/compare.py prints the results of HEAD and their change from BASE.
It fails when HEAD exceeds BASE on a workload by more than a limit:
Expand Down
232 changes: 199 additions & 33 deletions README.md

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions bench/compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ RAW=$OUT/compare.tsv
# valgrind. Inputs depend on FILES and UKI only, and are built once.
make_inputs() {
local stamp=$IN/.ready-$FILES-$UKI
[ -e "$stamp" ] && return
[ -e "$stamp" ] && [ -e "$IN/wide.manifest" ] && return
say "building inputs under $IN (FILES=$FILES UKI=$UKI)"
rm -rf "$IN"; mkdir -p "$IN"
# A subshell that stops at the first failure, so the stamp is only set
Expand Down Expand Up @@ -116,6 +116,8 @@ make_inputs() {
tr '\036' '\n' < "$IN/esp.manifest" | grep '"size":' | sed -E 's/.*"name":"([^"]*)".*/\1/' |
while IFS= read -r n; do cat "$e/$n"; done > "$IN/esp.blob"
[ -s "$IN/esp.blob" ] || { say "empty blob"; exit 1; }
# The manifest of the wide tree, for a plan that reads nothing else.
"$HEAD" manifest "$IN/wide" > "$IN/wide.manifest"
Comment thread
brauner marked this conversation as resolved.
Resolved
# An empty file system of 256 MiB, the target of populate, and one
# holding the wide tree, the input of check. Both are made once, by
# the head binary, so that both binaries see the same bytes.
Expand All @@ -140,9 +142,11 @@ fresh_image() { cp --sparse=always "$IN/empty.img" "$IMG/target.img"; }
no_image() { rm -f "$IMG/target.img"; }
empty_image() { rm -f "$IMG/target.img" && : > "$IMG/target.img"; }
nothing() { :; }
ASM=(assemble --create --sector-size 512 --identifier 1234abcd --label ESP)
# The file systems get a size: one both binaries make the same way whether
# or not they size to fit on their own.
ASM=(assemble --create --size 64M --sector-size 512 --identifier 1234abcd --label ESP)
POPULATE='{"image":{"fileDescriptor":0},"path":"/","content":{"sourceFileDescriptor":1}}'
ASSEMBLE='{"image":{"fileDescriptor":0},"content":{"manifest":{"fileDescriptor":1},"sourceFileDescriptor":2},"options":{"sectorSize":512,"identifier":"1234-ABCD","label":"ESP"}}'
ASSEMBLE='{"image":{"fileDescriptor":0,"size":67108864},"content":{"manifest":{"fileDescriptor":1},"sourceFileDescriptor":2},"options":{"sectorSize":512,"identifier":"1234-ABCD","label":"ESP"}}'
workloads() {
local r=$1
$r assemble/esp no_image -- @UFAT@ "${ASM[@]}" "$IMG/target.img" "$IN/esp"
Expand All @@ -153,6 +157,7 @@ workloads() {
$r check/wide nothing -- @UFAT@ check "$IN/wide.img"
$r manifest/esp nothing -- @UFAT@ manifest "$IN/esp"
$r manifest/wide nothing -- @UFAT@ manifest "$IN/wide"
$r plan/wide-manifest nothing -- @UFAT@ assemble --plan --sector-size 512 --manifest "$IN/wide.manifest"

@brauner brauner Nov 19, 2026 •

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.

Not for this series, but for later: what this series is for, a large manifest streamed through a pipe while the volume is written, isn't benchmarked. The only streamed assembly is assemble/esp-stream with a few dozen records, and this plan reads a regular file and writes nothing. An assemble/wide-manifest-stream workload (the wide tree's manifest and its contents through pipes like the ESP case) and a check that runs it at two sizes, say FILES=10000 and FILES=100000, and fails when the peak RSS grows with the number of records would cover it. At 10000 records memory that grows per record doesn't show.

$r varlink/Populate-wide fresh_image --ufat @UFAT@ --method org.uapi-group.FileSystem.Populate \
--fd "rw:$IMG/target.img" --fd "$IN/wide" --params "$POPULATE"
$r varlink/Assemble-esp-stream empty_image --ufat @UFAT@ --method org.uapi-group.FileSystem.Assemble \
Expand Down
12 changes: 7 additions & 5 deletions bench/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ small_file() { # small_file PATH SIZE SEED
}

make_inputs() {
local stamp=$IN/.ready-$WIDE
# The stamp names the order the manifests are written in: the inputs of
# a ufat from before manifests had to declare it are built again.
local stamp=$IN/.ready-$WIDE-codepoint
[ -e "$stamp" ] && return
say "building inputs under $IN (WIDE=$WIDE)"
rm -rf "$IN"; mkdir -p "$IN"
Expand Down Expand Up @@ -345,10 +347,10 @@ bench "sha256/esp/ufat-manifest" ":" -- "$UFAT" manifest "$IN/esp"
[ -n "$SHA256SUM" ] && bench "sha256/esp/sha256sum" ":" -- "$SHA256SUM" "${ESP_FILES[@]}"
for ss in 512 4096; do
W=$IMG/asm-$ss.img
# --create without --size sizes the image to fit the manifest.
bench "assemble/$ss/esp/dir-fit" "rm -f $W" -- "$UFAT" assemble --create --sector-size "$ss" --identifier 1234abcd --label ESP \
# --minimize sizes the image to fit the manifest, which it reads twice.
bench "assemble/$ss/esp/dir-fit" "rm -f $W" -- "$UFAT" assemble --create --minimize --sector-size "$ss" --identifier 1234abcd --label ESP \
--manifest "$IN/esp.manifest" "$W" "$IN/esp"
bench "assemble/$ss/esp/stream-fit" "rm -f $W" --stdin "$IN/esp.blob" -- "$UFAT" assemble --create --sector-size "$ss" --identifier 1234abcd --label ESP \
bench "assemble/$ss/esp/stream-fit" "rm -f $W" --stdin "$IN/esp.blob" -- "$UFAT" assemble --create --minimize --sector-size "$ss" --identifier 1234abcd --label ESP \
--manifest "$IN/esp.manifest" "$W" -
# Into a formatted 1 GiB image, like populate above: the difference to
# populate is the manifest handling and the SHA-256 verification.
Expand All @@ -375,7 +377,7 @@ for ss in 512 4096; do
--params '{"image":{"fileDescriptor":0},"path":"/","content":{"manifest":{"fileDescriptor":1},"sourceFileDescriptor":2},"timestampUSec":1700000000000000}'
bench "varlink/$ss/esp/Assemble-manifest-stream-fit" "rm -f $W; : > $W" --ufat "$UFAT" --method org.uapi-group.FileSystem.Assemble \
--fd "rw:$W" --fd "$IN/esp.manifest" --fd "$IN/esp.blob" \
--params "{\"image\":{\"fileDescriptor\":0},\"content\":{\"manifest\":{\"fileDescriptor\":1},\"sourceFileDescriptor\":2},\"options\":{\"sectorSize\":$ss,\"identifier\":\"1234-ABCD\",\"label\":\"ESP\",\"timestampUSec\":1700000000000000}}"
--params "{\"image\":{\"fileDescriptor\":0},\"content\":{\"manifest\":{\"fileDescriptor\":1},\"sourceFileDescriptor\":2},\"options\":{\"minimize\":true,\"sectorSize\":$ss,\"identifier\":\"1234-ABCD\",\"label\":\"ESP\",\"timestampUSec\":1700000000000000}}"
rm -f "$W"
for tree in esp wide-flat wide-flat83 wide-deep; do rm -f "$IMG/pop-$tree-$ss.img"; done
done
Expand Down
Loading
Loading