Skip to content

Commit

Permalink
disable DeepCopy in cache
Browse files Browse the repository at this point in the history
this commit disables DeepCopy in cache for performance reason. This will speed-up
request processing. From now on, no changes to the resources should be made from outside
the cache.

Signed-off-by: Francesco Ilario <[email protected]>
  • Loading branch information
filariow committed Jan 28, 2025
1 parent 71b3864 commit b643ea9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ func BuildAndStartCache(ctx context.Context, cfg *cacheConfig) (cache.Cache, err
&rbacv1.Role{},
}
c, err := cache.New(cfg.restConfig, cache.Options{
Scheme: s,
Scheme: s,
DefaultUnsafeDisableDeepCopy: ptr(true),
ByObject: map[client.Object]cache.ByObject{
&corev1.Namespace{}: {
Transform: mergeTransformFunc(
Expand Down Expand Up @@ -174,3 +175,7 @@ func BuildAndStartCache(ctx context.Context, cfg *cacheConfig) (cache.Cache, err

return c, nil
}

func ptr[T any](t T) *T {
return &t
}

0 comments on commit b643ea9

Please sign in to comment.