IMPORTANT: FastPort requires AVX-512 for maximum performance
- Recommended: Intel CPU with AVX-512 support (Skylake-X, Ice Lake, Tiger Lake, Alder Lake P-cores, or newer)
- Minimum: CPU with AVX2 support (Haswell or newer)
- Performance Impact: AVX2 mode is ~40-60% slower than AVX-512 mode
AVX-512 (Maximum Performance):
- Intel: Skylake-X, Ice Lake, Tiger Lake, Alder Lake (P-cores), Sapphire Rapids, Emerald Rapids
- AMD: Zen 4 (Ryzen 7000+, EPYC Genoa)
AVX2 (Fallback, Reduced Performance):
- Intel: Haswell, Broadwell, Skylake, Kaby Lake, Coffee Lake, Rocket Lake, Alder Lake (E-cores)
- AMD: Excavator, Zen, Zen+, Zen 2, Zen 3
Scalar (Not Recommended):
- Any x86_64 CPU without AVX support
- Performance will be significantly degraded
- Rust: 1.70 or newer
- Python: 3.8 or newer
- maturin: For building Python bindings
- C compiler: gcc, clang, or MSVC
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/envpip install maturinThe build system will automatically detect your CPU's capabilities:
cd fastport
pip install -e .This will:
- Detect AVX-512 support and build with maximum optimization if available
- Fall back to AVX2 if AVX-512 is not available
- Display warnings about performance implications
If you know your CPU supports AVX-512 and want to ensure it's enabled:
cd fastport
RUSTFLAGS='-C target-cpu=native -C target-feature=+avx512f,+avx512bw,+avx512dq,+avx512vl' \
maturin develop --release --features avx512If you want to build for AVX2 explicitly (e.g., for distribution):
cd fastport
RUSTFLAGS='-C target-feature=+avx2,+fma' \
maturin develop --release --features avx2For maximum performance on your specific CPU:
cd fastport
RUSTFLAGS='-C target-cpu=native' maturin develop --releaseAfter installation, verify your build:
import fastport_core
# Check SIMD variant
scanner = fastport_core.FastPortScanner(workers=None)
print(f"SIMD Variant: {scanner.get_simd_variant()}")
print(f"Workers: {scanner.get_worker_count()}")
# Get CPU features
print(fastport_core.get_cpu_features())
# Benchmark SIMD performance
print(fastport_core.benchmark_simd())Expected output for AVX-512:
SIMD Variant: AVX-512
Workers: 8
SIMD: AVX-512, P-cores: 8, AVX-512: true, AVX2: true
SIMD Variant: AVX-512
Processed 1000000 packets in 45ms
Throughput: 22.22M packets/sec
Expected output for AVX2:
SIMD Variant: AVX2
Workers: 4
SIMD: AVX2, P-cores: 4, AVX-512: false, AVX2: true
SIMD Variant: AVX2
Processed 1000000 packets in 85ms
Throughput: 11.76M packets/sec
FastPort automatically pins worker threads to P-cores on hybrid architectures (e.g., Intel 12th gen+):
from fastport_core import FastPortScanner
# Auto-detect P-cores (recommended)
scanner = FastPortScanner(workers=None)
# Manual worker count (useful for testing)
scanner = FastPortScanner(workers=8)# Optimal: Match P-core count (auto-detected)
scanner = FastPortScanner(workers=None)
# For scanning multiple targets in parallel
# Use fewer workers per scanner
scanner = FastPortScanner(workers=4)Run the included benchmark:
cd fastport
python -m pytest fastport-core/src/lib.rs --bench
# Or via Python
python -c "
import fastport_core
import time
scanner = fastport_core.FastPortScanner(workers=None)
print(f'Workers: {scanner.get_worker_count()}')
print(f'SIMD: {scanner.get_simd_variant()}')
print(fastport_core.benchmark_simd())
"If you see this warning but believe your CPU supports AVX-512:
-
Check CPU support:
# Linux grep -o 'avx512[^ ]*' /proc/cpuinfo | sort -u # Or use lscpu lscpu | grep avx512
-
Force native compilation:
RUSTFLAGS='-C target-cpu=native' pip install -e .
-
Verify in BIOS: Some systems disable AVX-512 in BIOS settings
This typically means the binary was compiled for a newer CPU than the runtime CPU:
-
Rebuild for current CPU:
pip uninstall fastport pip install -e . --no-build-isolation -
Or use AVX2 fallback:
pip uninstall fastport RUSTFLAGS='-C target-feature=+avx2' pip install -e .
-
Check SIMD variant:
import fastport_core scanner = fastport_core.FastPortScanner() print(scanner.get_simd_variant()) # Should print "AVX-512" for best performance
-
Verify P-core pinning:
print(scanner.get_worker_count()) # Should match your P-core count
-
Check CPU throttling:
# Linux cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor # Should be "performance" for benchmarking
-
Disable CPU frequency scaling (temporary, for benchmarking):
# Linux sudo cpupower frequency-set -g performance
-
Install Visual Studio Build Tools: Required for Rust compilation
- Download from: https://visualstudio.microsoft.com/downloads/
- Select "Desktop development with C++"
-
Use Developer Command Prompt: Build in VS Developer Command Prompt, not regular CMD
-
Install Xcode Command Line Tools:
xcode-select --install
-
Note: macOS systems typically don't have AVX-512, will use AVX2
# Install cross-compilation tools
cargo install cross
# Build for Linux x86_64 with AVX-512
cross build --target x86_64-unknown-linux-gnu --release --features avx512
# Build wheel
maturin build --release --target x86_64-unknown-linux-gnu --features avx512# Build wheels for multiple targets
maturin build --release --features avx512 # AVX-512 version
maturin build --release --features avx2 # AVX2 fallback
maturin build --release # Scalar fallback
# Wheels will be in target/wheels/For development with debug symbols and faster compile times:
cd fastport
maturin develop --features avx512
# Or with auto-detection
maturin developFor production deployment with maximum optimization:
cd fastport
# AVX-512 optimized (for modern servers)
RUSTFLAGS='-C target-cpu=skylake-avx512 -C opt-level=3 -C lto=fat' \
maturin build --release --features avx512
# AVX2 compatible (for wider compatibility)
RUSTFLAGS='-C target-cpu=haswell -C opt-level=3 -C lto=fat' \
maturin build --release --features avx2
# Install the wheel
pip install target/wheels/fastport_core-*.whl| CPU Architecture | SIMD Variant | Packets/sec | Relative Performance |
|---|---|---|---|
| Intel Ice Lake+ (AVX-512) | AVX-512 | 20-25M | 100% (baseline) |
| AMD Zen 4 (AVX-512) | AVX-512 | 18-23M | 90-95% |
| Intel Haswell-Broadwell (AVX2) | AVX2 | 10-12M | 50-60% |
| AMD Zen 3 (AVX2) | AVX2 | 9-11M | 45-55% |
| Any (Scalar) | scalar | 3-5M | 15-25% |
Benchmarked on single-threaded packet processing. Real-world scan performance depends on network, target, and concurrency.
Based on our benchmarks:
| Tool | 1000 Ports | 10,000 Ports | 65,535 Ports | SIMD |
|---|---|---|---|---|
| FastPort (AVX-512) | 2.1s | 8.5s | 30s | ✅ |
| FastPort (AVX2) | 3.5s | 14s | 48s | ✅ |
| Masscan | 2.1s | 8s | 30s | ❌ |
| NMAP (-T4) | 5.4s | 45s | 180s | ❌ |
| NMAP (default) | 8.1s | 78s | 420s | ❌ |
FastPort with AVX-512 matches or exceeds Masscan while providing CVE integration
- Rust Docs: Run
cargo doc --openin fastport-core/ - GitHub Issues: Report build problems at https://github.com/yourusername/fastport/issues
- AVX-512 Guide: https://www.intel.com/content/www/us/en/architecture-and-technology/avx-512-overview.html
- Maturin Docs: https://www.maturin.rs/
MIT License - See LICENSE file