Freeze when compiling "after a while"

I’m not yet sure how to reliably reproduce this.

The observation is that at beginning of my coding sessions, when I start the compilation like below:

$ rescript clean -with-deps && rescript build -w
>>>> Start compiling
rescript: [46/46] src/resolvers/Resolver.cmj # this is where it freezes
>>>> Finish compiling 90494 mseconds

My machine will freeze for 1-2 minutes. I suspect this might have something to do with a lot of file watchers and a lot of write, but as I cannot reliably reproduce this after these “first compilation daily”, I’m not sure yet what could be the case.

can you run bstracing after the build to see which part takes particularly long time?

Okay, so I am able to kinda reproduce the issue. It happens after I switch between branches with git

When I run bstracing after running rescript build -w, everything seems to be stretched for the whole duration of the compilation (Wall Duration is approximately the same for every row, or “process”).

When I run bstracing after running rescript build, some processes took much longer. They are stuck at the cmj category.

Should I provide better details somehow?

Now I also observed lag in cmi category.

It’s also not just rescript build that can freeze. Sometimes rescript does not freeze but after that git would freeze when I try to checkout other commits.

Do you find which one takes particularly long time ?

Some span took really long, for example:

Title Database.cmj, :mag:
Category cmj
User Friendly Category other
Start 269.000 ms
Wall Duration 45,143.000 ms

Sorry I’m not too familiar with this tool so I don’t know what to report.

And it doesn’t just take long doing its own thing, but my whole computer freezes while it is doing stuffs (BigSur 11.2.3).

What is in side database? Does it have some pathological pattern? Is it generated code?
Can you reproduce it by touch database module