Compiling Formulas at Runtime for the Sake of Performance
summary
At Ozon, calculated features (complex formulas defined by data scientists) used after initial ranking were consuming too much CPU, so the team implemented runtime bytecode generation to execute those formulas. The talk explains the bytecode-generation approach, shows it reduced CPU usage nearly threefold and lowered latency and allocations, and discusses techniques for inspecting JVM JIT behavior and ways to further optimize formula compilation.
AI-written summary · about
chapters (22)
- 0:00Introduction
- 2:06Talk overview
- 3:28Search ranking features
- 5:54Formula complexity challenges
- 8:43Recursive evaluation issues
- 10:11Manual vs generated code
- 11:58Compile to non-recursive
- 13:22Bytecode over Java code
- 15:09JVM bytecode basics
- 16:13Bytecode compiler design
- 18:17Debugging bytecode
- 20:02Benchmarking compiled vs evaluated
- 21:27Production CPU gains
- 23:34Adding range checks
- 26:44JIT optimizations with HSDis
- 28:33Vectorization results
- 30:18Inlining constant arrays
- 33:10Vector API on Java 21
- 35:34Alternative approaches
- 37:42Key takeaways
- 38:45Conclusion
- 39:31Q&A
