Add ARM64 macOS support by upgrading to OpenResty LuaJIT 2.1 #154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds ARM64 (Apple Silicon) macOS support to wrk2 by replacing the embedded LuaJIT 2.0.3 with OpenResty
LuaJIT 2.1 as a git submodule, along with necessary platform-specific build fixes.
Motivation
The current embedded LuaJIT 2.0.3 does not support ARM64 architecture, making wrk2 unbuildable on Apple Silicon
Macs and other ARM64 platforms. With the increasing adoption of ARM64 architecture (Apple Silicon, AWS Graviton,
etc.), this limitation affects a growing number of users.
Changes
Commit 1: Replace LuaJIT 2.0.3 with OpenResty LuaJIT 2.1
Commit 2: Fix build issues on ARM64 macOS
path (supports both /opt/homebrew on Apple Silicon and /usr/local on Intel)
on Apple Silicon
x86/x64 architectures
Why OpenResty LuaJIT instead of Official LuaJIT?
- Official LuaJIT 2.0.x: No ARM64 support
- Official LuaJIT 2.1: ARM64 support exists but branch is in perpetual beta
- OpenResty LuaJIT 2.1: Production-grade ARM64 support
- Based on official LuaJIT 2.1 with full ARM64 JIT support
- Actively maintained by OpenResty team
- Used in production by OpenResty (nginx + LuaJIT) worldwide
- Contains numerous ARM64-specific bug fixes
- Fully API-compatible with official LuaJIT 2.1
released.
Testing
All tests performed on macOS 15.7.3 (Sequoia) on Apple Silicon (ARM64) with OpenResty LuaJIT 2.1-20241203:
✅ Core Functionality
[x] Basic HTTP request generation
[x] Constant throughput rate control (-R parameter)
[x] HdrHistogram latency statistics (-L)
[x] Uncorrected latency statistics (-U)
[x] Multi-threaded concurrent execution
✅ Lua Script Support
[x] scripts/counter.lua - Request counting
[x] scripts/post.lua - POST requests with custom headers
[x] scripts/setup.lua - Thread initialization and data sharing
[x] scripts/report.lua - Custom report formatting with done() callback
✅ Build Verification
[x] Clean build from scratch
[x] Binary architecture: Mach-O 64-bit executable arm64
[x] All example scripts execute correctly
Sample Test Output
$ ./wrk -t2 -c10 -d5s -R100 -L http://localhost:8080/
Running 5s test @ http://localhost:8080/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.83ms 3.96ms 22.58ms 82.00%
Req/Sec nan nan 0.00 0.00%
Latency Distribution (HdrHistogram - Recorded Latency)
50.000% 3.52ms
75.000% 6.24ms
90.000% 10.18ms
99.000% 19.30ms
99.900% 22.59ms
99.990% 22.59ms
99.999% 22.59ms
100.000% 22.59ms
502 requests in 5.01s, 524.06KB read
Requests/sec: 100.28
Transfer/sec: 104.69KB
$ file wrk
wrk: Mach-O 64-bit executable arm64
Compatibility
Breaking Changes
None. All changes are additive or platform-specific.
Additional Notes
Checklist
[x] Tested on ARM64 macOS
[x] No breaking changes to existing platforms
[x] All example Lua scripts work correctly
[x] Clean build from scratch succeeds
[x] Commits are properly separated by purpose
Ready for review! Happy to address any feedback or concerns.