ππΌ I'm running a test suite via kaocha and have noticed that start up time is terribly slow. It's tolerable on my local machine but on CI, which are less powerful VMs, it takes 40-50 seconds before the first starts. I've heard that it spends a long time scanning the test directory but that still feels too long a time. So maybe first question: is this normal? and second question: are there some options available to investigate kaocha's performance?
it's been a while, I'm fairly sure we don't scan it. It think it's so the watcher can get triggered when source files change.
No, I don't think there's any way to "turn that off". Kaocha needs to create a test plan, for that it loads your namespaces if they're not loaded yet, and loops over the vars.
Maybe I was dreaming then. Am I AI?
one difference might be that cognitect test-runner will load and run the test namespaces, which will necessarily load the require 'd namespaces but no others, whereas does kaocha use src-paths to load everything?
i don't know what source-paths is used for, so i'm guessing here
do other test runners go faster? such as cognitect test runner or the leinigen test runner?
good question! Let me check
I said no earlier but ... Correction ... cognitect test runner is faster
by ~30%
Just last week I came across a test suite of ours that took either 6ish or 30ish minutes depending on which agent it ran on
Any chance cloverage is turned on for kaocha?
Or orchestra
no ... our only plugin is :kaocha.plugin/junit-xml
but I'm not sure we need it in this project so I'll try it without
yeah, as expected, that made no difference.
hmmm
are they running the same set of tests? do you have multiple kaocha suites defined and are accidentally running the same tests multiple times?
same tests definitely: I'm doing the comparison using only one long running integration test
so I can isolate the costs of each step
iiiiiiiinteresting
is this code open source? i'd be interested to see it
I have an idea
kaocha loads (all?) project namespaces at the start. I swear I saw a relatively recent feature/pr where the ability to turn this off was added
perhaps it's loading namespaces that are unnecessary for your test?
that's possible
what is the tweak needed to stop that?
I can't for the life of me seem to be able to find it right now
no worries ... I'm going to use the Cognitect runner for our CI and will circle back if there are some tweaks from #kaocha
kaocha does a lot of stuff under the hood that the other test runners don't, so i'm not entirely surprised it's slower, but 30% is quite a stark difference
The result of "find all the tests" is a test plan. You can generate a test plan from a REPL with
(require 'kaocha.repl)
(kaocha.repl/test-plan)
If test plan generation turns out to be the performance culprit, I'd try change :source-paths and :test-paths, in tests.edn, to see if it impacts test plan generation time.
#kaocha/v1
{:tests [{:id :unit
:source-paths ["src"]
:test-paths ["test"]}]}
Test plans and testables are explained here: https://cljdoc.org/d/lambdaisland/kaocha/1.91.1392/doc/9-extendingmaybe add some hooks to see in which stage it's spending that time?
The biggest difference is that I point the cognitect runner at the folder and ask it to run the tests. There are only two namespaces so, sure that's faster than traversing a (not very big) directory tree. It shouldn't be noticeable imho. I run the unit tests at the top of the folder hierarchy and itβs also much faster and needs to traverse the whole (again, not broad or deep) directory structure.
I added some hooks to see when it started / finished. Which was not interesting. What are the phases?
> @teodorlu @ plexus do you happen to know whether what I wrote above about an option to turn namespace auto loading off is not a hallucination? I haven't seen it mentioned, at least!