o1js: Performance regression in v1.9.0

I’m experiencing crazy performance regression when compiling a recursive circuit, that occurs when switching to the latest 1.9.0 release from the CD release https://pkg.pr.new/o1-labs/o1js@0f8ff81 that came just before it.

I’m seeing compilation time go from 17s to 180s. This is reproducible when switching between the two installed versions.

The obvious candidate PR that could have introduced such a regression is https://github.com/o1-labs/o1js/pull/1857 @mrmr1993

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

@mitschabaude

Thanks, I wrote a test and confirms it works on 1.8.0, and my branch, and fails on 1.9.0

https://github.com/o1-labs/o1js/pull/1874/files#diff-e7d3bfd05832c7137d897ba35e98b9b92dbfff4a541efec13eea2701c126f8caR50

I think it’s good to have a test since we know this caused a performance regression once. Adding a timing-based test to test performance may also be nice to do, but if we can pinpoint the root cause, I’m for adding a test to prevent it in the future.

@jmikedupont2 that test was introduced to fix a process that hangs forever, which seems to be what’s happening on your branch.

The test passes quickly on the main branch and in my PR branch https://github.com/o1-labs/o1js/actions/runs/11418129637/job/31771226595

I’d double check you have the right branched merged on your fork.

@mitschabaude I built your fix here:

I was looking for a good way to unit test the cache, but it seems too deeply rooted in the bindings code. The performance and cache read feature seem to work simultaneously on my machine.

@mitschabaude Thanks for the PR. Looks like I still can’t execute CI on Mina 😦 But I will organize the right people to get eyes on it at least.

I don’t want to regress #1411 and keep flip-flopping between the issues, so I’m reticent to just revert the changes. Is it possible to revert the change to maybe_lagrange_commitment without regressing the cache behavior?

Yeah of course, we can’t just revert everything. Both issues have to be fixed at the same time, and this really shouldn’t be a big problem if one takes the effort to understand exactly where the original version went wrong.

I didn’t look into the original bug, so I can’t say whether only reverting maybe_lagrange_commitment will regress to the original bug. But it seems worth a try! Simple enough to revert only that function, rebuild and run the regression test.

If that doesn’t work, that just means more effort is needed to fix the performance regression. We can’t keep the performance as it is now.

The “maybe” method fundamentally is needed for caching. The file system cache is slow: you can’t read from it every single time. Therefore, you need a fast cache that takes over once the file system cache read from the file system once. That fast cache is the in-memory LB. To act as a cache though, it needs to support cache misses. Cache misses (= returning undefined) used to be supported by maybeLagrangeBasis(), but the current version never misses, so the file system cache is never used.

The last time I had a performance regression related to Lagrange basis creation, the problem was that they were generated in a single thread.

According to the research made by @jmikedupont2, in 1.9.0 there is some slow process that almost do not use the CPU inserted at the beginning of compilation:

https://github.com/o1-labs/o1js/issues/1870#issuecomment-2420888570