|
| 1 | +# **ParserNG: Performance & Memory Manifesto** |
| 2 | + |
| 3 | +ParserNG is a high-performance mathematical expression engine for Java, designed for systems where **nanoseconds matter** and **Garbage Collection (GC) is unacceptable.** |
| 4 | + |
| 5 | + |
| 6 | +### **ParserNG vs. The Giants: Master Performance Matrix** |
| 7 | + |
| 8 | +| Battleground | Expression Type | Janino (ns/op) | **ParserNG (Turbo)** | **ParserNG Advantage** | |
| 9 | +| :--- | :--- | :--- | :--- | :--- | |
| 10 | +| **Pure Arithmetic** | `x + y + z...` | 251.08 | **119.95** | **2.1x Faster** | |
| 11 | +| **Structural Scale** | `500+ Variables` | **CRASH** | **SUCCESS** | **Only Survivor** | |
| 12 | +| **Functional Heavy** | `20+ sin() calls` | 471.43 | **362.89** | **1.3x Faster** | |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | + |
| 17 | +## **1. Performance: Beyond the "Gold Standard"** |
| 18 | +For years, Janino has been considered the speed leader because it compiles expressions to bytecode. ParserNG’s **Turbo** engine shatters this benchmark. |
| 19 | + |
| 20 | +In head-to-head testing using a complex trigonometric and power-based expression, ParserNG consistently beats both Janino and Parsii. |
| 21 | + |
| 22 | +### **Benchmark Results (Complex Expression)** |
| 23 | +*Expression: `(sin(x) + 2 + ((7-5) * (3.14159 * x^(14-10)) + sin(-3.141) + (0%x)) * x/3 * 3/sqrt(x+12))`* |
| 24 | + |
| 25 | +| Library | Speed (ns/op) | Performance Gap | |
| 26 | +| :--- | :--- | :--- | |
| 27 | +| **ParserNG Turbo (Widening)** | **119.95 ns** | **1.0x (Winner)** | |
| 28 | +| **ParserNG Turbo (Array)** | **133.26 ns** | 1.1x Slower | |
| 29 | +| **Janino** | 251.08 ns | **2.1x Slower** | |
| 30 | +| **Parsii** | 370.29 ns | 3.1x Slower | |
| 31 | + |
| 32 | +**The Verdict:** ParserNG is **2x faster than Janino** and **3x faster than Parsii**, all while operating under the same JVM constraints. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## **2. Memory Profile: Zero Allocation, Zero Disturbance** |
| 37 | +High-performance Java isn't just about raw speed; it's about **predictability**. Most parsers create object "noise" that forces the Garbage Collector to pause your application. |
| 38 | + |
| 39 | +### **The "Zero-Allocation" Guarantee** |
| 40 | +ParserNG achieves a steady-state execution with **zero object churn**. |
| 41 | +* **GC Allocation Rate:** **0.007 MB/sec** (effectively zero). |
| 42 | +* **GC Count:** **0** during the entire measurement period. |
| 43 | + |
| 44 | +### **Metaspace Safety** |
| 45 | +Unlike Janino, which creates a new Java class for every expression (risking **Metaspace OutOfMemoryErrors**), ParserNG uses a reusable, high-density architecture. You can compile millions of unique expressions without bloating the JVM's permanent memory or requiring a restart. |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## **3. Architecture: Hybrid Variable Passing** |
| 50 | +ParserNG intelligently optimizes how data reaches the CPU. |
| 51 | + |
| 52 | +### **Widening Strategy (The "Register" Path)** |
| 53 | +For expressions within the JVM’s method slot limits (up to 63 variables), ParserNG uses **Widening**. This passes values directly through registers and the stack, achieving the absolute lowest possible latency. |
| 54 | +* **Winner for:** Standard formulas, physics engines, and real-time signals. |
| 55 | + |
| 56 | +### **Array-Based Strategy (The "Unlimited" Path)** |
| 57 | +When expressions grow into hundreds or thousands of variables, ParserNG seamlessly switches to an **Array-Based** approach. This bypasses the JVM’s 255-slot limit, allowing for massive high-dimensional data processing that would crash a standard compiler. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## **4. Scalability: Linear Performance** |
| 62 | +ParserNG scales predictably. As you increase variable counts, the "tax" per variable remains under **1 nanosecond** per op, allowing you to build complex models without hitting a performance wall. |
| 63 | + |
| 64 | +| Variables | Array-Based | Widening | |
| 65 | +| :--- | :--- | :--- | |
| 66 | +| **1 Var** | 5.65 ns | 6.17 ns | |
| 67 | +| **20 Vars** | 15.11 ns | 15.34 ns | |
| 68 | +| **63 Vars** | 52.07 ns | **51.60 ns** | |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## **Summary** |
| 73 | +If you are building high-frequency trading platforms, real-time simulation software, or cloud-native microservices with tight memory budgets, **ParserNG** provides the deterministic speed you need without the Garbage Collection or Metaspace risks of traditional tools. |
| 74 | + |
| 75 | +--- |
| 76 | + |
0 commit comments