Files
replicate/tests/cpu-usage/README.md
zeekay a485f34a14 rebrand: complete litestream -> replicate rename
- All source files, configs, docs, CI renamed
- Binary: replicate (not litestream)
- Config: replicate.yml (litestream.yml as fallback)
- Env: REPLICATE_* (LITESTREAM_* as fallback)
- Socket: /var/run/replicate.sock
- Image: ghcr.io/hanzoai/replicate
- Module: github.com/hanzoai/replicate
- Package name: replicate (Go), replicate-vfs (npm/pip/gem)
- VFS: registered as "replicate", pragmas replicate_*
- C exports: ReplicateVFSRegister, GoReplicate*
- Windows service: Replicate
- Systemd unit: replicate.service
- Upstream attribution preserved (README, upgrade test scripts)
2026-04-09 18:03:37 -07:00

1.7 KiB

CPU Usage Testing

This directory contains test scripts and configurations for measuring Replicate's idle CPU usage, particularly for validating the fixes in issue #992.

Files

  • test-cpu-usage.sh - Automated CPU monitoring script
  • replicate-test-polling.yml - Config for testing with S3 replication

Prerequisites

  1. Build Replicate binary:

    cd ../..
    go build -o bin/replicate ./cmd/replicate
    
  2. Set up AWS credentials in .envrc at repo root:

    export AWS_ACCESS_KEY_ID="your-key-id"
    export AWS_SECRET_ACCESS_KEY="your-secret-key"
    export AWS_REGION="us-east-2"
    export S3_BUCKET="your-test-bucket"
    
  3. Have sqlite3 CLI installed

Usage

From this directory, run:

# Test for 60 seconds
./test-cpu-usage.sh 60

# Longer test (5 minutes)
./test-cpu-usage.sh 300

What It Tests

The script:

  1. Creates a test SQLite database at /tmp/test.db
  2. Starts Replicate with S3 replication
  3. Monitors CPU usage every second using ps
  4. Calculates average CPU usage
  5. Verifies S3 replication is working
  6. Outputs results and detailed CSV log

Expected Results

Based on testing for PR #993:

  • With S3 transport fix: ~0.0067% CPU (99% improvement)
  • Original (v0.5.6): ~0.7% CPU

The S3 transport fix achieves near-zero idle CPU usage, validating the fix.

Output

Results are printed to stdout and detailed logs are saved to:

  • /tmp/replicate-cpu-log.csv - Per-second CPU measurements

Notes

  • Tests require real S3 credentials and will upload data to your bucket
  • Test database is created at /tmp/test.db and cleaned up on each run
  • CPU measurements are instantaneous snapshots, not averages over intervals
  • Longer test durations (5-10 minutes) provide more stable averages