Skip to content

perf: harmonize residual direct file reads to cache-first read_file_content (Wave Z)#2282

Merged
hahwul merged 1 commit into
mainfrom
perf/analyzer-cache-first-sweep
Jul 11, 2026
Merged

perf: harmonize residual direct file reads to cache-first read_file_content (Wave Z)#2282
hahwul merged 1 commit into
mainfrom
perf/analyzer-cache-first-sweep

Conversation

@hahwul

@hahwul hahwul commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

Final pass of the analyzer performance sweep (follows #2258). A whole-tree regression re-grep across src/analyzer/analyzers/ confirmed no reintroduced interpolated-regex-in-loop (the one remaining dynamic-name .match in tornado.cr is guarded by starts_with? + returns on first match — the sanctioned low-cardinality pattern). It surfaced the last residual direct-disk reads that the per-file "apply the first tier only" discipline skipped on files that already received a Tier-A/B fix:

file site change
scala/zio_http.cr / akka.cr / tapir.cr / scalatra.cr analyze_file (+ scalatra build_mount_prefixes) File.read(path)read_file_content(path) (identical to the http4s swap in #2260)
java/dropwizard.cr read_path_config YAML.parse(File.read(path))read_file_content
kotlin/spring.cr read_properties File.each_line(path)read_file_content(path).each_line

read_file_content returns the detector-populated cache when present (skipping a redundant disk read) and otherwise falls back to File.read(..., encoding: "utf-8", invalid: :skip). Byte-identical on all valid UTF-8 (every fixture passes) and aligns invalid-byte handling with the rest of the codebase.

Left as-is: crystal/kemal.cr's File.read_lines (no encoding arg) — swapping would change invalid-UTF-8 handling, so it's not a detection-neutral swap.

Test plan

  • scala + java + kotlin functional specs → 3221 examples, 0 failures.
  • Full just test3681 unit + 20967 functional, 0 failures.
  • crystal tool format --check clean; ameba → 6 inspected, 0 failures; typos clean.

Co-authored-by: ksg97031 ksg97031@gmail.com

…ontent

The whole-tree Wave-Z regression re-grep confirmed no reintroduced
interpolated-regex-in-loop (the one remaining dynamic-name match in
tornado is guarded by a `starts_with?` and returns on first match — the
sanctioned low-cardinality pattern). It did surface the last residual
direct-disk reads that the per-file "apply the first tier only" sweep
discipline skipped on files that already got a Tier-A/B fix:

- scala/{zio_http,akka,tapir,scalatra}.cr `analyze_file` (+ scalatra's
  `build_mount_prefixes`) read via bare `File.read(path)` — identical to
  the http4s case already swapped in #2260.
- java/dropwizard.cr `read_path_config` read config yaml via `File.read`.
- kotlin/spring.cr `read_properties` read via `File.each_line`.

All routed through the base-class `read_file_content`, which returns the
detector-populated cache when present (skipping a redundant disk read)
and otherwise falls back to `File.read(..., encoding: "utf-8",
invalid: :skip)`. Byte-identical on all valid UTF-8 (every fixture
passes) and aligns invalid-byte handling with the rest of the codebase.

Left as-is: crystal/kemal.cr's `File.read_lines` (no encoding arg) —
swapping it would change invalid-UTF-8 handling, so it is not a
detection-neutral swap (tracked separately).

Detection-neutral: full suite 3681 unit + 20967 functional, 0 failures.

Co-authored-by: ksg97031 <ksg97031@gmail.com>
@hahwul hahwul merged commit 3b7461c into main Jul 11, 2026
@hahwul hahwul deleted the perf/analyzer-cache-first-sweep branch July 11, 2026 12:52
@github-actions github-actions Bot added the 🔬 analyzer Issue for Analyzer label Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔬 analyzer Issue for Analyzer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant