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

optimize init memory allocations #7578

Closed
Tracked by #7532
smira opened this issue Aug 4, 2023 · 0 comments
Closed
Tracked by #7532

optimize init memory allocations #7578

smira opened this issue Aug 4, 2023 · 0 comments

Comments

@smira
Copy link
Member

smira commented Aug 4, 2023

The current list for machined:

init github.com/containerd/containerd/reference/docker @7.5 ms, 1.6 ms clock, 1272352 bytes, 10620 allocs
init go.opentelemetry.io/otel/trace @14 ms, 0.75 ms clock, 968520 bytes, 4798 allocs
init k8s.io/client-go/kubernetes/scheme @17 ms, 1.4 ms clock, 686544 bytes, 5719 allocs
init go.etcd.io/etcd/api/v3/etcdserverpb @11 ms, 1.0 ms clock, 585144 bytes, 1438 allocs
init github.com/gdamore/tcell/v2 @24 ms, 22 ms clock, 582864 bytes, 32 allocs
init github.com/gopacket/gopacket/layers @20 ms, 3.1 ms clock, 393128 bytes, 106 allocs
init github.com/cosi-project/runtime/pkg/resource/meta/spec @3.0 ms, 0.63 ms clock, 339240 bytes, 2428 allocs
init github.com/hetznercloud/hcloud-go/v2/hcloud @24 ms, 0.21 ms clock, 285336 bytes, 1285 allocs
init github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1 @3.8 ms, 0.30 ms clock, 184248 bytes, 1176 allocs
init github.com/google/go-cmp/cmp @19 ms, 0.25 ms clock, 178376 bytes, 150 allocs
init k8s.io/api/core/v1 @16 ms, 0.18 ms clock, 177760 bytes, 468 allocs
init github.com/siderolabs/talos/pkg/machinery/api/machine @4.9 ms, 0.20 ms clock, 148464 bytes, 86 allocs
init go.etcd.io/etcd/raft/v3/raftpb @12 ms, 1.5 ms clock, 126744 bytes, 240 allocs
init k8s.io/component-base/metrics/legacyregistry @48 ms, 0.30 ms clock, 115296 bytes, 921 allocs
init github.com/siderolabs/talos/pkg/machinery/resources/network @4.2 ms, 0.45 ms clock, 112480 bytes, 1308 allocs
init sigs.k8s.io/structured-merge-diff/v4/typed @19 ms, 0.37 ms clock, 98264 bytes, 1828 allocs
init k8s.io/api/extensions/v1beta1 @17 ms, 0.052 ms clock, 98080 bytes, 99 allocs
init github.com/opencontainers/go-digest @6.6 ms, 0.11 ms clock, 94256 bytes, 845 allocs
init go.etcd.io/etcd/api/v3/membershippb @10 ms, 0.10 ms clock, 93992 bytes, 111 allocs

The gopacket issue is already PR'd as gopacket/gopacket#24

The tcell issue is #7579

The types/v1alpha1 should be a low-hanging fruit, this is more probably examples?

The way to regen the output:

GODEBUG=inittrace=1 _out/machined  &| cat > machined.log
# ^C it here
cat machined.log | /bin/grep init  | sort -rnk 8 | head -20
smira added a commit to smira/talos that referenced this issue Aug 4, 2023
There are two changes here:

* build `machined` binary with `tcell_minimal` tag (which disables
  loading some parts of the terminfo database), which also affects
  `apid`, `trustd` and `dashboard` processes, as they run from the same
  executable; in `dashboard` explicitly import `linux` terminal we're
  using when the `dashboard` runs on the machine
* pass `TCELL_MINIMIZE=1` environment variable to each Talos process
  which removes 0.5MiB of runewdith allocation for a lookup table

See siderolabs#7578

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
smira added a commit to smira/talos that referenced this issue Aug 8, 2023
There are two changes here:

* build `machined` binary with `tcell_minimal` tag (which disables
  loading some parts of the terminfo database), which also affects
  `apid`, `trustd` and `dashboard` processes, as they run from the same
  executable; in `dashboard` explicitly import `linux` terminal we're
  using when the `dashboard` runs on the machine
* pass `TCELL_MINIMIZE=1` environment variable to each Talos process
  which removes 0.5MiB of runewdith allocation for a lookup table

See siderolabs#7578

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
(cherry picked from commit fb536af)
smira added a commit to smira/talos that referenced this issue Aug 9, 2023
See siderolabs#7578

With this change and siderolabs#7590, init allocation:

```
init github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1 @2.1 ms, 0.006 ms clock, 1408 bytes, 26 allocs
```

Previously, it was:

```
init github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1 @3.8 ms, 0.30 ms clock, 184248 bytes, 1176 allocs
```

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
smira added a commit to smira/talos that referenced this issue Aug 9, 2023
See siderolabs#7578

With this change and siderolabs#7590, init allocation:

```
init github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1 @2.1 ms, 0.006 ms clock, 1408 bytes, 26 allocs
```

Previously, it was:

```
init github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1 @3.8 ms, 0.30 ms clock, 184248 bytes, 1176 allocs
```

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
smira added a commit to smira/talos that referenced this issue Aug 16, 2023
See siderolabs#7578

With this change and siderolabs#7590, init allocation:

```
init github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1 @2.1 ms, 0.006 ms clock, 1408 bytes, 26 allocs
```

Previously, it was:

```
init github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1 @3.8 ms, 0.30 ms clock, 184248 bytes, 1176 allocs
```

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
(cherry picked from commit e1b2886)
@smira smira closed this as completed Dec 8, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant