Skip to content
CAI
Software that uses CAICheck a score

discord/sorted_set_nif

65.3

Adequate · 3 October 2026

1.9k

lines of production code

Rust

with Elixir

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a high-performance SortedSet library implemented in Rust and exposed to Elixir via Native Implemented Functions (NIFs). It provides core set operations such as adding, removing, and indexing elements, along with sorting and list conversion capabilities. The implementation leverages the jemalloc allocator to expose detailed memory allocation information for profiling and monitoring purposes.

Behavioural changes

SortedSet NIF API updates and jemalloc memory info exposure

The SortedSet library has updated its NIF bridge to align with Rustler 0.22.x, which changes the return tuples from NIF functions to be wrapped in a {:ok, ...} structure (e.g., {:ok, :ok} instead of :ok, and {:ok, {:added, index}} instead of {:ok, :added, index}). This ensures consistent error handling across operations like add, remove, and size. Additionally, the library now exposes jemalloc memory allocation information via a new jemalloc\_allocation\_info function, allowing users to inspect memory usage details reported by the underlying allocator.

lib · high confidence

Updated benchmark scripts to use new Benchee formatter syntax and Discord.SortedSet

The benchmark scripts in the bench directory have been updated to align with the latest Benchee API, switching from the deprecated function-argument formatter syntax to the new module-attribute style for both Console and HTML formatters. Additionally, the construction benchmarks now reference the Discord.SortedSet module instead of the local SortedSet module for proper and shuffled enumerable construction tests.

bench · high confidence

Upgrade to Rustler 0.37 and adopt modern NIF patterns

The native SortedSet implementation has been upgraded to Rustler 0.37, replacing the legacy \rustler\_export\_nifs!\ macro with the declarative \rustler::init!\ macro. This change modernizes the NIF bridge by using \\#\[rustler::nif\]\ attributes for function registration and \\#\[rustler::resource\_impl\]\ for resource management, simplifying the API surface and improving type safety. Additionally, the module now integrates the jemalloc allocator via \jemallocator\ and exposes \jemalloc\_allocation\_info\ for memory profiling, while internal code has been refactored to use explicit \crate::\ paths and idiomatic Rust patterns.

_native/sorted\_set\nif · high confidence

Test coverage

Updated SortedSet property tests for syntax compatibility

Added tests to verify SortedSet behavior across multiple operations (add, remove, index\_add, index\_remove, size, slice, sorting, to\_list) by updating the test suite to use the new \check all(...)\ syntax required by the updated test framework.

test · high confidence

Dependencies

Upgrade Rustler to 0.37 and add jemalloc integration

The native NIF dependency on Rustler has been upgraded from version 0.18 to 0.37, requiring a corresponding update to the Elixir project configuration. Additionally, the \jemalloc\_info\ and \jemallocator\ crates have been added to the Rust dependencies, introducing memory allocation instrumentation and a custom allocator, while the project version has been bumped to 2.0.1.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 67 → 65 (-1.9)
  • Rubric changed (rubric-2026.09.15 → rubric-2026.10.1) — scores are not directly comparable.

Lenses

  • Code Health 95 → 95 (+0.0)
  • Architecture 100 → 100 (+0.1)
  • Maturity 61 → 61 (+0.0)
  • Readiness 58 → 54 (-3.5)
  • Security 80 → 83 (+3.3)

Resolved (1)

  • Documentation: no usage examples (README.md)

New (1)

  • Documentation: no architecture or design documentation (README.md)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

discord/sorted_set_nif was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 3 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 6ba93bf7d46635e3b35bb282339a1271784d0cbe — the exact code this score is about.
  • Scored under rubric-2026.10.1 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-4f4226d619ea.