Rename the tool to lucisv (Language Utility for Coding In SystemVerilog)
This commit is contained in:
1 parent
a284e33110
commit
eeaffafd56
188 files changed
+2825
-2802
No files matched your search
@@ -2,11 +2,11 @@
|
||||
|
||||
## Goal
|
||||
|
||||
Make `vfmt` format a whole RTL tree on all cores instead of one, and stop
|
||||
Make `lucisv` format a whole RTL tree on all cores instead of one, and stop
|
||||
walking into directories the repository already declares generated. Two
|
||||
`TODO.md` §3 items in one change, because they touch the same loop:
|
||||
formatting is a pure function of `(source, config)`, so the per-file loop in
|
||||
`crates/vfmt/src/main.rs` parallelises with `rayon::par_iter` once panic
|
||||
`crates/lucisv/src/main.rs` parallelises with `rayon::par_iter` once panic
|
||||
containment and output ordering are reworked for concurrency; and
|
||||
`.gitignore` support is the other half of the file-discovery item whose
|
||||
`--exclude` half already shipped with cli-polish. The user-visible contract
|
||||
@@ -27,7 +27,7 @@ same invocation, regardless of thread count.
|
||||
therefore produce byte-identical stdout and stderr.
|
||||
- **Output is buffered until the run ends.** The price of ordered reporting is
|
||||
that `--diff` / `--stdout` text is held in memory until every file is done,
|
||||
rather than streaming. For the sizes vfmt targets (a large RTL tree is tens
|
||||
rather than streaming. For the sizes lucisv targets (a large RTL tree is tens
|
||||
of MiB of source) this is acceptable; it is the reason `--stdout` over a
|
||||
huge tree is no longer incremental.
|
||||
- **8 MiB of worker stack is enough.** Taken from
|
||||
@@ -86,7 +86,7 @@ literally or as plain `*`, they are not errors):
|
||||
space).
|
||||
- The global ignore file (`core.excludesFile`), `.git/info/exclude`, and
|
||||
`$GIT_DIR/info/exclude`.
|
||||
- Git's "already-tracked files are not ignored" rule: vfmt has no index, so
|
||||
- Git's "already-tracked files are not ignored" rule: lucisv has no index, so
|
||||
a tracked file matching an ignore rule *is* skipped.
|
||||
- Re-including a path inside an ignored directory. An ignored directory is
|
||||
never descended into, so a `!` rule underneath it cannot bring anything
|
||||
@@ -142,13 +142,13 @@ A path named directly on the command line is never ignored, exactly as with
|
||||
|
||||
CLAUDE.md requires a written justification for every dependency; `TODO.md` §3
|
||||
pre-sanctions this one by name. It is the workspace's first third-party
|
||||
dependency, and `vfmt`'s only one.
|
||||
dependency, and `lucisv`'s only one.
|
||||
|
||||
**Why not hand-rolled threads.** The obvious alternative is *N* `std::thread`s
|
||||
each draining a shared `Mutex<vec::IntoIter>`, about 30 lines. Three things
|
||||
make that the worse choice here:
|
||||
|
||||
1. **Work stealing.** vfmt's per-file cost varies by two orders of magnitude
|
||||
1. **Work stealing.** lucisv's per-file cost varies by two orders of magnitude
|
||||
(a 20-line header vs. a 10 000-line generated netlist). A static chunking
|
||||
leaves cores idle behind one slow file; a shared-queue design fixes that
|
||||
but then contends on the mutex for short files. rayon's per-worker deques
|
||||
@@ -156,7 +156,7 @@ make that the worse choice here:
|
||||
2. **Panic propagation.** A panic on a hand-rolled worker either poisons the
|
||||
shared mutex or is silently swallowed by a detached `JoinHandle`. rayon
|
||||
propagates a worker panic to the thread that called `par_iter` — which
|
||||
matters because vfmt's own containment (`catch_panic`) is the *inner*
|
||||
matters because lucisv's own containment (`catch_panic`) is the *inner*
|
||||
layer, and anything that escapes it must still surface as a crash rather
|
||||
than as a quietly missing file.
|
||||
3. **Maintenance.** Thread count, stack size, worker naming, and clean
|
||||
@@ -166,10 +166,10 @@ make that the worse choice here:
|
||||
|
||||
**Cost.** Five transitive crates (`rayon-core`, `crossbeam-deque`,
|
||||
`crossbeam-epoch`, `crossbeam-utils`, `either`), all from the same
|
||||
well-maintained ecosystem, no build scripts, no `unsafe` in vfmt itself, and
|
||||
well-maintained ecosystem, no build scripts, no `unsafe` in lucisv itself, and
|
||||
~9 s of cold release compile time. The version is pinned with `=` rather than
|
||||
a caret: a work-stealing scheduler is exactly the kind of dependency whose
|
||||
minor releases can change thread behavior, and vfmt's determinism claim is
|
||||
minor releases can change thread behavior, and lucisv's determinism claim is
|
||||
worth an explicit bump.
|
||||
|
||||
## Work log
|
||||
@@ -178,7 +178,7 @@ worth an explicit bump.
|
||||
|
||||
- Read CLAUDE.md, `TODO.md` §3, `docs/features/cli-polish/README.md`
|
||||
(the panic-hook handshake), `docs/features/recursion-limit/README.md`
|
||||
(Handshakes: the 8 MiB request) and all of `crates/vfmt/src` before
|
||||
(Handshakes: the 8 MiB request) and all of `crates/lucisv/src` before
|
||||
writing anything.
|
||||
- **Blocked on the workspace for most of the run.** Another agent was
|
||||
mid-flight creating `crates/vlog_semantic`; its `Cargo.toml` was in the
|
||||
@@ -225,7 +225,7 @@ parallel iterator, so the collect restores input order; `run_files` then
|
||||
walks that vector serially, printing and counting. Diff hunks and error
|
||||
lines therefore cannot interleave, and the summary counters are derived
|
||||
from the ordered vector rather than from shared counters. Verified at
|
||||
corpus scale: `vfmt --diff` over the 860-file corpus produces 2 424 208
|
||||
corpus scale: `lucisv --diff` over the 860-file corpus produces 2 424 208
|
||||
bytes of stdout and 66 019 bytes of stderr that are **byte-identical**
|
||||
across `--threads 1`, `2`, `8`, the default, and a repeat run.
|
||||
|
||||
@@ -271,7 +271,7 @@ one" and "the last line in a file wins" from one loop.
|
||||
expectations: a scratchpad `git init` tree with a root `.gitignore`
|
||||
(`build/`, `*_gen.sv`, `/anchored.sv`, `gen/rtl`, `sub/*.sv`, a comment) and
|
||||
a nested `sub/.gitignore` (`!keep_gen.sv`, `drop.sv`) over 13 `.sv` files.
|
||||
`git check-ignore` and vfmt agree on **every** file.
|
||||
`git check-ignore` and lucisv agree on **every** file.
|
||||
|
||||
On the real corpus (28 `.gitignore` files across ibex, OpenTitan, PULP
|
||||
common_cells and picorv32) the honoured rules change nothing: the same 860
|
||||
@@ -325,7 +325,7 @@ accurately; nothing fabricated. Did not touch `crates/vlog_semantic`
|
||||
`a_deeply_nested_file_formats_on_a_worker_thread` — it fails with the
|
||||
child process losing its exit code entirely (`panicked at
|
||||
cli.rs:81:23: exit code`), i.e. a hard crash, not a graceful error;
|
||||
restored the file and confirmed `git diff crates/vfmt/src/main.rs`
|
||||
restored the file and confirmed `git diff crates/lucisv/src/main.rs`
|
||||
byte-identical to before the experiment (`diff` of the two captured
|
||||
diffs was empty). **Pass.**
|
||||
2. **Hook.** Single `Once`-guarded `install_panic_hook` (`main.rs:266`);
|
||||
@@ -342,7 +342,7 @@ accurately; nothing fabricated. Did not touch `crates/vlog_semantic`
|
||||
scratchpad build: it still prints the full `thread 'main' panicked at
|
||||
… note: run with RUST_BACKTRACE=1`, exit 101 — the default hook is
|
||||
intact for real bugs. **Pass.**
|
||||
3. **Determinism.** Ran `vfmt --diff` over the full 860-file corpus (not
|
||||
3. **Determinism.** Ran `lucisv --diff` over the full 860-file corpus (not
|
||||
just ~100) at `--threads` 1/2/8/default, 3 repeats each (12 runs) plus 2
|
||||
more default-thread repeats (5 total for that setting): stdout hashes to
|
||||
one value across all 12, stderr to one value across all 12 —
|
||||
@@ -357,15 +357,15 @@ accurately; nothing fabricated. Did not touch `crates/vlog_semantic`
|
||||
(`scratchpad/gitprobe/`) covering all four requested tricky cases plus
|
||||
extras: a `!secret.sv` inside `build/` (ignored by the parent `build/`
|
||||
rule — git prunes the directory before reading its `.gitignore`, and so
|
||||
does vfmt); `/x.sv` anchored inside a *nested* `anchor_test/.gitignore`
|
||||
does lucisv); `/x.sv` anchored inside a *nested* `anchor_test/.gitignore`
|
||||
(correctly scoped to that directory only, not its `sub2/`); `!keepdir/`
|
||||
negating a directory while `*.sv` still catches the file inside it
|
||||
(git: ignored; vfmt: ignored — negating the directory doesn't negate the
|
||||
(git: ignored; lucisv: ignored — negating the directory doesn't negate the
|
||||
per-file pattern); and the `build/` vs. bare `build` directory-only
|
||||
distinction (already covered by the existing unit test
|
||||
`a_trailing_slash_matches_directories_only`, confirmed still green).
|
||||
Ran `git check-ignore -q` against every `.sv` file in the tree, compared
|
||||
to which files vfmt actually visited (16 files, 6 not ignored) —
|
||||
to which files lucisv actually visited (16 files, 6 not ignored) —
|
||||
**exact agreement, 0 discrepancies.** Corpus visited-set check: `--diff`
|
||||
with and without `--no-gitignore` over the real 860-file corpus (28
|
||||
`.gitignore` files) produced byte-identical stdout and stderr, matching
|
||||
@@ -377,15 +377,15 @@ accurately; nothing fabricated. Did not touch `crates/vlog_semantic`
|
||||
(extensions: v, sv, vh, svh)`, exit 2 — sane, and `--no-gitignore`
|
||||
recovers the files as expected. `.gitignore` + `--exclude` together:
|
||||
both apply simultaneously (verified with one pattern from each). **Pass.**
|
||||
5. **Deps.** `cargo tree -p vfmt` shows exactly `rayon` → `either`,
|
||||
5. **Deps.** `cargo tree -p lucisv` shows exactly `rayon` → `either`,
|
||||
`rayon-core` → `crossbeam-deque` → `crossbeam-epoch`/`crossbeam-utils`
|
||||
(5 transitive crates as documented); `cargo metadata` confirms none of
|
||||
the six packages (rayon included) declare a build script. `rayon` is
|
||||
pinned `=1.12.0` in both `Cargo.toml` and `Cargo.lock`. Justification
|
||||
section present and specific. **Pass.**
|
||||
6. **Tools.** `cargo test -p vfmt`: 50 unit + 30 CLI, all green (0.01s +
|
||||
0.14–0.21s). `cargo clippy -p vfmt --all-targets` and
|
||||
`cargo fmt -p vfmt -- --check`: both silent/clean. Workspace-wide (now
|
||||
6. **Tools.** `cargo test -p lucisv`: 50 unit + 30 CLI, all green (0.01s +
|
||||
0.14–0.21s). `cargo clippy -p lucisv --all-targets` and
|
||||
`cargo fmt -p lucisv -- --check`: both silent/clean. Workspace-wide (now
|
||||
that `vlog_semantic` compiles): `cargo build --workspace`,
|
||||
`cargo clippy --workspace --all-targets` clean, `cargo test --workspace`
|
||||
green across all crates. Note: workspace-wide `cargo fmt --check` is
|
||||
@@ -427,7 +427,7 @@ accurately; nothing fabricated. Did not touch `crates/vlog_semantic`
|
||||
(error outranks would-reformat), no interleaving.
|
||||
|
||||
**One methodology note, not a product finding:** immediately after the
|
||||
`WORKER_STACK` sabotage-and-restore in item 1, `cargo build -p vfmt`
|
||||
`WORKER_STACK` sabotage-and-restore in item 1, `cargo build -p lucisv`
|
||||
reported "Finished in 0.01s" and silently kept serving the *stale* 2 MiB
|
||||
binary — restoring the file with `mv` from a `sed -i.bak` backup left its
|
||||
mtime older than the already-rebuilt (sabotaged) target, so Cargo's
|
||||
@@ -435,18 +435,18 @@ mtime fast-path skipped recompilation despite the content being back to
|
||||
the original 8 MiB source. This briefly made `cargo test --workspace`
|
||||
report `a_deeply_nested_file_formats_on_a_worker_thread` and
|
||||
`deeply_nested_file_does_not_kill_the_batch` as crashing. `touch`ing
|
||||
`crates/vfmt/src/main.rs` and rebuilding made both pass again immediately,
|
||||
`crates/lucisv/src/main.rs` and rebuilding made both pass again immediately,
|
||||
and `git diff` on the file was unaffected throughout (content never
|
||||
changed). Recorded here in case anyone else sees the same thing after a
|
||||
`sed -i.bak` / `mv` round-trip on this codebase — it is a Cargo caching
|
||||
quirk local to that workflow, not a vfmt bug.
|
||||
quirk local to that workflow, not a lucisv bug.
|
||||
|
||||
**Severity summary:** no BLOCKING findings (zero nondeterminism observed
|
||||
across ~40 varied repeated runs), no should-fix gitignore/git
|
||||
disagreements (0 of many probe files disagreed). CLAUDE.md compliance:
|
||||
no `unwrap`/`expect`/`panic!` in library code paths in `main.rs`/`args.rs`/
|
||||
`walk.rs` outside `#[cfg(test)]` (grepped directly); all `pub` items carry
|
||||
a one-line doc comment; feature stayed inside `crates/vfmt` +
|
||||
a one-line doc comment; feature stayed inside `crates/lucisv` +
|
||||
`docs/features/parallel-files` as scoped, confirmed via `git status`/`git
|
||||
diff --stat` against `HEAD`. README.md and TODO.md claims read as
|
||||
accurate against what I independently measured.
|
||||
|
||||
Reference in new issue
Block a user