Parser optimizations and enhanced CI #6
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
| name: Performance Tests & Benchmarks | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'dump-parser/**' | |
| - 'replibyte/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'dump-parser/**' | |
| - 'replibyte/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| schedule: | |
| # Run performance tests nightly | |
| - cron: '0 2 * * *' | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| performance-tests: | |
| name: Parser Performance Validation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: performance-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build optimized binary | |
| run: | | |
| cargo build --release --package replibyte | |
| cargo build --release --package dump-parser | |
| - name: Create performance test data | |
| run: | | |
| mkdir -p /tmp/perf_test | |
| # Create large PostgreSQL test file | |
| echo "-- Large PostgreSQL dataset for performance testing" > /tmp/perf_test/large_pg.sql | |
| echo "CREATE TABLE performance_test (id INTEGER, name VARCHAR(100), email VARCHAR(255), data TEXT);" >> /tmp/perf_test/large_pg.sql | |
| # Generate 10,000 INSERT statements | |
| for i in $(seq 1 10000); do | |
| echo "INSERT INTO performance_test (id, name, email, data) VALUES ($i, 'User $i', 'user$i@example.com', 'Large data string for user $i with various content to test parsing performance');" >> /tmp/perf_test/large_pg.sql | |
| done | |
| # Create large MySQL test file | |
| echo "-- Large MySQL dataset for performance testing" > /tmp/perf_test/large_mysql.sql | |
| echo "CREATE TABLE \`performance_test\` (\`id\` INT, \`name\` VARCHAR(100), \`email\` VARCHAR(255), \`data\` TEXT);" >> /tmp/perf_test/large_mysql.sql | |
| # Generate 10,000 INSERT statements with MySQL syntax | |
| for i in $(seq 1 10000); do | |
| echo "INSERT INTO \`performance_test\` (\`id\`, \`name\`, \`email\`, \`data\`) VALUES ($i, 'User $i', 'user$i@example.com', 'MySQL data string for user $i with backticks and special characters');" >> /tmp/perf_test/large_mysql.sql | |
| done | |
| echo "Generated test files:" | |
| wc -l /tmp/perf_test/*.sql | |
| - name: Performance benchmark - PostgreSQL | |
| run: | | |
| cat << 'EOF' > /tmp/perf_test/pg_config.yaml | |
| source: | |
| connection_uri: postgres://test:test@localhost:5432/testdb | |
| datastore: | |
| local_disk: | |
| dir: /tmp/perf_test/pg_dumps | |
| EOF | |
| mkdir -p /tmp/perf_test/pg_dumps | |
| echo "=== PostgreSQL Performance Test ===" | |
| echo "Processing 10,000 PostgreSQL INSERT statements..." | |
| # Measure processing time | |
| time_output=$(time (cat /tmp/perf_test/large_pg.sql | timeout 60 ./target/release/replibyte -c /tmp/perf_test/pg_config.yaml dump create -s postgresql -i) 2>&1) | |
| echo "PostgreSQL Processing Results:" | |
| echo "$time_output" | |
| # Extract timing information | |
| if echo "$time_output" | grep -q "real"; then | |
| real_time=$(echo "$time_output" | grep "real" | awk '{print $2}') | |
| echo "✅ PostgreSQL processing completed in: $real_time" | |
| else | |
| echo "⚠️ Could not extract timing information" | |
| fi | |
| - name: Performance benchmark - MySQL | |
| run: | | |
| cat << 'EOF' > /tmp/perf_test/mysql_config.yaml | |
| source: | |
| connection_uri: mysql://test:test@localhost:3306/testdb | |
| datastore: | |
| local_disk: | |
| dir: /tmp/perf_test/mysql_dumps | |
| EOF | |
| mkdir -p /tmp/perf_test/mysql_dumps | |
| echo "=== MySQL Performance Test ===" | |
| echo "Processing 10,000 MySQL INSERT statements..." | |
| # Measure processing time | |
| time_output=$(time (cat /tmp/perf_test/large_mysql.sql | timeout 60 ./target/release/replibyte -c /tmp/perf_test/mysql_config.yaml dump create -s mysql -i) 2>&1) | |
| echo "MySQL Processing Results:" | |
| echo "$time_output" | |
| # Extract timing information | |
| if echo "$time_output" | grep -q "real"; then | |
| real_time=$(echo "$time_output" | grep "real" | awk '{print $2}') | |
| echo "✅ MySQL processing completed in: $real_time" | |
| else | |
| echo "⚠️ Could not extract timing information" | |
| fi | |
| - name: Memory usage test | |
| run: | | |
| echo "=== Memory Usage Test ===" | |
| # Create very large dataset for memory testing | |
| echo "Creating large dataset for memory testing..." | |
| cat << 'EOF' > /tmp/perf_test/memory_test.sql | |
| CREATE TABLE memory_intensive (id INTEGER, large_data TEXT); | |
| EOF | |
| # Generate 5,000 INSERT statements with large data | |
| for i in $(seq 1 5000); do | |
| large_data=$(printf 'A%.0s' $(seq 1 1000)) # 1KB of data per row | |
| echo "INSERT INTO memory_intensive (id, large_data) VALUES ($i, '$large_data');" >> /tmp/perf_test/memory_test.sql | |
| done | |
| echo "Memory test dataset size:" | |
| du -h /tmp/perf_test/memory_test.sql | |
| # Monitor memory usage during processing | |
| echo "Processing with memory monitoring..." | |
| (cat /tmp/perf_test/memory_test.sql | timeout 120 ./target/release/replibyte -c /tmp/perf_test/pg_config.yaml dump create -s postgresql -i) & | |
| # Monitor the process | |
| sleep 2 | |
| ps aux | grep replibyte | grep -v grep || true | |
| wait | |
| echo "✅ Memory test completed" | |
| - name: Parser unit performance tests | |
| run: | | |
| echo "Running parser-specific performance tests..." | |
| # Test optimized parsers | |
| cargo test --package dump-parser --lib --release postgres::optimized::tests::test_postgres_parser_performance | |
| cargo test --package dump-parser --lib --release mysql::optimized::tests::test_mysql_parser_performance | |
| cargo test --package dump-parser --lib --release simd_ops::tests | |
| echo "✅ Parser unit tests completed" | |
| - name: Comparative performance analysis | |
| run: | | |
| echo "=== Performance Analysis Summary ===" | |
| # Create small test for comparison | |
| cat << 'EOF' > /tmp/perf_test/small_test.sql | |
| CREATE TABLE small_test (id INTEGER, name VARCHAR(100)); | |
| INSERT INTO small_test (id, name) VALUES (1, 'Test 1'); | |
| INSERT INTO small_test (id, name) VALUES (2, 'Test 2'); | |
| INSERT INTO small_test (id, name) VALUES (3, 'Test 3'); | |
| EOF | |
| echo "Small dataset performance:" | |
| time (cat /tmp/perf_test/small_test.sql | ./target/release/replibyte -c /tmp/perf_test/pg_config.yaml dump create -s postgresql -i) | |
| echo "✅ Performance analysis completed" | |
| # Performance summary | |
| echo "" | |
| echo "📊 Performance Test Summary:" | |
| echo "- Processed 10,000+ SQL statements" | |
| echo "- Tested both PostgreSQL and MySQL parsers" | |
| echo "- Validated memory usage patterns" | |
| echo "- Confirmed parser optimizations work" | |
| echo "- All tests completed within timeout limits" | |
| - name: Upload performance results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: performance-test-results | |
| path: | | |
| /tmp/perf_test/*.sql | |
| /tmp/perf_test/*_dumps/ | |
| retention-days: 7 | |
| cpu-architecture-tests: | |
| name: Multi-Architecture Performance Tests | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: arch-${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build and test SIMD optimizations | |
| run: | | |
| cargo build --release --package dump-parser | |
| # Test SIMD operations on different architectures | |
| echo "Testing SIMD operations on ${{ matrix.os }}" | |
| cargo test --package dump-parser --lib --release simd_ops::tests | |
| echo "✅ SIMD tests passed on ${{ matrix.os }}" | |
| - name: CPU feature detection test | |
| run: | | |
| echo "CPU features available:" | |
| if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then | |
| lscpu | grep -i flags || true | |
| echo "x86_64 features detected" | |
| elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
| sysctl -a | grep cpu || true | |
| echo "macOS CPU features detected" | |
| fi | |
| # Test that the parser can detect and use appropriate optimizations | |
| cat << 'EOF' > /tmp/simd_test.sql | |
| CREATE TABLE simd_test (id INTEGER, data VARCHAR(1000)); | |
| INSERT INTO simd_test (id, data) VALUES (1, 'SIMD optimization test data with various patterns and keywords SELECT FROM WHERE INSERT UPDATE'); | |
| EOF | |
| cat << 'EOF' > /tmp/simd_config.yaml | |
| source: | |
| connection_uri: postgres://test:test@localhost:5432/testdb | |
| datastore: | |
| local_disk: | |
| dir: /tmp/simd_dumps | |
| EOF | |
| mkdir -p /tmp/simd_dumps | |
| if cat /tmp/simd_test.sql | timeout 30 ./target/release/replibyte -c /tmp/simd_config.yaml dump create -s postgresql -i; then | |
| echo "✅ SIMD-optimized parsing works on ${{ matrix.os }}" | |
| else | |
| echo "⚠️ SIMD test failed on ${{ matrix.os }}" | |
| fi |