| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
World's Fastest AWS Lambda Runtime with ARM SIMD
Key Finding: Binary size directly impacts Lambda cold start. Ruchy Lambda achieves 6.70ms with 396KB binary (12.8x faster than Python's 85.73ms with ~100MB runtime). Python wrapped in C++ still suffers from large binaries (~10-50MB) and slow cold starts (28-86ms). Ruchy Lambda gives you BOTH fast local performance (ARM SIMD 4x parallelism) AND world-class Lambda deployment.
Ruchy Lambda achieves 6.70ms cold start on AWS Graviton2 using hand-tuned ARM NEON SIMD intrinsics — 29% faster than x86_64 baseline and 12.8x faster than Python.
Built by transpiling Ruchy (high-level language) to Rust with aggressive size optimizations:
# Prerequisites: ARM64 cross-compilation toolchain
rustup target add aarch64-unknown-linux-musl
sudo apt-get install gcc-aarch64-linux-gnu
# Clone and build
git clone https://github.com/paiml/ruchy-lambda.git
cd ruchy-lambda
cargo build --release# Build ARM64 SIMD Lambda (396KB binary)
./scripts/build-arm64-simd.sh
# Deploy to AWS Lambda Graviton2
aws lambda create-function \
--function-name ruchy-simd-arm64 \
--runtime provided.al2023 \
--architectures arm64 \
--handler bootstrap \
--role arn:aws:iam::YOUR_ACCOUNT:role/lambda-role \
--zip-file fileb://target/lambda-arm64-simd/bootstrap.zip
# Invoke and measure cold start
aws lambda invoke --function-name ruchy-simd-arm64 --payload '{}' response.json
# Check CloudWatch Logs for Init Duration (should be ~6-7ms)Cold Start (Init Duration):
Replicate:
# Install dependencies
rustup target add aarch64-unknown-linux-musl
sudo apt-get install gcc-aarch64-linux-gnu # Cross-compiler
# Build and deploy
./scripts/build-arm64-simd.sh # 5-10 seconds
# Follow deployment instructions aboveSee ARM64_DEPLOYMENT_RESULTS.txt for full CloudWatch metrics.
┌──────────────────────────────────────────────────┐
│ Ruchy Source (.ruchy) │
│ - High-level syntax │
│ - Pattern matching, error handling │
└────────────────┬─────────────────────────────────┘
│
▼ ruchy transpile
┌──────────────────────────────────────────────────┐
│ Rust Code │
│ - Idiomatic Rust output │
│ - Dead code elimination │
│ - Escape analysis (stack allocation) │
└────────────────┬─────────────────────────────────┘
│
▼ rustc (release-ultra profile)
┌──────────────────────────────────────────────────┐
│ Bootstrap Binary (396KB ARM64) │
│ - opt-level='z' (size optimization) │
│ - LTO=fat (cross-crate optimization) │
│ - ARM NEON SIMD intrinsics │
│ - Static linking (no dynamic libraries) │
└────────────────┬─────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────┐
│ AWS Lambda (Graviton2, provided.al2023) │
│ Cold Start: 6.70ms │
│ Memory: 11MB / 128MB │
│ Cost: 20% cheaper vs x86_64 │
└──────────────────────────────────────────────────┘
Zero-Dependency SIMD using Rust's built-in std::arch::aarch64:
use std::arch::aarch64::*;
// 4x parallelism with f32x4 vectors
let va = vld1q_f32(a.as_ptr().add(offset));
let vb = vld1q_f32(b.as_ptr().add(offset));
// Fused multiply-add (single instruction)
acc = vfmaq_f32(acc, va, vb); // acc += va * vb
// Horizontal sum (reduce to scalar)
sum = vaddvq_f32(acc);Key Features:
See ARM64_SIMD_IMPLEMENTATION.md for complete details.
All data captured from AWS CloudWatch logs on deployed functions in us-east-1.
| Metric | Value | vs x86_64 Baseline |
|---|---|---|
| Cold Start | 6.70ms | -29% (faster) |
| Memory Used | 11MB | -21% (lower) |
| Binary Size | 396KB | +12% |
| Package Size | 214KB | +23% |
| Cost per 1M req | $0.85/mo | -20% (cheaper) |
Handler: fibonacci(35) - 59M recursive calls Measured: 2025-11-20, us-east-1, 128MB memory config
| Runtime | Cold Start (Init) | Duration (CPU) | Memory | Binary Size | Package Size |
|---|---|---|---|---|---|
| Ruchy v3.212.0 | 9.48ms (7.69ms best) | 1.47ms avg | 14MB | 352KB | 174KB |
| Rust (tokio) | 14.90ms | 1.09ms | 12MB | 596KB | ~250KB |
| C++ (AWS SDK) | 28.96ms | 4.04ms | 22MB | 87KB | ~50KB |
| Go | 56.49ms | 2.34ms | 19MB | 4.2MB | ~1.5MB |
| Python 3.12 | 85.73ms | 15.07ms | 36MB | 445B + 78MB* | ~1KB |
Measurement methodology: AWS Lambda CloudWatch logs (Init Duration, Duration, Max Memory Used).
Key Metrics Explained:
*Python paradox: You deploy only 445 bytes of code, but AWS loads a ~78MB Python interpreter. Custom runtimes (Ruchy, Rust, C++, Go) include everything in one small binary, achieving 10x faster cold starts.
| Runtime | Init (Cold Start) | Execution (CPU) | Total Time | Memory |
|---|---|---|---|---|
| ARM64 SIMD | 6.70ms | 481.42ms | 488.12ms | 11MB |
| x86_64 Ruchy | 9.26ms | 637.46ms | 646.72ms | 14MB |
| Rust | 14.97ms | 551.33ms | 566.30ms | 13MB |
| Go | 46.85ms | 689.22ms | 736.07ms | 19MB |
| C++ | 99.38ms | 1136.72ms | 1236.10ms | 22MB |
| Python | 92.74ms | 25,083.46ms | 25,176.20ms | 37MB |
Note: ARM64 achieves both faster cold start (6.70ms vs 9.26ms) AND faster total time (488ms vs 647ms) than x86_64.
# Automated build (recommended)
./scripts/build-arm64-simd.sh
# Manual build
cargo build \
--profile release-ultra \
--target aarch64-unknown-linux-musl \
-p ruchy-lambda-bootstrap
# Output: target/aarch64-unknown-linux-musl/release-ultra/bootstrap (396KB)Configuration (.cargo/config.toml):
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-gnu-gcc"
rustflags = [
"-C", "target-cpu=neoverse-n1", # Graviton2 CPU
"-C", "target-feature=+neon", # ARM NEON SIMD
"-C", "link-arg=-static",
"-C", "link-arg=-s",
]Profile (Cargo.toml):
[profile.release-ultra]
opt-level = 'z' # Size optimization (faster cold start)
lto = "fat" # Fat link-time optimization
codegen-units = 1 # Maximum optimization
panic = 'abort' # No unwinding overhead
strip = true # Remove debug symbolscargo build --profile release-ultra -p ruchy-lambda-bootstrap
# Output: target/x86_64-unknown-linux-musl/release-ultra/bootstrap (352KB)Minimal (handler_minimal.ruchy):
pub fun lambda_handler(request_id: &str, body: &str) -> String {
"{\"statusCode\":200,\"body\":\"ok\"}"
}
Fibonacci (handler_fibonacci.ruchy):
pub fun fibonacci(n: i32) -> i32 {
if n <= 1 {
n
} else {
fibonacci(n - 1) + fibonacci(n - 2)
}
}
pub fun lambda_handler(request_id: &str, body: &str) -> String {
let n = 35;
let result = fibonacci(n);
let result_str = result.to_string();
String::from("{\"statusCode\":200,\"body\":\"fibonacci(35)=") + &result_str + "\"}"
}
SIMD Vector Operations (handler_simd_vector.rs):
// 10K element f32 vector dot product
pub fn lambda_handler(_request_id: &str, _body: &str) -> String {
const SIZE: usize = 10_000;
let vec_a: Vec<f32> = (0..SIZE).map(|i| (i as f32) + 1.0).collect();
let vec_b: Vec<f32> = vec![0.5; SIZE];
// Uses ARM NEON intrinsics on Graviton2, scalar fallback on x86_64
let result = simd_ops::dot_product(&vec_a, &vec_b);
format!("{{\"statusCode\":200,\"body\":{{\"dotProduct\":{},\"vectorSize\":{}}}}}",
result, SIZE)
}# ARM64 cross-compilation toolchain
rustup target add aarch64-unknown-linux-musl
sudo apt-get install gcc-aarch64-linux-gnu
# AWS CLI (if not installed)
pip install awscli
aws configure# 1. Build ARM64 SIMD binary
./scripts/build-arm64-simd.sh
# Output: target/lambda-arm64-simd/bootstrap.zip (214KB)
# 2. Create IAM role (one-time)
aws iam create-role \
--role-name lambda-execution-role \
--assume-role-policy-document file://<(cat <<EOF
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"Service": "lambda.amazonaws.com"},
"Action": "sts:AssumeRole"
}]
}
EOF
)
aws iam attach-role-policy \
--role-name lambda-execution-role \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
# 3. Deploy function
aws lambda create-function \
--function-name ruchy-simd-arm64 \
--runtime provided.al2023 \
--architectures arm64 \
--handler bootstrap \
--role arn:aws:iam::YOUR_ACCOUNT_ID:role/lambda-execution-role \
--zip-file fileb://target/lambda-arm64-simd/bootstrap.zip \
--timeout 30 \
--memory-size 128
# 4. Invoke and test
aws lambda invoke \
--function-name ruchy-simd-arm64 \
--payload '{}' \
response.json
cat response.json
# Expected: {"statusCode":200,"body":"fibonacci(35)=9227465"}
# 5. Check cold start time
aws logs filter-log-events \
--log-group-name /aws/lambda/ruchy-simd-arm64 \
--filter-pattern "REPORT" \
--max-items 1 \
--query 'events[0].message' \
--output text
# Expected: Init Duration: 6.70 ms (or similar)# Run tests
cargo test --workspace
# Local benchmark (fibonacci)
make bench-local
# Build for local testing (x86_64)
cargo build --profile release-ultra -p ruchy-lambda-bootstrap
# Transpile Ruchy source
ruchy compile your-handler.ruchy --optimize aggressiveSmaller Binary Loads Faster
ARM64 Architecture Advantages
Optimized Compilation
Minimal Memory Footprint
| Profile | Binary Size | Cold Start | Rationale |
|---|---|---|---|
| opt-level='z' | 396KB | 6.70ms | Size-first: smaller loads faster |
| opt-level=3 | 2.1MB | ~15-20ms | Speed-first: larger binary, slower load |
Lambda cold start is dominated by binary load time, not execution speed. A 6x smaller binary (396KB vs 2.1MB) results in significantly faster initialization.
Tested Ruchy v3.212.0's --pgo flag on fibonacci(35) workload:
| Optimization | Time | Binary Size | Result |
|---|---|---|---|
| nasa/aggressive | 20.7ms | 312-314KB | ✅ Optimal |
| PGO | 22.0ms | 3.8MB | ❌ 6% slower, 12x larger |
Why PGO Failed: Fibonacci has simple branching (single if/else) that branch predictors handle well. PGO's aggressive inlining creates code bloat, hurting cache locality.
When PGO Works: Complex branching patterns (JSON parsing, HTTP routing, hash tables, trees) where hot path optimization justifies the binary size trade-off.
Recommendation: Do not use PGO for Lambda. Stick with opt-level='z' (release-ultra) for optimal cold start performance.
ARM64 Graviton2 Pricing (us-east-1):
Example (1M requests/month, 128MB, 500ms avg):
| Architecture | Monthly Cost | Savings |
|---|---|---|
| ARM64 Graviton2 | $0.85 | Baseline |
| x86_64 | $1.06 | +$0.21 (+25%) |
Annual Savings: $2.52/year per workload (scales linearly)
Ruchy Ecosystem:
Quality standards enforced by PMAT v2.192.0+:
See CLAUDE.md for detailed development guidelines.
MIT OR Apache-2.0
Built with optimization insights from:
Status: ✅ Production-ready ARM64 SIMD implementation Latest: v3.212.0 (2025-11-20) Deployed: ruchy-simd-arm64 (AWS Lambda us-east-1 Graviton2) Cold Start: 6.70ms (29% faster than x86_64, 12.8x faster than Python)
| Back | FazBrowse Home | New Git URL |