Closed teohhanhui closed 1 month ago
A note that the tracing
feature bloats the resulting binaries quite a fair bit, from < 1 MiB to 3.8 MiB :crying_cat_face:
Let me know if you need me to change the default
feature to exclude tracing
. (Or turn off the attributes
feature on tracing
crate to avoid proc macros... Not sure this would help actually...)
cargo tree --duplicates -e normal
:
regex-automata v0.1.10
└── matchers v0.1.0
└── tracing-subscriber v0.3.18
├── krun v0.1.0 (/home/teohhanhui/Projects/slp/krun/crates/krun)
└── krun-guest v0.1.0 (/home/teohhanhui/Projects/slp/krun/crates/krun-guest)
regex-automata v0.4.6
└── regex v1.10.4
└── tracing-subscriber v0.3.18 (*)
regex-syntax v0.6.29
└── regex-automata v0.1.10 (*)
regex-syntax v0.8.3
├── regex v1.10.4 (*)
└── regex-automata v0.4.6 (*)
There's an open PR to deduplicate this in matchers
: https://github.com/hawkw/matchers/pull/5
It will only benefit us when tracing-subscriber
updates to matchers
0.2: https://github.com/tokio-rs/tracing/issues/2923
cargo depgraph --all-deps | dot -Tpng > graph.png
:
A note that the
tracing
feature bloats the resulting binaries quite a fair bit, from < 1 MiB to 3.8 MiB 😿Let me know if you need me to change the
default
feature to excludetracing
. (Or turn off theattributes
feature ontracing
crate to avoid proc macros... Not sure this would help actually...)
Hm... yes, that's quite significant. For components that are as relatively simple as krun
and krun-guest
, how much value are we getting from tracing
?
Switching to log
(with kv
feature) + env_logger
cuts down release binary sizes to 2.5 MiB and 2.4 MiB respectively, while preserving the same expressiveness. Also, libkrun uses log
too, so there's familiarity for contributors.
Working on cutting this down further...
Both binaries are down to 1.1 MiB respectively. This was primarily achieved by disabling the regex
feature in env_logger
: https://docs.rs/env_logger/latest/env_logger/#filtering-results
And we're also being explicit with all feature flags now, i.e. default-features = false
I've noticed a problem from my testing: passt
processes hanging around...
teohhanhui@Han-MacBook-Air:~$ ps aux | grep passt
teohhan+ 73572 0.0 0.0 72272 2560 ? S 05:23 0:01 /usr/bin/passt -q -f --fd 4
teohhan+ 73609 0.0 0.0 72288 3072 ? S 05:23 0:01 /usr/bin/passt -q -f --fd 4
teohhan+ 73763 0.0 0.0 72272 2560 ? S 05:24 0:01 /usr/bin/passt -q -f --fd 4
teohhan+ 168592 0.0 0.0 72288 1536 ? S 06:54 0:17 /usr/bin/passt -q -f --fd 4
teohhan+ 170108 0.0 0.0 72272 2048 ? S 07:03 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 171325 0.0 0.0 72272 2048 ? S 07:11 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 171861 0.0 0.0 72288 2048 ? S 07:14 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 174435 0.0 0.0 72272 2560 ? S 07:27 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 174531 0.0 0.0 72272 2560 ? S 07:27 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 174563 0.0 0.0 72272 2560 ? S 07:28 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 174639 0.0 0.0 72288 2048 ? S 07:28 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 174673 0.0 0.0 72272 2560 ? S 07:28 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 176527 0.0 0.0 72272 2560 ? S 07:36 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 178771 0.0 0.0 72272 2560 ? S 07:49 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 187569 0.0 0.0 72272 2560 ? S 08:30 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 199298 0.0 0.0 72272 2048 ? S 09:47 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 200732 0.0 0.0 72288 1536 ? S 09:57 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 202108 0.0 0.0 72272 2048 ? S 10:02 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 203001 0.0 0.0 72288 2048 ? S 10:09 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 204247 0.0 0.0 72272 1536 ? S 10:16 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 205135 0.0 0.0 72272 1536 ? S 10:19 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 209267 0.0 0.0 72288 2048 ? S 10:45 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 210018 0.0 0.0 72272 2048 ? S 10:49 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 210061 0.0 0.0 72272 2560 ? S 10:49 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 210117 0.0 0.0 72288 2048 ? S 10:50 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 210183 0.0 0.0 72272 2560 ? S 10:50 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 210235 0.0 0.0 72288 2560 ? S 10:51 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 210358 0.0 0.0 72288 2048 ? S 10:52 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 210393 0.0 0.0 72272 2048 ? S 10:52 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 210573 0.0 0.0 72272 2560 ? S 10:55 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 210662 0.0 0.0 72288 3072 ? S 10:55 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 211600 0.0 0.0 72288 2560 ? S 11:04 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 212464 0.0 0.0 72272 2560 ? S 11:10 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 212682 0.0 0.0 72272 2048 ? S 11:12 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 213080 0.0 0.0 72272 2048 ? S 11:14 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 213442 0.0 0.0 72272 1536 ? S 11:19 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 213565 0.0 0.0 72288 2048 ? S 11:20 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 213820 0.7 0.0 72288 1536 ? S 11:23 0:58 /usr/bin/passt -q -f --fd 4
teohhan+ 223715 1.1 0.0 72272 1536 ? S 12:13 1:00 /usr/bin/passt -q -f --fd 4
teohhan+ 227106 0.0 0.0 72272 3072 ? S 12:40 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 227653 0.0 0.0 72272 2560 ? S 12:47 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 228052 0.0 0.0 72288 1536 ? S 12:51 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 228434 0.0 0.0 72272 2048 ? S 12:53 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 228535 0.0 0.0 72272 2048 ? S 12:54 0:01 /usr/bin/passt -q -f --fd 4
teohhan+ 229990 0.0 0.0 72272 2048 ? S 13:12 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 230903 0.0 0.0 72272 3584 ? S 13:14 0:00 /usr/bin/passt -q -f --fd 4
teohhan+ 236073 0.0 0.0 222704 2048 pts/12 S+ 13:41 0:00 grep --color=auto passt
Thanks a lot for the work put on this PR. Merging it!
Oops! I will send a follow-up PR.
Replaces https://github.com/slp/krun.legacy/pull/4
As discussed in https://github.com/slp/krun.legacy/pull/1#issuecomment-2076839288
Bugs fixed:
krun
incorrectly passes own arguments tokrun-guest
, e.g./tmp/passt_1.socket
[x] When forking
krun-guest
to rundhclient
in child process, stdin/stdout/stderr were illegally closed.See https://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html#tag_16_67_07
[x]
File exists (os error 17)
when trying to create the temp directory forXDG_RUNTIME_DIR
after the first run. Use properly unique temp dir names for each run.Dependency tree with
cargo tree -e normal --no-dedupe
(excludingbuild-dependencies
):Requires: