Skip to content

Commit

Permalink
Merge branch 'main' into hydro_node_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchuyaya committed Jan 16, 2025
2 parents bfbff47 + 75eb323 commit 720e917
Show file tree
Hide file tree
Showing 63 changed files with 1,784 additions and 951 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ jobs:
- name: Run benchmark
run: |
time cargo bench -p benches -- hydroflow --output-format bencher | tee output.txt
time cargo bench -p benches -- dfir --output-format bencher | tee output.txt
time cargo bench -p benches -- micro/ops/ --output-format bencher | tee -a output.txt
- name: Generate benchmark page
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
}
}
],
"rust-analyzer.cargo.features": ["deploy"],
"editor.semanticTokenColorCustomizations": {
"enabled": true,
"rules": {
Expand Down
68 changes: 40 additions & 28 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions benches/benches/words_diamond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ fn hash_code(s: &str) -> u32 {
.fold(0, |n, c| n.wrapping_mul(31).wrapping_add(c as u32))
}

fn hydroflow_diamond(c: &mut Criterion) {
fn dfir_rs_diamond(c: &mut Criterion) {
let _ = *WORDS;

c.bench_function(name_of!(hydroflow_diamond), |b| {
c.bench_function(name_of!(dfir_rs_diamond), |b| {
b.iter(|| {
let words = words();
let mut df = dfir_syntax! {
Expand Down Expand Up @@ -173,7 +173,7 @@ fn hydroflo2_diamond_iter_buffer_one(c: &mut Criterion) {

criterion_group!(
words_diamond,
hydroflow_diamond,
dfir_rs_diamond,
hydroflo2_diamond_forloop,
hydroflo2_diamond_iter_clone_chain,
hydroflo2_diamond_iter_clone_interleave,
Expand Down
2 changes: 1 addition & 1 deletion dfir_lang/src/graph/eliminate_extra_unions_tees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn find_unary_ops<'a>(
.filter(move |&node_id| {
graph
.node_op_inst(node_id)
.map_or(false, |op_inst| op_name == op_inst.op_constraints.name)
.is_some_and(|op_inst| op_name == op_inst.op_constraints.name)
})
.filter(|&node_id| {
1 == graph.node_degree_in(node_id) && 1 == graph.node_degree_out(node_id)
Expand Down
2 changes: 1 addition & 1 deletion dfir_lang/src/graph/hydroflow_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ impl DfirGraph {
.iter()
.position(|&node_id| {
self.node_color(node_id)
.map_or(false, |color| Color::Pull != color)
.is_some_and(|color| Color::Pull != color)
})
.unwrap_or(subgraph_nodes.len())
}
Expand Down
1 change: 1 addition & 0 deletions dfir_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ proc-macro2 = "1.0.74"
proc-macro-crate = "1.0.0"
quote = "1.0.35"
syn = { version = "2.0.46", features = [ "parsing", "extra-traits" ] }
glob = "0.3.2"

[build-dependencies]
dfir_lang = { path = "../dfir_lang", version = "^0.11.0" }
Expand Down
38 changes: 26 additions & 12 deletions dfir_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,33 @@ pub fn dfir_parser(input: proc_macro::TokenStream) -> proc_macro::TokenStream {

#[doc(hidden)]
#[proc_macro]
pub fn surface_booktest_operators(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
assert!(input.is_empty(), "Input must be empty");
let each = dfir_lang::graph::ops::OPERATORS.iter().map(|op| {
let op_ident = Ident::new(op.name, Span::call_site());
let op_filename = format!("../../docs/docgen/{}.md", op.name);
let lit_filename = LitStr::new(&op_filename, Span::call_site());
quote! {
#[doc = include_str!(#lit_filename)]
mod #op_ident {}
}
});
pub fn doctest_markdown_glob(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let current_dir = std::env::current_dir().unwrap();
let input_glob = parse_macro_input!(input as LitStr);
let globbed_files = glob::glob(input_glob.value().as_str())
.expect("Failed to read glob pattern")
.map(|entry| entry.expect("Failed to read glob entry"))
.map(|path| {
let path_abs = current_dir.join(path.clone());
let path_abs_str = path_abs.to_str().expect("Failed to convert path to string");
let file_name_without_extension = path.to_str().expect("Failed to get file stem");
let lit = LitStr::new(path_abs_str, Span::call_site());
let mut ident_string = file_name_without_extension
.chars()
.map(|c| if c.is_ascii_alphanumeric() { c } else { '_' })
.collect::<String>();
if ident_string.chars().next().unwrap().is_ascii_digit() {
// Identifiers cannot start with a digit, prepend an underscore.
ident_string.insert(0, '_');
}
let file_name_ident = Ident::new(&ident_string, Span::call_site());
quote! {
#[doc = include_str!(#lit)]
mod #file_name_ident {}
}
});
let out = quote! {
#( #each )*
#( #globbed_files )*
};
out.into()
}
Expand Down
2 changes: 1 addition & 1 deletion dfir_rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ pub type Never = std::convert::Infallible;
#[cfg(doctest)]
mod booktest {
mod surface_ops {
dfir_macro::surface_booktest_operators!();
dfir_macro::doctest_markdown_glob!("docs/docgen/*.md");
}
}
3 changes: 2 additions & 1 deletion dfir_rs/src/scheduled/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ impl Default for Context {
current_tick_start: SystemTime::now(),
subgraph_last_tick_run_in: None,

subgraph_id: SubgraphId(0),
// Will be re-set before use.
subgraph_id: SubgraphId::from_raw(0),

tasks_to_spawn: Vec::new(),
task_join_handles: Vec::new(),
Expand Down
Loading

0 comments on commit 720e917

Please sign in to comment.