Skip to content

chore(controllers): embed gtime to cut build time#2514

Merged
weisdd merged 7 commits intomasterfrom
chore/embed-gtime
Feb 17, 2026
Merged

chore(controllers): embed gtime to cut build time#2514
weisdd merged 7 commits intomasterfrom
chore/embed-gtime

Conversation

@weisdd
Copy link
Collaborator

@weisdd weisdd commented Feb 17, 2026

In #2269, there was the gtime dependency added to parse a wider set of durations. As a consequence, many indirect dependencies were added as well.

When analyzing build time using actiongraph, I've noticed that, on my laptop (8-core M1), all those deps contribute about 30-40 seconds in total, which seems to be too much for just a single function we wanted to use.

To mitigate that, I've prepared a new gtime package that contains only the code related to ParseDuration(). - It's mostly a copy of https://github.com/grafana/grafana-plugin-sdk-go/backend/gtime, but decoupled from https://github.com/grafana/grafana-plugin-sdk-go/backend (backend.DownstreamError) and reformatted according to our current linter/formatter settings.

Of course, the actual effect depends on many factors, but when I measured the build time with clean cache, it dropped from ~233.177s to ~192.593s.

Build stats
0.021s                golang.org/x/exp
0.021s   0.021s       github.com/mattetti/filebuffer
0.024s   0.024s       github.com/mattn/go-colorable
0.024s   0.024s       github.com/mattn/go-isatty
0.027s   0.027s       github.com/clipperhouse/stringish
0.029s                github.com/cheekybits/genny
0.035s   0.035s       github.com/oklog/run
0.036s                github.com/golang/protobuf
0.038s   0.038s         github.com/cenkalti/backoff/v5
0.048s   0.048s       github.com/grafana/otel-profiling-go
0.049s   0.049s         go.opentelemetry.io/contrib/propagators/jaeger
0.050s   0.050s       github.com/mattn/go-runewidth
0.053s   0.053s       github.com/fatih/color
0.074s   0.052s       golang.org/x/xerrors
0.074s   0.074s       github.com/hashicorp/yamux
0.077s                  github.com/clipperhouse/uax29/v2
0.078s   0.078s       github.com/olekukonko/tablewriter
0.090s   0.090s           github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus
0.093s                github.com/google/flatbuffers
0.096s   0.096s       github.com/jszwedko/go-datemath
0.099s                github.com/gogo/googleapis
0.100s                  github.com/grpc-ecosystem/go-grpc-middleware/v2
0.111s   0.088s             go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
0.121s   0.121s       github.com/hashicorp/go-hclog
0.123s   0.097s         go.opentelemetry.io/contrib/samplers/jaegerremote
0.139s   0.039s         github.com/grafana/pyroscope-go/godeltaprof
0.153s   0.153s       github.com/zeebo/xxh3
0.155s   0.070s               go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace
0.272s   0.068s         github.com/pierrec/lz4/v4
0.421s   0.084s             go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
0.578s   0.025s       go.opentelemetry.io/otel/sdk
0.965s   0.717s       github.com/hashicorp/go-plugin
1.020s                github.com/jaegertracing/jaeger-idl
1.707s                github.com/grafana/grafana-plugin-sdk-go
2.916s                  github.com/apache/arrow-go/v18
20.423s   0.041s       github.com/goccy/go-json

~30.34s (doesn't include linking and waiting).

Copy link
Collaborator

@Baarsgaard Baarsgaard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binary size also shrinks! 95Mi -> 81Mi

@weisdd
Copy link
Collaborator Author

weisdd commented Feb 17, 2026

@Baarsgaard ah, that's nice! I've completely forgotten to check the binary size, thanks for highlighting that :)

@weisdd weisdd enabled auto-merge February 17, 2026 14:36
@weisdd weisdd added this pull request to the merge queue Feb 17, 2026
Merged via the queue into master with commit 56b5ea1 Feb 17, 2026
19 checks passed
@weisdd weisdd deleted the chore/embed-gtime branch February 17, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants