Repository navigation
#1488 winux-regex fast-path - #1615
Merged
Merged
Conversation
…st (winx#1488, #1531) Port of the C++ engine's compile-time prefilters (regex.cppm Pattern::fast_ / build_fast_path — the kwset/dfa "must" analysis precedent of #1531) to rust2/crates/winux-regex: - anchored: first consumable element is `^` -> single attempt at 0, none when start > 0 (AnchorStart compares absolute positions). - prefix: required literal prefix (Literal runs, single-member classes, {m} literal expansions, zero-width assertions transparent) -> memchr-style candidate jumps; the interpreter still validates every candidate through the unchanged local_attempt path. - first: 256-byte first-byte set expanded per byte through the engine's own class_matches/fold rule (single source of truth, matcher's rule hoisted to a pub(crate) fn); legacy advance rule kept, only the futile attempts are skipped. - pure_literal: whole tree Literal-only with no captures -> a prefix candidate IS the match, byte-for-byte the interpreter's result. - Unmodeled shapes fall back to the legacy scan; a continuation-range prefix first byte is rejected in build (candidates would sit on positions the legacy traversal never attempts). Necessary conditions only — no semantic fork (#1550 lesson). Correctness gates: the #1603 138-row GNU grep -o matrix is byte-identical to the pre-change baseline in BOTH feature modes; new tests/fastpath_equiv.rs (hand corpus per tier + 120k-seed deterministic fuzz) requires fast vs disable_fast_path equality across checked_find / checked_match / find_all / matches_entire, WorkLimit surfaced identically. The filters live behind the default `fast-path` feature plus a doc(hidden) disable_fast_path() knob for A/B diffing. Performance (47 MiB / 819k lines, release, #1531 shape): grep -c fox 9.713s -> 57.979ms (167x); first-tier (f|F)(o|O)(x|X) 16.726s -> 405ms (41x); dot-head fallback control unchanged (~1% noise); pathological (.*)*b and \(.*\)*b long lines stay WorkLimit-bounded in both modes (75-80s, unchanged) — the #1603 caps are untouched.
…robust unit tests (Refs #1602) The rust-tests job (added in d2ee03f) is the first CI surface where symlinks can actually be created (hosted runneradmin has the symlink privilege; dev hosts soft-skip the guarded tests), so five winux-cmds lib tests failed there while passing locally: - fs_win::create_symlink absolutized the symlink TARGET through api_path (ctx.cwd.join), baking an absolute path into the reparse point where GNU symlink(2) and the 1.x pipeline (src/utils/win32.cppm win32_normalize_symlink_target: '/'->'\' only, "store the user-visible link text unchanged") keep the given text verbatim. ln -s tgt sl then failed readlink == "tgt" on CI. The LINK operand keeps api_path. - fs_win::file_meta's CreateFileW path missed the lstat symlink size fixup (st_size = target-path byte length; #1310 contract, already present in the find_first_meta fallback), so stat %s on a symlink reported 0 instead of len(target) on NTFS reparse points. - canon dangling test asserted !r.contains("dang") but the scratch dir itself is named canon-dang-*, tripping the check on symlink-capable hosts; now checks the link name per path component only. - chown from_filter hardcoded --from Administrators for the no-match case, but elevated hosts (CI runner) create files owned by the Administrators group, so it matched and -v printed; the no-match account is now picked against the actual owner name. - nice no_command_prints_niceness assumed the process runs at NORMAL; hosted runners spawn processes BELOW_NORMAL and children inherit the class (actions/runner-images#7663), so nice correctly printed 10; the test now normalizes its own priority class first. Verification: cargo test --locked -p winux-cmds --lib 577 passed on the branch tip (dev host, symlink-guarded tests soft-skip); CI rust-tests is the oracle for the symlink-capable path.
…efs #1602) Follow-up to 2ad7639: the verbatim-target change kept the drive-dialect fold out of the reparse point, breaking ctest ln.ln_symlink_drive_dialect_lands_on_operand_drive — "ln -s /c/Users/... link" stored the literal POSIX spelling, which no Windows path resolution can follow (a leading "/" resolves against the current drive root), so reading through the link returned empty. create_symlink now folds the target through winux_core::path::normalize_operand before the '/'->'\' reparse fold (#1101): the drive-dialect fold maps "/c/x" to "C:\x" (lands on the operand drive), shell-tree spellings map through the env, and relative plus already-native spellings are identity, so they keep the GNU-verbatim text. The LINK operand keeps api_path. Verification: cargo test --locked -p winux-cmds --lib 577 passed; the ctest expectation is CI-covered (symlink privilege).
aphrody-labs Bot
pushed a commit
to aphrody-labs/WinuxCmd
that referenced
this pull request
Nov 15, 2026
…xwin#1607 The behavioral fix (per-component link-name check instead of a contains("dang") substring assert, which matched the canon-dang-* scratch dir itself) already landed on master via 2ad7639 (PR unixwin#1615); the issue stayed open because nothing referenced it. Pins the tracker link on the owning test. No behavior change.
aphrody-labs Bot
pushed a commit
to aphrody-labs/WinuxCmd
that referenced
this pull request
Nov 15, 2026
…xwin#1608 The behavioral fix (pick the no-match --from account against the actual file owner instead of hardcoding Administrators, which owns the files on elevated CI runners) already landed via 2ad7639 (PR unixwin#1615); pins the tracker link on the owning test. No behavior change.
aphrody-labs Bot
pushed a commit
to aphrody-labs/WinuxCmd
that referenced
this pull request
Nov 15, 2026
…win#1609 The behavioral fix (TARGET keeps the operand text verbatim through normalize_operand + the '/'->'\' reparse fold — identity for relative spellings, drive-dialect fold for /c/x — while the LINK operand keeps api_path) already landed via 2ad7639 + 305b056 (PR unixwin#1615); pins the tracker link on the owning function. No behavior change. The -r path (ln.rs relative_target -> create_symlink) is covered by the ln relative_requires_symbolic -rs probe, which runs privileged on CI rust-tests (green on master).
aphrody-labs Bot
pushed a commit
to aphrody-labs/WinuxCmd
that referenced
this pull request
Nov 15, 2026
…in#1610 The behavioral fix (SetPriorityClass(NORMAL) before asserting the niceness, since hosted runners spawn BELOW_NORMAL and children inherit the class) already landed via 2ad7639 (PR unixwin#1615); pins the tracker link on the owning test. No behavior change.
aphrody-labs Bot
pushed a commit
to aphrody-labs/WinuxCmd
that referenced
this pull request
Nov 15, 2026
…unixwin#1611 The behavioral fix (stat %s on a symlink = target-path byte length on the CreateFileW main path; the find_first_meta fallback already had it) already landed via 2ad7639 (PR unixwin#1615); pins the tracker link on the owning function. No behavior change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ports the #1531-class literal pre-filter (C++ precedent:
src/utils/regex.cppmPattern::fast_/build_fast_path, kwset/dfa "must"-analysis style) to the rust2winux-regexengine. Four compile-time necessary conditions, all computed from the same parsed node tree the interpreter runs — no text-layer re-lexing (#117):^→ single attempt at position 0 (none whenstart > 0).{m}literal expansions, zero-width assertions transparent) → memchr-style candidate jumps; the interpreter still validates every candidate through the unchangedlocal_attemptpath.class_matches/fold rule (hoisted to apub(crate)free fn so the sets cannot drift from the matcher); legacy advance rule kept, only futile attempts skipped.Unmodeled shapes fall back to the legacy scan; a continuation-range prefix first byte is rejected in
build(candidates would sit on positions the legacy traversal never attempts — the regex.cppm rule). Necessary conditions only, no semantic fork (#1550 lesson). New code:rust2/crates/winux-regex/src/fastpath.rs; integration:checked_find_at_bytes/checked_match_at_bytes/matches_entire_bytes(find_allderives). Filters sit behind the defaultfast-pathcargo feature plus a#[doc(hidden)] disable_fast_path()knob for A/B.Correctness (all gates green)
examples/matrix_harnessin BOTH modes (feature on /--no-default-features),cmpclean against output captured before the change.tests/fastpath_equiv.rs: per-tier hand corpus (UTF-8/continuation traps,-ifolding, raw bytes, caps) + 120k-case deterministic fuzz — fast vsdisable_fast_pathmust agree byte-for-byte acrosschecked_find_at_bytes/checked_match_at_bytes(every start offset) /find_all_bytes/matches_entire_bytes, WorkLimit included. Tier engagement itself pinned byfastpath.rsunit tests.Performance (
examples/fastpath_bench, release, 47 MiB / 819k lines — the #1531 shape)grep -c fox(prefix/pure-literal tier)grep -c (f|F)(o|O)(x|X)(first tier).{2}foxfallback control(.*)*b4096-byte line\(.*\)*b4096-byte lineCounts match in every pair. The #1603 triple caps (StepBudget / visited / output) are untouched and still bound the pathological family; dot-head patterns keep the filter OFF by construction, so those numbers are structurally the same code in both modes.
Refs #1488, #1531, #1603. Lesson applied: #1550 (necessary conditions only), #117 (no text-layer fast path).