Search code examples
rustrust-cargorust-criterion

Rust Criterion fails to build benchmarks


I'm using criterion and cargo-criterion to benchmark my code but after adding a couple more benchmarks, for some reason I am not able to get past the build step (of the benchmarks). The error message I'm getting is not very helpful to find out where the issue lies and neither can I find much information on the problem when searching online.

The error I get from both cargo criterion and cargo bench

Error: Failed to parse message from cargo187/190: continuous(bench), test_data(bench), simplistic(bench)

Caused by:
    expected value at line 188 column 1
error: could not compile `compiled-regex`

Repo: https://github.com/Tobiky/compiled-regex/

I've had no issues running the individual benchmarks in an example file within the workspace nor can I find any errors being produced on my side.

What is causing this issue?

EDIT 1: From further digging I've found that rustc is sigkilling itself during the build but its not giving any reason as to why.

I'm also testing combinations and orders of the benchmarks to see if that has any effect, tested about half of it and nothing so far.

Edit 2: As per @kmdreko suggestion, the issue might be been the compiler consuming too much memory which turned out true. Since code is being generated it might have to do with something there and I'm currently investigating. So far, removing inlining on a couple of generated functions have solved the problem but I still do not know why.


Solution

  • The problem ended up being an aggressive inlining invocation on the generated code. The possible recursive functions and function depth likely is the cause for the OOM described by @kmdreko. Removing inlining invocation removed the crashes.

    I will edit this answer once I've done further adjustments and tests to narrow the cause.