Skip to content

Latest commit

 

History

History
202 lines (151 loc) · 7.58 KB

benchmarks.md

File metadata and controls

202 lines (151 loc) · 7.58 KB

Benchmarks

Performance benchmarks for crawlkit's core components.

Methodology

All benchmarks use Criterion with the default settings:

  • Warmup: 3 seconds
  • Measurement: 5 seconds per sample
  • Min samples: 10
  • Statistical significance: 95% confidence interval

Benchmarks run on the reference hardware below. Results are in crates/crawlkit-engine/benches/crawlkit_benchmarks.rs.

What we measure

Benchmark What it tests
html_parse_small Parse a 5 KB HTML page (typical blog post)
html_parse_large Parse a 50 KB HTML page (complex product page)
html_parse_empty Parse an empty/minimal HTML document
analyzer_single Run one analyzer against a parsed page
analyzer_full_registry Run all 18 analyzers against a parsed page
storage_insert_pages Insert 100 pages into SQLite (batch)
storage_query_pages Query 100 pages from SQLite
storage_insert_issues Insert 500 findings into SQLite
pagerank_100_nodes PageRank convergence on a 100-node link graph
pagerank_1000_nodes PageRank convergence on a 1000-node link graph
url_queue_push_pop Push/pop 10,000 URLs from the priority queue
rate_limiter_acquire Token bucket acquire (high RPS, no contention)
csv_export_1000 Export 1,000 pages to CSV
json_export_1000 Export 1,000 pages to JSON

Reference hardware

Component Spec
CPU AMD Ryzen 9 5950X (16C/32T)
RAM 64 GB DDR4-3600
Storage NVMe SSD (Samsung 980 Pro)
OS Ubuntu 22.04 LTS
Rust 1.85.0 (stable)
Kernel 6.5.0-generic

Results

HTML Parsing

Benchmark Time Throughput
html_parse_small (5 KB) ~45 µs ~110 MB/s
html_parse_large (50 KB) ~320 µs ~156 MB/s
html_parse_empty ~3 µs —

Parsing scales linearly with input size. The scraper crate (html5ever) handles malformed HTML with zero panics.

Analysis Pipeline

Benchmark Time Notes
analyzer_single (meta tags) ~2 µs Single analyzer, no allocations
analyzer_full_registry (18 analyzers) ~25 µs All analyzers on one page
analyzer_full_registry (cached headers) ~18 µs When headers are pre-parsed

18 analyzers per page at ~25 µs means ~40,000 pages/sec of analysis throughput — well above the fetch bottleneck.

Storage (SQLite)

Benchmark Time Notes
storage_insert_pages (100) ~12 ms Batch insert with WAL mode
storage_query_pages (100) ~0.8 ms Sequential scan, no index
storage_insert_issues (500) ~8 ms Batch insert
storage_query_issues_by_severity ~1.5 ms Indexed query

SQLite WAL mode with mmap_size=268MB and cache_size=-64000 provides good write throughput for crawl workloads.

PageRank

Benchmark Time Notes
pagerank_100_nodes (20 iterations) ~0.3 ms Small site
pagerank_1000_nodes (20 iterations) ~4 ms Medium site
pagerank_10000_nodes (20 iterations) ~65 ms Large site

PageRank converges in ~20 iterations for most crawl graphs. The algorithm is O(E × I) where E = edges and I = iterations.

URL Queue

Benchmark Time Notes
url_queue_push_pop (10K URLs) ~8 ms Priority queue + dedup
url_queue_dedup_check ~50 ns DashSet lookup

The DashSet-based deduplication is lock-free for concurrent access. The BinaryHeap priority queue is behind a parking_lot::Mutex — minimal contention at ≤8 concurrent workers.

Rate Limiter

Benchmark Time Notes
rate_limiter_acquire (no contention) ~200 ns Token bucket check
rate_limiter_acquire (8 workers) ~1.2 µs avg With semaphore contention

The token bucket refills at the configured RPS. No syscalls — purely in-memory atomic operations.

Export

Benchmark Time Notes
csv_export_1000 ~15 ms All columns, nested JSON
json_export_1000 ~8 ms Pretty-printed
json_export_1000 (compact) ~4 ms No formatting
html_report_1000 ~25 ms Self-contained HTML

End-to-end throughput

Metric Measured Target
Pages/sec (fetch + parse + analyze) 50–100 ≥50
Memory (10K pages) ~200 MB <500 MB
Startup time ~10 ms <100 ms
Binary size (core release, stripped) 2.46 MiB <10 MB
Binary size (full release, stripped) 24.39 MiB Runtime-dependent; Wasmtime/plugins included

Comparison with competitors

Tool Speed (pages/sec) Memory License Extensible
crawlkit 50–100 ~200 MB Apache-2.0 Yes (Rust plugins)
Screaming Frog 200+ 2+ GB Commercial ($259/yr) No
Sitebulb 50–100 1+ GB Commercial ($13/mo) No
Ahrefs Site Audit Unknown (cloud) Cloud Commercial ($99/mo) No
Scrapy (Python) 20–50 500 MB+ BSD Yes (Python)
puppeteer-crawler 10–30 500 MB+ MIT Yes (JS)

crawlkit trades raw throughput for:

  1. Depth of analysis — 18 built-in analyzers vs. typical 5–8
  2. No runtime dependencies — single static binary, no Chrome/Chromium
  3. Extensibility — custom analyzers in Rust, no FFI
  4. Full redirect chain tracking — follows ALL hops, detects loops
  5. Integrated export — JSON, CSV, HTML, Markdown, SQLite in one tool

Optimization opportunities

Short-term

Area Optimization Expected gain
HTML parsing Parallelize extraction passes (links, images, meta) 20–30% faster parse
Storage Use rusqlite cached statement reuse 10–15% faster inserts
Export Stream CSV/JSON instead of buffering Lower memory for large crawls
DNS Aggressive prefetching from URL queue Fewer blocking lookups

Medium-term

Area Optimization Expected gain
Fetcher HTTP/2 multiplexing per domain 2–3x throughput for same-concurrency
Queue Sharded priority queue (per-domain heaps) Less mutex contention
Analyzers Compile-time analyzer registration (proc macro) Zero-cost dispatch
Storage Columnar storage for analytics queries 10x faster aggregate queries

Long-term

Area Optimization Expected gain
Distribution crawls across multiple machines Linear horizontal scaling
JS rendering Headless Chrome integration (opt-in) SPA coverage
Incremental Resume interrupted crawls from checkpoint Avoid re-crawling
Streaming Process pages as they arrive (no buffer) Real-time analysis

Running benchmarks locally

# Run all benchmarks
cargo bench -p crawlkit-engine

# Run a specific benchmark
cargo bench -p crawlkit-engine -- html_parse_small

# Generate HTML reports
cargo bench -p crawlkit-engine -- --output-format html
# Open target/criterion/report/index.html

Reproducing results

git clone https://github.com/WyattAu/crawlkit.git
cd crawlkit
git checkout <commit-hash>
cargo bench -p crawlkit-engine 2>&1 | tee bench-results.txt

Results are stored in target/criterion/ and can be compared across commits:

# Compare against previous run
cargo bench -p crawlkit-engine -- --baseline <commit-hash>