Skip to content

Excessive script overhead #39

@jrfondren

Description

@jrfondren

Consider:

# grep . *.rs
h1.rs:fn main() { println!("hi") }
h2.rs:#! /usr/bin/env cargo-eval
h2.rs:fn main() { println!("hi") }
h3.rs:#! /usr/bin/env rust-script
h3.rs:fn main() { println!("hi") }
# rustc h1.rs
# hyperfine --warmup=1 ./h1 ./h2.rs ./h3.rs
Benchmark 1: ./h1
  Time (mean ± σ):       1.2 ms ±   0.1 ms    [User: 0.4 ms, System: 0.9 ms]
  Range (min … max):     0.0 ms …   1.8 ms    1013 runs

Benchmark 2: ./h2.rs
  Time (mean ± σ):       5.8 ms ±   6.9 ms    [User: 2.1 ms, System: 2.7 ms]
  Range (min … max):     1.4 ms …  88.8 ms    402 runs

Benchmark 3: ./h3.rs
  Time (mean ± σ):      99.5 ms ±   3.8 ms    [User: 84.2 ms, System: 14.0 ms]
  Range (min … max):    95.8 ms … 114.0 ms    25 runs

Summary
  './h1' ran
    4.95 ± 5.87 times faster than './h2.rs'
   84.60 ± 10.38 times faster than './h3.rs'

On a good laptop the difference isn't so bad, ./h1 is only 30x faster than ./h3.rs. The times are above are on a server with slow HDD disks.

I was excited to see an actively maintained Rust scripting crate, but this overhead is too much. I also worry that whatever the .json writes are for will be broken if there are many concurrent runs of the script.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions