Skip to content

Commit

Permalink
Feat:recovereable error functions in scope src/cli (#1106)
Browse files Browse the repository at this point in the history
* fix clippy unwrap in src/cli

* apply suggestion
  • Loading branch information
vuvoth authored Feb 14, 2024
1 parent 1d4d308 commit ffb4071
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl ReplCli {
// Initializes CLI config with CLI arguments as overrides
let config = cli_config(self.config.as_ref(), Some(&cli_settings));

create_lurk_dirs().unwrap();
create_lurk_dirs()?;

let rc = config.rc;
let limit = config.limit;
Expand Down
8 changes: 4 additions & 4 deletions src/cli/repl/meta_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,10 @@ where
}
let open = repl.store.intern_lurk_symbol("open");
let open_expr = repl.store.list(vec![open, repl.store.num(hash)]);
let (args_vec, _) = repl
.store
.fetch_list(&args)
.expect("data must have been interned");
let Some((args_vec, _)) = repl.store.fetch_list(&args) else {
bail!("Data must have been interned");
};

let mut expr_vec = Vec::with_capacity(args_vec.len() + 1);
expr_vec.push(open_expr);
expr_vec.extend(args_vec);
Expand Down
20 changes: 12 additions & 8 deletions src/cli/repl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,13 @@ where
self.limit,
)?;
let iterations = frames.len();
let output = frames
.last()
.expect("evaluation should return at least one frame")
.output
.clone();

let Some(last_frames) = frames.last() else {
// TODO: better error decs
bail!("Frames is empty");
};

let output = last_frames.output.clone();
self.evaluation = Some(Evaluation { frames, iterations });
Ok((output, iterations))
}
Expand Down Expand Up @@ -584,16 +586,18 @@ where

let mut input = parser::Span::new(&input);
loop {
let file_dir = file_path.parent().unwrap();
let Some(file_dir) = file_path.parent() else {
bail!("Can't load parent of {}", file_path);
};

match self.handle_form(input, file_dir, demo) {
Ok(new_input) => input = new_input,
Err(e) => {
if let Some(parser::Error::NoInput) = e.downcast_ref::<parser::Error>() {
// It's ok, it just means we've hit the EOF
return Ok(());
} else {
return Err(e);
}
return Err(e);
}
}
}
Expand Down

1 comment on commit ffb4071

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks

Table of Contents

Overview

This benchmark report shows the Fibonacci GPU benchmark.
NVIDIA L4
Intel(R) Xeon(R) CPU @ 2.20GHz
32 vCPUs
125 GB RAM
Workflow run: https://github.com/lurk-lab/lurk-rs/actions/runs/7900881930

Benchmark Results

LEM Fibonacci Prove - rc = 100

ref=1d4d308e2bc12f5ab431ea210c0b722f9eb31825 ref=ffb4071b7aa5bd5955b59afb1835635a8a59b65c
num-100 1.45 s (✅ 1.00x) 1.45 s (✅ 1.00x faster)
num-200 2.78 s (✅ 1.00x) 2.77 s (✅ 1.00x faster)

LEM Fibonacci Prove - rc = 600

ref=1d4d308e2bc12f5ab431ea210c0b722f9eb31825 ref=ffb4071b7aa5bd5955b59afb1835635a8a59b65c
num-100 1.84 s (✅ 1.00x) 1.84 s (✅ 1.00x slower)
num-200 3.03 s (✅ 1.00x) 3.03 s (✅ 1.00x faster)

Made with criterion-table

Please sign in to comment.