Every tracked file that can carry a comment (880 of them) now opens with "Author: Guoliang Chen, a Senior Digital Design Engineer" and closes with "Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com", in the file's own comment syntax. No behaviour change: the diff outside the version bump and changelogs is comment lines only. - tools/stamp_author.py: writes the lines; idempotent, `--check` lists what is missing. Headers go under a shebang and under Markdown front matter. - Left alone: test fixtures, cases and snapshots (byte-exact inputs), JSON and JSONL, logs, images, lockfiles, docs/site/dist (regenerated) and the LICENSE files (already carry the copyright line). - tools/linux_check.sh: --help reads its header from line 3, now that the author line sits under the shebang. - tools/gates.sh green on this tree: 5 545 tests, corpus 814/6 as before. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
44 lines
1.8 KiB
Rust
44 lines
1.8 KiB
Rust
// Author: Guoliang Chen, a Senior Digital Design Engineer
|
|
|
|
//! How much parsing this thread has done — a work counter, not a timer.
|
|
//!
|
|
//! A `textDocument/codeAction` used to parse the same buffer five times, and
|
|
//! the only honest way to prove that it no longer does is to count the parses
|
|
//! rather than to time them (take 5 §P1,
|
|
//! `docs/features/perf5-p1/README.md`). A stopwatch assertion on a 1.3 MB
|
|
//! buffer is a flake; a count is not.
|
|
//!
|
|
//! **Per thread, deliberately.** A process-wide counter would be unusable as
|
|
//! an assertion, because `cargo test` runs tests in parallel and every other
|
|
//! test in the binary would be adding to it; and it would answer the wrong
|
|
//! question anyway, since what a caller wants to know is what *this* request
|
|
//! did. A request is answered on one thread, so a thread-local count is that
|
|
//! number exactly. It costs one non-atomic add per whole-file parse.
|
|
|
|
use std::cell::Cell;
|
|
|
|
thread_local! {
|
|
static PARSES: Cell<u64> = const { Cell::new(0) };
|
|
}
|
|
|
|
/// How many whole-file parses this thread has run.
|
|
///
|
|
/// Counted in [`crate::parse`] and [`crate::parse_tolerant`], which is every
|
|
/// way a whole file is parsed: [`crate::parse_source`] and
|
|
/// [`crate::parse_source_tolerant`] both funnel through them. A *lex* failure
|
|
/// parses nothing and is not counted; neither is a fragment read (macro
|
|
/// expansion), which re-reads a token slice rather than a file.
|
|
///
|
|
/// The count is monotone and never reset, so a caller measures a *delta*
|
|
/// across the work it is asking about.
|
|
pub fn parses() -> u64 {
|
|
PARSES.with(Cell::get)
|
|
}
|
|
|
|
/// Count one whole-file parse.
|
|
pub(crate) fn count_parse() {
|
|
PARSES.with(|parses| parses.set(parses.get() + 1));
|
|
}
|
|
|
|
// Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
|