Spark是如何进行字节码到机器码指令运行时间转换的?

How does Spark do bytecode to machine code instructions run time conversion?

阅读了一些关于Whole State Code Generation的文章后,spark 进行字节码优化以将查询计划转换为优化的执行计划。

https://jaceklaskowski.gitbooks.io/mastering-apache-spark/spark-sql-whole-stage-codegen.html

现在我的下一个问题是,但是在进行了这些与字节码和所有相关的优化之后,将这些字节码指令转换为机器码指令可能仍然是一个可能的瓶颈,因为这是由 JIT 单独完成的流程的运行时间以及要进行此优化,JIT 必须有足够的运行时间。

Spark 是否会做任何与dynamic/runtime 将优化字节码(这是 whole stage code gen 的结果)转换为机器码相关的事情,或者它是否依赖 JIT 将这些字节码指令转换为机器码代码说明。因为如果依赖JIT,那么就存在一定的不确定性。

spark does bytecode optimizations to convert a query plan to an optimized execution plan.

Spark SQL 进行字节码优化。

Spark SQL 简单地使用 CollapseCodegenStages physical preparation rule and eventually converts a query plan into a single-method Java source code (that Janino compiles 并生成字节码。

So does spark do anything related to dynamic/runtime conversion of optimized bytecode

没有


说到 JIT,WholeStageCodegenExec does this check whether the whole-stage codegen generates "too long generated codes" or not that could be above spark.sql.codegen.hugeMethodLimit Spark SQL internal property (that is 8000 by default and is the value of HugeMethodLimit in the OpenJDK JVM settings).

The maximum bytecode size of a single compiled Java function generated by whole-stage codegen. When the compiled function exceeds this threshold, the whole-stage codegen is deactivated for this subtree of the current query plan. The default value is 8000 and this is a limit in the OpenJDK JVM implementation.


支持 CodegenSupport 的物理运算符并不多,因此查看它们的 doConsumedoProduce 方法应该可以揭示 JIT 是否可能无法启动。