Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress the lima-guestagent in the installation directory #2426

Closed
afbjorklund opened this issue Jun 18, 2024 · 9 comments · Fixed by #2438
Closed

Compress the lima-guestagent in the installation directory #2426

afbjorklund opened this issue Jun 18, 2024 · 9 comments · Fixed by #2438

Comments

@afbjorklund
Copy link
Contributor

afbjorklund commented Jun 18, 2024

Description

There are a lot of architectures, and not all of them are used...

We could compress them in the install, and decompress on host.

The on-disk lima installation goes from 175M to 68M, with gzip.

Note: lima-guestagent is still uncompressed, in the cidata.iso

@afbjorklund
Copy link
Contributor Author

Could make some different comparisons (size and time), using different compression formats and levels.

@jandubois
Copy link
Member

Is this really worth the effort? Given that most Linux images are in the 300MB range?

I could see adding additional Makefile targets to only build the "native" guestagent that matches the host arch by default (if we don't already have that), but the additional compression/decompression seems like a micro-optimization by now (I might have felt differently about this even just 5 years ago).

@afbjorklund

This comment was marked as outdated.

@afbjorklund
Copy link
Contributor Author

The installation was indeed smaller, but it is probably not worth the complication.

38M	_output/share/lima/lima-guestagent.Linux-aarch64
37M	_output/share/lima/lima-guestagent.Linux-armv7l
38M	_output/share/lima/lima-guestagent.Linux-riscv64
39M	_output/share/lima/lima-guestagent.Linux-x86_64

11M	_output/share/lima/lima-guestagent.Linux-aarch64.gz
11M	_output/share/lima/lima-guestagent.Linux-armv7l.gz
11M	_output/share/lima/lima-guestagent.Linux-riscv64.gz
12M	_output/share/lima/lima-guestagent.Linux-x86_64.gz

7,6M	_output/share/lima/lima-guestagent.Linux-aarch64.zst
7,6M	_output/share/lima/lima-guestagent.Linux-armv7l.zst
8,2M	_output/share/lima/lima-guestagent.Linux-riscv64.zst
8,6M	_output/share/lima/lima-guestagent.Linux-x86_64.zst

If anything, could make it a boolean and stick with gzip only (smaller code addition)?

-const Ext = ""
+const Ext = ".gz"
 
 func Open(path string) (io.ReadCloser, error) {
-	return os.Open(path)
+	reader, err := os.Open(path + Ext)
+	if err != nil {
+		return nil, err
+	}
+	return gzip.NewReader(reader)
 }

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Jun 23, 2024

I could see adding additional Makefile targets to only build the "native" guestagent that matches the host arch by default (if we don't already have that)

The "minimal" target does just this.

        _output/share/lima/lima-guestagent.Linux-$(shell uname -m | sed -e s/arm64/aarch64/)

@jandubois
Copy link
Member

The "minimal" target does just this.

What I have wanted in the past is something like make minimal templates install, so I still get all the templates, but only the native guestagent. Because minimal only installs the default template.

Obviously this is simple enough to add if/when I really need it.

@afbjorklund

This comment was marked as off-topic.

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Jun 25, 2024

Added a defconfig target to generate the arch config: #2446

make defconfig all install

Not sure if it is best with a script, or just two defconfig files ?

CONFIG_GUESTAGENT_OS_LINUX=y
CONFIG_GUESTAGENT_OS_FREEBSD=n
CONFIG_GUESTAGENT_ARCH_X8664=y
CONFIG_GUESTAGENT_ARCH_AARCH64=y
CONFIG_GUESTAGENT_ARCH_ARMV7L=y
CONFIG_GUESTAGENT_ARCH_RISCV64=y

@afbjorklund
Copy link
Contributor Author

"all" + gzip: (4 targets)

69M _output/

"minimal": (1 target)

64M _output/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants