diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-03-27 14:36:01 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-04-03 11:26:05 +0000 |
| commit | fed899ed4a625d124a881a2da67430be5d15325c (patch) | |
| tree | 9138f5c2f506b22efb1a84af5a1d21063f9b3dfd /vm | |
| parent | afbcc4a93d840f52b2579530d638654a4a1e5447 (diff) | |
pkg/rpctype: make RPC compression optional
RPC compression take up to 10% of CPU time in profiles,
but it's unlikely to be beneficial for local VM runs
(we are mostly copying memory in this case).
Enable RPC compression based on the VM type
(local VM don't use it, remove machines use it).
Diffstat (limited to 'vm')
| -rw-r--r-- | vm/adb/adb.go | 2 | ||||
| -rw-r--r-- | vm/bhyve/bhyve.go | 2 | ||||
| -rw-r--r-- | vm/cuttlefish/cuttlefish.go | 2 | ||||
| -rw-r--r-- | vm/gce/gce.go | 2 | ||||
| -rw-r--r-- | vm/gvisor/gvisor.go | 2 | ||||
| -rwxr-xr-x | vm/isolated/isolated.go | 2 | ||||
| -rw-r--r-- | vm/kvm/kvm.go | 2 | ||||
| -rw-r--r-- | vm/proxyapp/init.go | 2 | ||||
| -rw-r--r-- | vm/qemu/qemu.go | 2 | ||||
| -rw-r--r-- | vm/starnix/starnix.go | 2 | ||||
| -rw-r--r-- | vm/vm.go | 6 | ||||
| -rw-r--r-- | vm/vm_test.go | 2 | ||||
| -rw-r--r-- | vm/vmimpl/vmimpl.go | 12 | ||||
| -rw-r--r-- | vm/vmm/vmm.go | 2 | ||||
| -rw-r--r-- | vm/vmware/vmware.go | 2 |
15 files changed, 26 insertions, 18 deletions
diff --git a/vm/adb/adb.go b/vm/adb/adb.go index a108104c5..5b162bc37 100644 --- a/vm/adb/adb.go +++ b/vm/adb/adb.go @@ -27,7 +27,7 @@ import ( ) func init() { - vmimpl.Register("adb", ctor, false) + vmimpl.Register("adb", ctor, false, true) } type Device struct { diff --git a/vm/bhyve/bhyve.go b/vm/bhyve/bhyve.go index c3b53e053..3e82cbc2d 100644 --- a/vm/bhyve/bhyve.go +++ b/vm/bhyve/bhyve.go @@ -21,7 +21,7 @@ import ( ) func init() { - vmimpl.Register("bhyve", ctor, true) + vmimpl.Register("bhyve", ctor, true, false) } type Config struct { diff --git a/vm/cuttlefish/cuttlefish.go b/vm/cuttlefish/cuttlefish.go index 94610ed4e..d17bd78f2 100644 --- a/vm/cuttlefish/cuttlefish.go +++ b/vm/cuttlefish/cuttlefish.go @@ -28,7 +28,7 @@ const ( ) func init() { - vmimpl.Register("cuttlefish", ctor, true) + vmimpl.Register("cuttlefish", ctor, true, true) } type Pool struct { diff --git a/vm/gce/gce.go b/vm/gce/gce.go index 16f3f996f..6a292d4f6 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -35,7 +35,7 @@ import ( ) func init() { - vmimpl.Register("gce", ctor, true) + vmimpl.Register("gce", ctor, true, true) } type Config struct { diff --git a/vm/gvisor/gvisor.go b/vm/gvisor/gvisor.go index 45c076b23..f8194ab56 100644 --- a/vm/gvisor/gvisor.go +++ b/vm/gvisor/gvisor.go @@ -25,7 +25,7 @@ import ( ) func init() { - vmimpl.Register("gvisor", ctor, true) + vmimpl.Register("gvisor", ctor, true, false) } type Config struct { diff --git a/vm/isolated/isolated.go b/vm/isolated/isolated.go index 51a995b72..3383e91fa 100755 --- a/vm/isolated/isolated.go +++ b/vm/isolated/isolated.go @@ -23,7 +23,7 @@ import ( const pstoreConsoleFile = "/sys/fs/pstore/console-ramoops-0" func init() { - vmimpl.Register("isolated", ctor, false) + vmimpl.Register("isolated", ctor, false, true) } type Config struct { diff --git a/vm/kvm/kvm.go b/vm/kvm/kvm.go index 353f4300e..f22a195b3 100644 --- a/vm/kvm/kvm.go +++ b/vm/kvm/kvm.go @@ -27,7 +27,7 @@ const ( ) func init() { - vmimpl.Register("kvm", ctor, true) + vmimpl.Register("kvm", ctor, true, false) } type Config struct { diff --git a/vm/proxyapp/init.go b/vm/proxyapp/init.go index 467187f46..9c96e4855 100644 --- a/vm/proxyapp/init.go +++ b/vm/proxyapp/init.go @@ -32,7 +32,7 @@ func init() { func(env *vmimpl.Env) (vmimpl.Pool, error) { return ctor(makeDefaultParams(), env) }, - false) + false, true) } // Package configuration VARs are mostly needed for tests. diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index 4b857066a..4496680c3 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -27,7 +27,7 @@ import ( func init() { var _ vmimpl.Infoer = (*instance)(nil) - vmimpl.Register("qemu", ctor, true) + vmimpl.Register("qemu", ctor, true, false) } type Config struct { diff --git a/vm/starnix/starnix.go b/vm/starnix/starnix.go index d8beaba91..c3973fee9 100644 --- a/vm/starnix/starnix.go +++ b/vm/starnix/starnix.go @@ -22,7 +22,7 @@ import ( func init() { var _ vmimpl.Infoer = (*instance)(nil) - vmimpl.Register("starnix", ctor, true) + vmimpl.Register("starnix", ctor, true, false) } type Config struct { @@ -93,6 +93,12 @@ func AllowsOvercommit(typ string) bool { return vmimpl.Types[vmType(typ)].Overcommit } +// UseNetCompression says if it's beneficial to use network compression for this VM type. +// Local VMs (qemu) generally don't benefit from compression, while remote machines may benefit. +func UseNetCompression(typ string) bool { + return vmimpl.Types[vmType(typ)].NetCompression +} + // Create creates a VM pool that can be used to create individual VMs. func Create(cfg *mgrconfig.Config, debug bool) (*Pool, error) { typ, ok := vmimpl.Types[vmType(cfg.Type)] diff --git a/vm/vm_test.go b/vm/vm_test.go index 2a3f1171a..62b93f4c1 100644 --- a/vm/vm_test.go +++ b/vm/vm_test.go @@ -80,7 +80,7 @@ func init() { ctor := func(env *vmimpl.Env) (vmimpl.Pool, error) { return &testPool{}, nil } - vmimpl.Register("test", ctor, false) + vmimpl.Register("test", ctor, false, false) } type Test struct { diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index a9afdc1f1..bd565c8aa 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -129,16 +129,18 @@ func (err InfraError) InfraError() (string, []byte) { } // Register registers a new VM type within the package. -func Register(typ string, ctor ctorFunc, allowsOvercommit bool) { +func Register(typ string, ctor ctorFunc, allowsOvercommit, netCompression bool) { Types[typ] = Type{ - Ctor: ctor, - Overcommit: allowsOvercommit, + Ctor: ctor, + Overcommit: allowsOvercommit, + NetCompression: netCompression, } } type Type struct { - Ctor ctorFunc - Overcommit bool + Ctor ctorFunc + Overcommit bool + NetCompression bool } type ctorFunc func(env *Env) (Pool, error) diff --git a/vm/vmm/vmm.go b/vm/vmm/vmm.go index 71dfd39b4..67f12f4c7 100644 --- a/vm/vmm/vmm.go +++ b/vm/vmm/vmm.go @@ -25,7 +25,7 @@ import ( var vmctlStatusRegex = regexp.MustCompile(`^\s+([0-9]+)\b.*\brunning`) func init() { - vmimpl.Register("vmm", ctor, true) + vmimpl.Register("vmm", ctor, true, false) } type Config struct { diff --git a/vm/vmware/vmware.go b/vm/vmware/vmware.go index 4c05bac12..6bccbaa6e 100644 --- a/vm/vmware/vmware.go +++ b/vm/vmware/vmware.go @@ -22,7 +22,7 @@ import ( ) func init() { - vmimpl.Register("vmware", ctor, false) + vmimpl.Register("vmware", ctor, false, false) } type Config struct { |
