Open
Conversation
- Replace node-gyp/autoconf with CMake + cmake-js - Rewrite binding.cc: 727 → 230 lines (remove cache, mutexes, async executor) - execAsync is now a simple Promise wrapper (async is JS concept, not parallelism) - Add benchmark.js for performance testing Deleted: binding.gyp, deps/jq.gyp, configure, util/configure.js Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Cache: - Simple LRU cache for compiled jq filters (no mutex needed) - Default cache size of 100 filters - ~700k ops/sec for small JSON (was 1.2k without cache) Production optimizations: - -O3 maximum optimization level - -ffast-math aggressive floating-point optimizations - -funroll-loops, -ftree-vectorize (SIMD) - -fno-exceptions, -fno-rtti (smaller binary) - -march=native / -mcpu=native (CPU-specific) - LTO (Link Time Optimization) - Symbol stripping for smaller binary Performance vs original: - Small JSON: +74% (401k → 699k ops/sec) - Medium JSON: +250% / 3.5x (3.4k → 12k ops/sec) - Large JSON: +238% / 3.4x (92 → 311 ops/sec) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Performance Comparison: cmake-thin-wrapper vs main
Summary
This branch (
cmake-thin-wrapper) replaces the node-gyp build system with CMake and introduces several optimizations:-O3, LTO)Benchmark Results
Micro-benchmark (10K iterations)
Sync Execution (
exec)Sync Execution (
exec)Async Execution (
execAsync)Realistic Workload (108K complex queries on 27KB JSON)
Note: Worker threads excel on high-core machines (15+ threads). N-API async has lower per-op
overhead and performs better on typical 2-4 core machines.
Key insight: cmake-thin-wrapper async is 3x faster than main async (4.65s vs 14.34s)
Key Optimizations
CMake Build System
node-gypwithcmake-js-O3,-funroll-loops,-ftree-vectorize-mcpu=native)Mainstream jq 1.8.1
Thread-Local LRU Cache
Thin C++ Wrapper
N-API Async Work for Async Execution
execAsync()uses N-API's native async work APIworker_threads(9μs vs 14μs)Usage
Sync (fastest for single operations)
Async with Batching (fastest for high throughput)
Test Environment