Skip to content

runtime,cmd/compile: redesign PCDATA encoding #61984

Open
@aclements

Description

@aclements

I've been experimenting with alternate encodings for the PCDATA tables, with the goal of significantly improving decode speed, at possibly a slight increase in binary size.

@mknyszek, @dr2chase and I designed a format that's >4x faster to decode than the Go 1.21 tables, while increasing binary size by only 1–2.5%. This issue is to track (eventually) moving to this format in the compiler and runtime.

I've described the format here and have an out-of-tree implementation of the encoder and decoder (apologies for the messy, experimental code).

Here's an example benchmark, using the go binary:

goos: linux
goarch: amd64
pkg: github.com/aclements/go-misc/pcvaluetab
cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
                               │  go.bench   │
                               │   sec/op    │
Decode/go/varint-cache-nohit-8   50.40n ± 2%
Decode/go/varint-cache-hit-8     10.23n ± 0%
Decode/go/varint-cache-none-8    42.46n ± 0%
Decode/go/alt-8                  11.69n ± 1%

file size change: +1.975729%

All of the benchmarks generate a random sample of 1024 (PC, table) pairs to lookup and report the average lookup time.

"Decode/go/alt" is the new implementation. "varint-cache-nohit" is the current varint format, with no cache hits. "varint-cache-hit" is similar, but repeats each lookup 8 times to simulate a high cache hit rate. "varint-cache-none" is the varint format, but with no cache.

Here are the same results for github.com/kubernetes/kubernetes/cmd/kubelet:

goos: linux
goarch: amd64
pkg: github.com/aclements/go-misc/pcvaluetab
cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
                                    │ kubelet.bench │
                                    │    sec/op     │
Decode/kubelet/varint-cache-nohit-8     56.21n ± 1%
Decode/kubelet/varint-cache-hit-8       11.04n ± 1%
Decode/kubelet/varint-cache-none-8      48.61n ± 1%
Decode/kubelet/alt-8                    11.80n ± 1%

file size change: +1.248393%

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsFixThe path to resolution is known, but the work has not been done.Performancebinary-sizecompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions