kaocha

ray 2026-01-21T11:51:32.662489Z

πŸ‘‹πŸΌ 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?

plexus 2026-01-23T12:55:12.468929Z

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.

πŸ‘ 1
plexus 2026-01-22T09:26:43.013089Z

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.

imre 2026-01-22T15:11:23.348459Z

Maybe I was dreaming then. Am I AI?

2
πŸ€– 2
2026-01-22T15:42:35.106089Z

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?

2026-01-22T15:42:48.900239Z

i don't know what source-paths is used for, so i'm guessing here

2026-01-21T12:23:21.957349Z

do other test runners go faster? such as cognitect test runner or the leinigen test runner?

ray 2026-01-21T12:59:38.100489Z

good question! Let me check

ray 2026-01-21T13:51:21.385289Z

I said no earlier but ... Correction ... cognitect test runner is faster

ray 2026-01-21T13:51:37.271709Z

by ~30%

imre 2026-01-21T13:52:03.022699Z

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

imre 2026-01-21T13:52:22.240569Z

Any chance cloverage is turned on for kaocha?

imre 2026-01-21T13:52:32.023789Z

Or orchestra

ray 2026-01-21T13:53:27.744949Z

no ... our only plugin is :kaocha.plugin/junit-xml

ray 2026-01-21T13:54:00.669539Z

but I'm not sure we need it in this project so I'll try it without

ray 2026-01-21T14:01:03.130189Z

yeah, as expected, that made no difference.

2026-01-21T14:13:09.450609Z

hmmm

2026-01-21T14:14:00.549459Z

are they running the same set of tests? do you have multiple kaocha suites defined and are accidentally running the same tests multiple times?

ray 2026-01-21T14:46:54.682599Z

same tests definitely: I'm doing the comparison using only one long running integration test

ray 2026-01-21T14:47:12.638319Z

so I can isolate the costs of each step

2026-01-21T14:53:22.203679Z

iiiiiiiinteresting

2026-01-21T14:53:38.780349Z

is this code open source? i'd be interested to see it

πŸ” 1
😒 1
imre 2026-01-21T14:53:54.488099Z

I have an idea

πŸ‘€ 1
imre 2026-01-21T14:58:26.214339Z

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

imre 2026-01-21T14:58:44.852499Z

perhaps it's loading namespaces that are unnecessary for your test?

ray 2026-01-21T15:02:36.309769Z

that's possible

ray 2026-01-21T15:02:58.134969Z

what is the tweak needed to stop that?

imre 2026-01-21T15:03:17.039679Z

I can't for the life of me seem to be able to find it right now

😬 1
ray 2026-01-21T15:24:02.584539Z

no worries ... I'm going to use the Cognitect runner for our CI and will circle back if there are some tweaks from #kaocha

2026-01-21T15:33:08.822419Z

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

teodorlu 2026-01-21T16:14:13.461499Z

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-extending

plexus 2026-01-21T16:23:08.271189Z

maybe add some hooks to see in which stage it's spending that time?

πŸ‘ 1
ray 2026-01-21T16:42:24.244639Z

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.

imre 2026-01-21T16:42:57.186379Z

@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?

ray 2026-01-21T16:44:14.232719Z

I added some hooks to see when it started / finished. Which was not interesting. What are the phases?

teodorlu 2026-01-21T17:10:15.981549Z

> @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!