Skip to content

Instantly share code, notes, and snippets.

@m-doughty
Created September 20, 2026 11:58
Show Gist options
  • Select an option

  • Save m-doughty/ce5e7159305dc05d0239b4e51c26141b to your computer and use it in GitHub Desktop.

Select an option

Save m-doughty/ce5e7159305dc05d0239b4e51c26141b to your computer and use it in GitHub Desktop.
my $conc = (%*ENV<CONC> // 4).Int;
my $mb = (%*ENV<MB> // 4).Int;
my $rounds = (%*ENV<ROUNDS> // 60).Int;
my $chars = $mb * 1024 * 1024;
my $blob = ('a' x $chars).encode('utf8');
say "decoding {$blob.elems} bytes x $rounds on $conc threads, $conc allocator threads";
my @w;
for ^$conc {
@w.push: start {
for ^$rounds {
my $s = $blob.decode('utf8');
die "BAD DECODE: got {$s.chars} chars, wanted $chars" unless $s.chars == $chars;
}
}
}
for ^$conc {
@w.push: start {
my $sink = 0;
for ^$rounds {
for ^20000 {
my @a = $_, $_ + 1, $_ + 2;
$sink += @a[0];
}
}
$sink
}
}
await @w;
say "survived";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment