You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
k8s.io/client-go/kubernetes is pulled in directly via knative.dev/pkg/metrics for the stackdriver exporter to fetch secrets.
Pulling in the above PR and commenting the kubeClient references in knative.dev/pkg/metrics yields a binary size of 42,193,344 (32% reduction in size).
FWIW, that's likely included in my figures, unless it is transitively pulled in through other things. I'm measuring the overall binary size once a particular cut point in the dependency graph has been snipped.
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.
Anyway, totally ack that there's a maintainability trade-off here, just this may be a case where it's warranted (empirically QP is very expensive for what it does), and rust is pretty ok.
@julz
The topic is a little old, but I am wondering are there any findings/update for reimplementing QP as a wasm plug-in in envoy? The idea is promising even now.
Move autoscaler/metric.Stat to it's own package so it doesn't pull in any autoscaling APIs
Don't consume corev1.Probe in the queue proxy - but create a copy of it
Move knative.dev/configmap.Parse methods to their own package - no corev1 dep
Drop corev1 usage in knative.dev/pkg/metrics
drop use of corev1.Secret
drop use of corev1.ConfigMap - move ConfigMapWatcher to it's own package
Drop corev1 usage in knative.dev/pkg/tracing
drop use of corev1.ConfigMap
I tested changes 1-3 and removed tracing and metrics in order to see what the floor of completing 4-6 would be - that resulted in a queue-proxy binary size of 15MB.
There's probably a gain to be had when we removed it's copy of prometheus libs - ie. #11126
Following up on this - as part of moving to OTel libs the new knative.dev/pkg/observability should be segmented so it doesn't rely on k8s deps.
I'm slightly concerned about the leakage of go-cmp via knative.dev/pkg/apis.CheckDisallowedFields -- is this something that we could simplify using go templates (e.g. should request and maskedRequest be the same type)?
Activity
mattmoor commentedon Oct 27, 2020
Goal: eliminate queue-proxy dependency on
k8s.io/client-go/kubernetesTwo offenders:
k8s.io/client-go/informersis pulled in via the informed watcher inknative.dev/pkg/configmap(unused in queue-proxy): Splitting configmap package to avoid heavy dependencies pkg#1851k8s.io/client-go/kubernetesis pulled in directly viaknative.dev/pkg/metricsfor the stackdriver exporter to fetch secrets.Pulling in the above PR and commenting the kubeClient references in
knative.dev/pkg/metricsyields a binary size of42,193,344(32% reduction in size).mattmoor commentedon Oct 27, 2020
Goal: eliminate queue-proxy dependency on
contrib.go.opencensus.io/exporter/stackdriverTwo offenders:
knative.dev/pkg/metricsknative.dev/pkg/tracingCommenting out the stackdriver logic in these packages further reduces the queue-proxy binary size to
35,560,653(another 18% reduction).cc @evankanderson
vagababov commentedon Oct 27, 2020
In my build opencensus also seems to pull
793066 T github.com/aws/aws-sdk-go/aws/endpoints.initwhich with other aws stuff is another meg.mattmoor commentedon Oct 27, 2020
FWIW, that's likely included in my figures, unless it is transitively pulled in through other things. I'm measuring the overall binary size once a particular cut point in the dependency graph has been snipped.
mattmoor commentedon Oct 27, 2020
Shouldn't effect the code pages, but @tcnghia also found that if we use:
It drops things another ~10MB (on top of what I measured above). Seems like the lowest hanging fruit yet.
https://blog.filippo.io/shrink-your-go-binaries-with-this-one-weird-trick/
Build stripped binariest to reduce sizes
Build stripped binaries to reduce sizes
Build stripped binaries to reduce sizes (#2537)
mattmoor commentedon Oct 30, 2020
@evankanderson do you want to link to or summarize your thoughts on timeline to cut this dependency?
github-actions commentedon Jan 29, 2021
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with
/reopen. Mark the issue asfresh by adding the comment
/remove-lifecycle stale.30 remaining items
qiming-007 commentedon Jan 2, 2024
@julz
The topic is a little old, but I am wondering are there any findings/update for reimplementing QP as a wasm plug-in in envoy? The idea is promising even now.
dprotaso commentedon Jul 11, 2025
Following up on this - as part of moving to OTel libs the new knative.dev/pkg/observability should be segmented so it doesn't rely on k8s deps.
One thing I recently discovered is that using certain libraries is preventing dead code elimination by the compiler - https://github.com/aarzilli/whydeadcode/
I'm wondering if this is really the root cause to the bloat (eg. k8s deps should be pruned by the compiler)
mattmoor commentedon Jul 11, 2025
Yeah, @dims did a bunch of work on this recently in K8s itself.
dprotaso commentedon Jul 11, 2025
There's a few places to dive into - one is building with
grpcnotrace-https://github.com/grpc/grpc-go/blob/3d0cb79a78772b48422793c579395ba7da64d6f3/trace_notrace.go#L22-L25
After that text/template, go-cmp are other sources.
dprotaso commentedon Jul 11, 2025
For templating we could explore https://github.com/valyala/fasttemplate
I'm also wondering if go-cmp can be 'quarantined' using a
sync.Onceor somethingevankanderson commentedon Jul 11, 2025
I'm slightly concerned about the leakage of
go-cmpviaknative.dev/pkg/apis.CheckDisallowedFields-- is this something that we could simplify using go templates (e.g. shouldrequestandmaskedRequestbe the same type)?