Skip to content

hydro_std v0.17.0-alpha.7

Latest

Choose a tag to compare

@hydro-project-bot hydro-project-bot released this 20 Nov 04:11
· 11 commits to main since this release

Chore

  • enable many new workspace clippy lints and fix all resulting warnings
    Enables a large batch of new clippy lints in [workspace.lints.clippy]
    and fixes every resulting warning — the workspace is now clean under
    cargo clippy --workspace --all-targets.

    Lint config changes (Cargo.toml)

    Round 1 — initial batch: collapsible_else_if, doc_markdown,
    format_collect, ignore_without_reason, ignored_unit_patterns,
    inconsistent_struct_constructor, manual_assert, manual_string_new,
    match_bool, mismatching_type_param_order, mut_mut,
    nonminimal_bool, option_as_ref_cloned, ptr_cast_constness,
    pub_underscore_fields, ref_binding_to_reference, ref_option,
    ref_option_ref, single_char_pattern, str_split_at_newline,
    string_add_assign, transmute_ptr_to_ptr, type_repetition_in_bounds

    Round 2 — added after auditing hit counts across the workspace:

    • Zero-hit future-guards: borrow_as_ptr, doc_link_with_quotes,
      expl_impl_clone_on_copy, inefficient_to_string, macro_use_imports,
      range_minus_one, rest_pat_in_fully_bound_structs,
      string_to_string, trait_duplication_in_bounds, unnecessary_join
    • Low-noise with fixes: bool_to_int_with_if, cast_lossless,
      equatable_if_let, needless_raw_string_hashes, redundant_else,
      string_add, unnested_or_patterns, unused_peekable

    Removed / deferred:

    • many_single_char_names — removed; only fired on idiomatic
      single-letter names in bench/test code (effectively all false positives)
    • must_use_candidate — tried it, then removed: it demands annotations
      stricter than std itself (std doesn't mark Vec::iter() etc.), and its
      heuristic misfired on dataflow-builder functions whose side effects are
      the point. Kept a curated set of 19 #[must_use]s on consuming
      builder setters (RustCrate::pin_to_core, TrybuildHost::tracing,
      MaelstromDeploy::node_count/rate/time_limit, SimFlow options,
      the NetworkingConfig transport/reliability chain, …) where dropping
      the return value silently discards configuration.
    • manual_assert_eq — commented out as TODO; requires clippy 1.97.0
    • dbg_macro, undocumented_unsafe_blocks — commented out as TODOs for
      follow-up

    Warning fixes (~350 warnings)

    Auto-fixed via cargo clippy --fix (all reviewed): doc_markdown
    backticks/<URL>s, _ → () for unit patterns, if cond { panic!() }
    → assert!(), char patterns, usize::from(..) instead of as casts /
    bool-to-int ifs, matches!(), nested or-patterns, redundant else
    removal, etc.

    dfir_lang codegen fixes — the most interesting finding: ~270
    warnings pointed at user call sites of source_stream,
    difference/anti_join, null, and source_stream_serde, but the
    offending patterns were in dfir_lang's generated code (which carries
    call-site spans). Fixed at the source so downstream users with these
    lints enabled won't see them either:

    • source_stream: PullStep::Ready(_, _) → PullStep::Ready(..)
    • anti_join/difference: |(k, _)| → |(k, _v)| (the _ matched
      () values)
    • null: allow ignored_unit_patterns on the generated let _ = (...)
    • source_stream_serde: nested the generated Poll::Ready(Some(Err(_))) | Poll::Ready(None) or-pattern

    Manual cleanups on top of the auto-fixes:

    • Rewrote De Morgan-ugly generated asserts (assert!(!(!a && !b))) into
      readable positive forms or if + assert! (FlowBuilder/handle drop
      guards, multiversioned network sends, recompilation checks, sim
      deterministic-hook checks)
    • Fixed doc comments the autofix mangled (merge_modules example is now
      a ```text block; GhtInner<GhtInner<GhtLeaf<...>>>;
      Rc<RefCell<Vec<T>>>) plus nearby typos and formatting not caught by
      the lint
    • type_repetition_in_bounds: merged duplicate where-clause predicates
      in lattices GHT and hydro_lang stream/keyed_singleton/networking
    • ignore_without_reason: maelstrom tests now ignore = "requires the Maelstrom binary (set the MAELSTROM_PATH env var)"
    • unused_peekable caught a genuinely unused .peekable() in
      hydro_lang ir/backtrace.rs
    • string_add: format!() / push('\n') rewrites (verified the
      q!-quoted maelstrom body isn't embedded in any snapshots)
    • String::new() in the no_std lattices test needed use alloc::string::String

    Verification

    • cargo clippy --workspace --all-targets — zero warnings
    • cargo +nightly fmt --all — clean
    • Test suites pass: lattices, dfir_lang, dfir_pipes, and dfir_rs
      (309 tests incl. compile-fail/trybuild and graphviz/mermaid snapshots)

Refactor

  • replace snapshot-only ticks with non-lazy inputs
    [ci-bench]

    Prepares for lazy snapshot ingress (#3270), under which a tick whose
    only inputs are snapshots
    / state (no batched-in stream) can never fire. Rewrites the
    snapshot-only ticks in hydro_lang and
    hydro_test so each tick is driven by a batched (non-lazy) input:

    • Stream::timeout: instead of snapshotting a fold of Instant::now()
      into a fresh tick, every
      batch of inputs arms a countdown (tokio::time::sleep(duration)
      resolved at the top level),
      tagged with a fresh epoch. A sliced! region batches the inputs and the
      expired countdowns and
      keeps the current epoch as state: a countdown whose epoch is still
      current (no newer input) is
      a timeout; stale countdowns are ignored; the next input clears it. No
      Instant reads in the
      tick. The countdown feedback into the slice is broken by a top-level
      defer_tick (added in
      the preceding revision). duration is now quoted in the top-level
      operator context, and
      L::DropConsistency: TopLevel is required.
    • map_reduce: the leader batches the partial counts into its tick and
      uses across_ticks
      (atomic reduce + snapshot back into the same tick) instead of
      snapshotting a top-level
      reduce into a fresh tick.
    • echo_server: the connection-count log batches a 1-second
      source_interval into the slice
      that snapshots the membership, instead of a snapshot-only slice followed
      by sample_every.

    Remaining snapshot-only ticks, still to do: bench_client's
    virtual-client spawner
    (new_payload_ids) and paxos_bench's checkpoint quorum.

    hydro_test IR snapshots updated (map_reduce, paxos). hydro_test: all
    tests pass.

Bug Fixes (BREAKING)

  • type source_interval AtLeastOnce, read the clock through use::time, and replace false manual_proof! commutativity claims with assume_ordering
    Rust-side changes that fell out of the Lean formalization of Hydro
    (hydro_lean/, a separate PR stacked on this one). Each item is a place
    where the types or a manual_proof! claimed something the program does
    not guarantee; the fix is to state the real nondeterminism with
    nondet! so it is visible to the type system and the simulator.

    source_interval is AtLeastOnce

    source_interval / source_interval_delayed
    (hydro_lang/src/location/mod.rs) now return Stream<(), _, Unbounded, TotalOrder, AtLeastOnce>. A timer's fires can repeat, and ExactlyOnce
    hid that from the types. Consumers that genuinely need ExactlyOnce say
    so with assume_retries and a nondet! reason.

    • sample_every's interval hook is typed BatchHook<(), TotalOrder, AtLeastOnce, _> accordingly (singleton.rs, stream/mod.rs).
    • raft keeps taking ExactlyOnce timer streams (its sim tests feed
      them from sim_input); the deployment wirings
      (hydro_test/examples/raft.rs, the raft_ir snapshot's create_raft)
      apply .assume_retries::<ExactlyOnce>(nondet!(…)) to
      source_interval's streams — a repeated fire is just another fire.
    • The simulator does not support batching an AtLeastOnce stream (its
      existing todo!), so source_interval stays unsupported in sim — as
      before, now visibly.

    Clock reads go through use::time

    • New use::time(nondet!(…)) sliced! style over
      Tick::current_tick_instant (sliced/style.rs).
    • Stream::timeout is rewritten over it: the latest-arrival register is
      stamped with the tick's clock reading, instead of an Instant::now()
      inside a fold closure.
    • hydro_std::bench_client: Instant::now() reads inside a fold
      closure and a map were wall-clock reads invisible to the types;
      replaced by use::time. The overwrite-reduce's commutative = manual_proof! becomes assume_ordering::<TotalOrder>(nondet!(/** one in flight per virtual client */)). The clock-reading functions are gated
      on the tokio feature.

    The Paxos recommit fold is not commutative

Commit Statistics

  • 3 commits contributed to the release.
  • 51 days passed between releases.
  • 3 commits were understood as conventional.
  • 3 unique issues were worked on: #3204, #3278, #3353

Commit Details

view details
  • #3204
    • Enable many new workspace clippy lints and fix all resulting warnings (aca1170)
  • #3278
    • Replace snapshot-only ticks with non-lazy inputs (3f8b82e)
  • #3353
    • Type source_interval AtLeastOnce, read the clock through use::time, and replace false manual_proof! commutativity claims with assume_ordering (cbd1438)