Very slow with large number of contexts
Compared to the native kubectl config use-context $contextname, kubectl ctx is noticeable slower when operating on a kubeconfig with a large number of contexts (9.8k).
kubectx ctx needs around 1.3-1.4 seconds to switch a context versus the native kubectl config use-context needing 0.7-0.8s (n=3 for each, M1 Pro with Sonoma 14.4).
Is this the Go based implementation or the Bash based implementation?
It was the bash implementation, but the go implementation is only marginally faster, takes ~1.1 seconds
To close the loop here: The limiting factor is yaml decoding and I think there is very little we can do to speed that up. I ended up writing a minimal version of a similiar CLI in rust which reduced the runtime to about 300 ms. That is still noticeable to me so I made that CLI write in json and naively check for json on decoding and use a json decoder if possible - That brought it down to about 30 ms.