cockroachdb / cockroachdb/cockroach

ui: gzip-compressed assets incur a hefty `init` latency

Open
#126,916 2 comments 0 reactions 0 assignees View on GitHub
branch-master C-enhancement T-observability
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

`ui.Assets` are unpacked during `init`,

```
//go:embed assets.tar.gz
var assets []byte

func init() {
fs, err := targz.AsFS(bytes.NewBuffer(assets))
if err != nil {
panic(err)
}
ui.Assets = fs
ui.HaveUI = true
}
```

At this time, their gzip-compressed size is ~`11MB`,

```
ls -lh /private/var/tmp/_bazel_srosenberg/567ebe324bb100ad2d71e73476e77acb/execroot/com_github_cockroachdb_cockroach/bazel-out/darwin_arm64-fastbuild/bin/pkg/ui/distccl/assets.tar.gz
-r-xr-xr-x 1 srosenberg wheel 11M Jul 10 00:00 /private/var/tmp/_bazel_srosenberg/567ebe324bb100ad2d71e73476e77acb/execroot/com_github_cockroachdb_cockroach/bazel-out/darwin_arm64-fastbuild/bin/pkg/ui/distccl/assets.tar.gz
```

The `init` latency on `m1pro` is ~`139ms`,

```
GODEBUG=inittrace=1 ./cockroach version 2>&1|grep init|grep pkg/ui |awk '{print $5}' |tr -d '@'|awk '{sum += $0} END {print sum}'
139.02
```

which is > 50% of the _total_ `init` latency for the entire binary,

```
GODEBUG=inittrace=1 ./cockroach version 2>&1|grep init|awk '{print $5}' |tr -d '@'|awk '{sum += $0} END {print sum}'
237.397
```

Jira issue: CRDB-40183

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.