helm-diff icon indicating copy to clipboard operation
helm-diff copied to clipboard

Diff is too slow

Open strainovic opened this issue 2 years ago • 1 comments

Hi,

In the k8s namespace, I have about 26 releases with various k8s objects such as deployments, config maps, secrets, ingresses, services, etc. When I run diff as helmfile command, it takes 2 minutes to complete, while only for the first 20 seconds, the CPU is at 100%. After that, it is around 10-20%.

Can we somehow detect why diff works that slow, and improve diff speed?

Thanks!

strainovic avatar Mar 23 '23 17:03 strainovic

I wrote this simple bash script to compare times and these are the results:

real    0m22.749s
user    0m0.682s
sys     0m2.188s

for the bash script

real    1m54.800s
user    0m0.000s
sys     0m0.015s

for the helmfile diff (I run diff with --skip-deps argument).

Here is the script:

#!/bin/bash

namespace="test"

source .env
source .secrets
source .versions

releases=$(helm ls -n ${namespace} | awk '{ print $1 }')

for release in ${releases[@]}; do
  if [ "${release}" != "NAME" ]; then
    helm get manifest ${release} -n ${namespace} > k8s-${release}-manifest.yaml &
    helmfile -n ${namespace} -l name=${release} template --skip-deps > local-${release}-manifest.yaml &
  fi
done
wait

for release in ${releases[@]}; do
  if [ "${release}" != "NAME" ]; then
    diff k8s-${release}-manifest.yaml local-${release}-manifest.yaml > diff-${release}-manifest.yaml &
  fi
done
wait

echo "DONE!"

Thanks!

strainovic avatar Mar 23 '23 17:03 strainovic