BlogsCloudflareLuaJIT Performance Optimization

LuaJIT Performance Optimization

LuaJIT Performance Optimization

1
posts
2017

Cloudflare is actively involved in optimizing LuaJIT performance through research and development. This includes creating tools like 'loom' to better understand JIT compilation and debugging, and contributing to the LuaJIT ecosystem by addressing 'Not Yet Implemented' (NYI) features. A key focus has been on improving the performance of table iteration functions like `next()` and `pairs()` by enabling them to be JIT-compiled, thereby removing performance bottlenecks for Lua code that relies heavily on these features.

2017

LuaJIT Hacking: Getting next() out of the NYI list

2/21/2017

This post introduces 'loom', a custom HTML-formatted tool for visualizing LuaJIT's JIT compilation traces, offering more detail and cross-references than the standard `-jdump` option. It also details the problem of `next()` and `pairs()` being 'Not Yet Implemented' (NYI) in LuaJIT, forcing code to run in the interpreter and incurring significant performance penalties, especially when using the FFI library. The post outlines the steps taken to get `next()` out of the NYI list, enabling it to be JIT-compiled.