用WebAssembly快速编译和执行SQL程序
Fast Compilation and Execution of SQL Queries with WebAssembly
摘要:
如在向量化模型中,查询的解释执行遭受解释开销。通过编译查询,可以消除这种解释开销,但代价是编译阶段会延迟执行,从而牺牲吞吐量的延迟。对于短期查询,最小化延迟很重要,而对于长期运行的查询,吞吐量超过延迟。由于纯解释模型和纯编译模型都不能提供低延迟和高吞吐量,因此出现了自适应解决方案。自适应系统可以从解释执行无缝过渡到编译执行,从而实现短时间查询的低延迟和长时间运行查询的高吞吐量。然而,这些自适应系统提出了一个巨大的发展努力,需要在解释器和编译器设计的专家知识。在这项工作中,我们调查查询执行编译到WebAssembly。我们能够在不到一毫秒的时间内将复杂的查询编译成机器码,并获得接近最佳的性能。通过将WebAssembly的执行委托给V8引擎,我们能够在执行期间从快速编译但未优化的代码无缝过渡到彻底优化的代码。我们的方法同时提供低延迟和高吞吐量,是开箱即用的自适应方法,并且易于实现。大大减少的编译时间甚至使我们能够探索库代码的生成式编程,即完全通过构造内联。我们的实验评估证实,我们的方法产生竞争力,有时优越的性能。
英文摘要:
Interpreted execution of queries, as in the vectorized model, suffers from interpretation overheads. By compiling queries this interpretation overhead is eliminated at the cost of a compilation phase that delays execution, sacrificing latency for throughput. For short-lived queries, minimizing latency is important, while for long-running queries throughput outweighs latency. Because neither a purely interpretive model nor a purely compiling model can provide low latency and high throughput, adaptive solutions emerged. Adaptive systems seamlessly transition from interpreted to compiled execution, achieving low latency for short-lived queries and high throughput for long-running queries. However, these adaptive systems pose an immense development effort and require expert knowledge in both interpreter and compiler design. In this work, we investigate query execution by compilation to WebAssembly. We are able to compile even complex queries in less than a millisecond to machine code with near-optimal performance. By delegating execution of WebAssembly to the V8 engine, we are able to seamlessly transition from rapidly compiled yet non-optimized code to thoroughly optimized code during execution. Our approach provides both low latency and high throughput, is adaptive out of the box, and is straight forward to implement. The drastically reduced compilation times even enable us to explore generative programming of library code, that is fully inlined by construction. Our experimental evaluation confirms that our approach yields competitive and sometimes superior performance.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。