Skip to content

Commit

Permalink
Mark comptess and decompress rust function as `schedule = "DirtyC…
Browse files Browse the repository at this point in the history
…pu"` to prevent long compression from starving Erlang VM
  • Loading branch information
JonathanTron committed Feb 20, 2025
1 parent 2f1f192 commit 8efcdfa
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
4 changes: 0 additions & 4 deletions native/ex_brotli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion native/ex_brotli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@

[dependencies]
brotli = "7.0.0"
rustler = "0.36.0"
4 changes: 2 additions & 2 deletions native/ex_brotli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use brotli::CompressorReader;
use rustler::{Binary, Encoder, Env, NifResult, OwnedBinary, Term};
use std::io::{Read, Write};

#[rustler::nif]
#[rustler::nif(schedule = "DirtyCpu")]
fn compress<'a>(env: Env<'a>, input: Binary) -> NifResult<Term<'a>> {
let mut compressor = CompressorReader::new(input.as_slice(), 4096, 11, 22);

Expand All @@ -19,7 +19,7 @@ fn compress<'a>(env: Env<'a>, input: Binary) -> NifResult<Term<'a>> {
}
}

#[rustler::nif]
#[rustler::nif(schedule = "DirtyCpu")]
fn decompress<'a>(env: Env<'a>, input: Binary) -> NifResult<Term<'a>> {
let mut decompressor = brotli::Decompressor::new(input.as_slice(), 4096);

Expand Down

0 comments on commit 8efcdfa

Please sign in to comment.