Skip to content

Commit 91791b1

Browse files
committed
run_qemu.sh: move mkosi WorkspaceDirectory to /tmp(fs)
I've been selfishly enjoying this major optimization for a while; time to share it. Very small hence very easy to comment out or even revert if needed. mkosi-workspace is located on /var/tmp/ by default, which is usually persistent and slow storage which wears out. On success, mkosi-workspace is deleted at the end of the build so it really does not need to be located on persistent storage. So, move it to /tmp which is usually tmpfs. On one of my systems, moving to tmpfs lowers the build time from 4 min to 1 min! If you ever wondered how I could git bisect mkosi faster than reading its release notes: that's how. Signed-off-by: Marc Herbert <[email protected]>
1 parent 0ba61b4 commit 91791b1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

mkosi_tmpl_portable/optional.tmpl

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# mkosi-workspace is located on /var/tmp/ by default (why?), which is usually
2+
# persistent and slow storage which wears out. On success, mkosi-workspace is
3+
# deleted at the end of the build so it really does not need to be located on
4+
# persistent storage. So, move it to /tmp which is usually tmpfs. Moving to
5+
# tmpfs makes mkosi SEVERAL TIMES faster!
6+
#
7+
# If needed, a new @MkosiWorkspaceDirectory@ variable and option would
8+
# mitigate both issues below.
9+
#
10+
# Warning 1: mkosi-workspace needs emough space to hold the system image: a few
11+
# gigabytes. If you run out of /tmp space, either make it bigger (mount -o
12+
# remount,size=newsize after buying a decent amount of RAM), or comment this
13+
# out.
14+
#
15+
# Warning 2: mkosi version v15 and v16 cannot use /tmp/ for this. (cpio
16+
# error). Point at another tmpfs with a different name, cherry-pick
17+
# mkosi fix 28ccb67a92e, or comment this out.
18+
#
19+
# Pro-tip: symlink kernel/qbuild/ to /tmp too. A few more gigabytes required.
20+
# (some old mkosi versions nest their WorkspaceDir inside qbuild/ by default)
21+
22+
[Output]
23+
# WorkspaceDirectory= (and others) were moved to the brand new [Build]
24+
# section in mkosi v25 commit ef5a79993e2. Fortunately, no version
25+
# before or after that mkosi commit seems to mind the duplicate (mkosi
26+
# versions < v15 don't seem to care about sections at all). So just
27+
# duplicate and forget about it.
28+
WorkspaceDirectory=/tmp/
29+
30+
[Build]
31+
WorkspaceDirectory=/tmp/

0 commit comments

Comments
 (0)