Skip to content

Draft: Full rewrite of fast_mmaped_file in Rust

Will Chandler (ex-GitLab) requested to merge wc/riir into master

This is a full rewrite of the fast_mmaped_file C extension in Rust using the magnus library. It strives to match the behavior of the C implementation as closely as possible, with the exception of additional checks for correctness. magnus has yet to add a tagged release that supports Ruby inheritance on Rust structs, so we're using HEAD for the time being. This functionality should be available when v0.6.0 is released, probably in a few weeks.

All active specs are passing and no failures have been found from 100,000 fuzzing runs.

The output of to_metrics is not identical to the existing extension as floating point values are occasionally slight different, e.g. 0.0009244309985660948 vs 0.00092443099856609479. My guess is this is due to differences in float formatting between libc and the Rust standard library. I've attached the output of to_metrics from the C and Rust implementation for comparison.

This MR is far too large to review in one go, but I wanted to make the full thing available for validation and to gauge interest.

Setup

Run ./bin/setup

Running Rust unit tests

Using magnus types in Rust unit tests does not work with the standard test runner due to how the Ruby runtime needs to be initialized. We can work around this by using https://nexte.st/ as the test runner, cargo nextest run. This executes each test function as a separate process.

TODO

  • Get CI working
Edited by Will Chandler (ex-GitLab)

Merge request reports

Loading