Skip to content

[feature] Performance optimizations and benchmark#70

Merged
StellaLupus merged 3 commits intomainfrom
fix/speed
Apr 21, 2026
Merged

[feature] Performance optimizations and benchmark#70
StellaLupus merged 3 commits intomainfrom
fix/speed

Conversation

@StellaLupus
Copy link
Copy Markdown
Collaborator

  • KotlinEngine: pre-compile regex patterns once at init instead of per scan (~46% faster)
  • Matchers: move per-call regex/list constructions to object-level constants
  • CardBins: List -> Set for O(1) BIN lookup
  • HyperScanEngine: drop unnecessary toMutableList() conversion
  • Add BenchmarkTest covering scan throughput, init speed and match consistency
  • CI: post benchmark results as PR comment via actions/github-script

- KotlinEngine: pre-compile regex patterns once at init instead of per scan (~46% faster)
- Matchers: move per-call regex/list constructions to object-level constants
- CardBins: List -> Set for O(1) BIN lookup
- HyperScanEngine: drop unnecessary toMutableList() conversion
- Add BenchmarkTest covering scan throughput, init speed and match consistency
- CI: post benchmark results as PR comment via actions/github-script
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 15, 2026

Benchmark Results

Scan Throughput

Corpus: testText.txt × 250 ≈ 354 KB | Matchers: 65 | Warmup: 5 | Iterations: 20

Engine mean p50 σ Throughput Matches/iter
KotlinEngine 2955.0 ms 2948.2 20.9 0.12 MB/s 10500
HyperScanEngine 140.8 ms 140.5 3.7 2.46 MB/s 10500
HyperScan(preload) 140.0 ms 140.9 2.7 2.47 MB/s 10500

Init Speed

Matchers: 65 | Warmup: 1 | Iterations: 5

Engine mean p50 min max σ
KotlinEngine 6.5 ms 5.5 4.7 9.9 1.9
HyperScanEngine 17975.9 ms 18004.0 17782.1 18139.1 140.6
HyperScan(preload) 104.2 ms 103.8 101.9 107.9 2.0

Pre-compiled DB speedup: 172.6x

Match Consistency (testText.txt)

Engine Matches
KotlinEngine 42
HyperScanEngine 42
HyperScan(preload) 42

equal | preload matches compile

volchara added 2 commits April 15, 2026 18:24
…tabase

Avoid expensive regex compilation on startup by allowing the engine to
save and load a compiled Hyperscan database (ByteArray, InputStream, File).
A SHA-256 manifest ensures strict matcher/config compatibility on load.
Benchmarks show ~192x init speedup with identical scan results.

Made-with: Cursor
@github-actions
Copy link
Copy Markdown

✅ SNAPSHOT published.

Published version: 1.5.0-SNAPSHOT

Gradle:

dependencies { implementation("org.angryscan:core:1.5.0-SNAPSHOT") }

Maven:

<dependency>
  <groupId>org.angryscan</groupId>
  <artifactId>core</artifactId>
  <version>1.5.0-SNAPSHOT</version>
</dependency>

Commit: 2a9a4dfb21fa71d18a1db7f51787a6120fce4cd7

@StellaLupus StellaLupus requested a review from gammmaaaa April 21, 2026 12:12
@StellaLupus StellaLupus self-assigned this Apr 21, 2026
@StellaLupus StellaLupus merged commit 4a01120 into main Apr 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants