# Apache Gluten

**Apache Gluten** 是一款开源中间件插件，它通过将计算密集型算子的执行卸载到原生向量化引擎（如 Velox 和 [ClickHouse](https://www.edgepedia.org/zh/clickhouse)）来加速 Apache Spark SQL，且无需修改现有的 SQL 查询或 DataFrame 代码<sup>[1](https://apache.github.io/gluten/getting-started/)</sup>。"Gluten"在拉丁语中意为"胶水"，反映了该项目将原生库粘合到 Spark SQL 上的目标，使工作负载既能获得 Spark 的分布式可扩展性，又能获得原生引擎的性能<sup>[2](https://apache.github.io/gluten/)</sup>。该项目由 Intel 和 Kyligence 于 2022 年发起，随后进入 Apache 孵化器，并于 2026 年 3 月成为 Apache 顶级项目<sup>[3](https://github.com/apache/gluten)</sup>。

| 关键事实 | 详情 |
|---|---|
| 是什么 | 一个 Spark 插件，将基于 JVM 的 SQL 执行卸载到原生引擎，仅需修改配置<sup>[1](https://apache.github.io/gluten/getting-started/)</sup> |
| 原生后端 | Velox（Meta 的 C++ 执行库）和 ClickHouse（以原生库形式移植的列式 DBMS）<sup>[1](https://apache.github.io/gluten/getting-started/)</sup> |
| 计划交换 | Spark 物理计划转换为 Substrait，通过 JNI 传递给原生代码；数据以 Apache Arrow 列式格式交换<sup>[4](https://nightlies.apache.org/gluten/docs/_site/)</sup> |
| 支持的 Spark 版本 | Spark 3.4、3.5、4.0 和 4.1<sup>[4](https://nightlies.apache.org/gluten/docs/_site/)</sup> |
| 基准测试结果 | 在 Spark 3.3.1 上以 3 TB 规模运行 Gluten + Velox，TPC-H 整体加速 3.34 倍，TPC-DS 整体加速 3.02 倍；单条查询最高加速分别达 23.45 倍和 13.75 倍<sup>[5](https://gluten.apache.org/)</sup> |
| 治理 | 2024 年 1 月 11 日起进入孵化；2026 年 2 月 18 日毕业为 Apache 顶级项目<sup>[6](https://incubator.apache.org/projects/gluten.html)</sup> |
| 最新版本 | 1.7.0，发布于 2026 年 8 月 26 日<sup>[7](https://release-catalog.apache.org/gluten/index.html)</sup> |

## 动机与设计

Spark 基于 JVM 的 SQL 引擎历来在查询计划层面获取优化；自 Spark 2.0 以全阶段代码生成（Whole Stage Code Generation）取代火山模型（Volcano Model）并报告了 2 倍加速之后，单算子性能基本停止提升<sup>[2](https://apache.github.io/gluten/)</sup>。与此同时，ClickHouse、Arrow 和 Velox 等原生库采用列式数据格式和向量化处理，性能优于基于 JVM 的 SQL 引擎，但它们自身仅支持单节点执行<sup>[2](https://apache.github.io/gluten/)</sup>。

Gluten 的基本设计原则是复用 Spark 的整个控制流和尽可能多的 JVM 代码，同时将计算密集型的数据处理卸载到原生代码<sup>[2](https://apache.github.io/gluten/)</sup>。该项目将其目标用户描述为任何希望从根本上加速 SparkSQL 的人；作为一个插件，它无需修改 DataFrame API 或 SQL 查询，只需正确配置即可<sup>[2](https://apache.github.io/gluten/)</sup>。

## 架构

Gluten 将 Spark 的全阶段物理计划转换为 [Substrait](https://www.edgepedia.org/zh/substrait) 计划——一种跨语言的数据计算操作规范——并通过 JNI 调用传递给原生侧，在原生侧构建并执行原生算子链<sup>[4](https://nightlies.apache.org/gluten/docs/_site/)</sup>。结果以列式批次返回给 Spark：由于 Gluten 使用 [Apache Arrow](https://www.edgepedia.org/zh/apache-arrow) 作为其基本数据格式，返回给 Spark JVM 的数据是 ArrowColumnarBatch，通过 Spark 3.0 引入的 Spark Columnar API 进行交换<sup>[4](https://nightlies.apache.org/gluten/docs/_site/)</sup>。

关键组件包括<sup>[4](https://nightlies.apache.org/gluten/docs/_site/)</sup>：

- **查询计划转换**，将 Spark 的物理计划转换为 Substrait 计划。
- **统一内存管理**，控制原生内存分配。
- **列式 shuffle**，通过列式交换算子对 Gluten 的列式数据进行 shuffle，同时复用 Spark 核心的 shuffle 服务。
- **回退机制**，对不支持的算子回退到原版 Spark，通过原生实现的 ColumnarToRow（C2R）和 RowToColumnar（R2C）算子在 Gluten 列式数据与 Spark 内部行数据之间进行转换。
- **指标**，从原生引擎收集并在 Spark UI 中展示，帮助识别缺陷和瓶颈。
- **Shim 层**，支持多个 Spark 版本。

## 后端

Gluten 目前支持两种原生后端<sup>[1](https://apache.github.io/gluten/getting-started/)</sup>：

- **Velox**，Meta 的 C++ 执行库，提供可复用、可扩展的高性能数据处理组件<sup>[4](https://nightlies.apache.org/gluten/docs/_site/)</sup>。
- **ClickHouse**，一个列式 DBMS，被移植为原生库使用<sup>[1](https://apache.github.io/gluten/getting-started/)</sup>。

该架构可扩展至更多原生加速器<sup>[2](https://apache.github.io/gluten/)</sup>。一个相关的 Apache 项目 DataFusion Comet 采用基于 Rust 的方法解决同一问题；Comet 的文档指出，两个项目都能加速对 [Apache Iceberg](https://www.edgepedia.org/zh/apache-iceberg) 表的查询，但方法不同，而 Gluten 总体上覆盖的表格式范围更广<sup>[8](https://datafusion.apache.org/comet/about/gluten_comparison.html)</sup>。

## 部署

部署 Gluten 意味着将其 JAR 和配置添加到 Spark 会话中。Velox 后端需要启用堆外内存并设置列式 shuffle 管理器以支持原生 shuffle，例如设置 `spark.plugins=org.apache.gluten.GlutenPlugin`、`spark.memory.offHeap.enabled=true` 和 `spark.shuffle.manager=org.apache.spark.shuffle.sort.ColumnarShuffleManager`<sup>[1](https://apache.github.io/gluten/getting-started/)</sup>。一种实验性的堆外内存大小动态调整模式让 Gluten 根据 `spark.executor.memory` 自动管理堆外/堆内内存的划分，无需显式设置堆外内存<sup>[1](https://apache.github.io/gluten/getting-started/)</sup>。

运行查询后，原生执行在 Spark UI 中可见：包含 `Transformer`、`Velox` 或 `Columnar` 的查询计划节点表明算子以原生方式运行<sup>[1](https://apache.github.io/gluten/getting-started/)</sup>。Gluten 还在 Spark UI 中添加了一个 `Gluten SQL / DataFrame` 标签页，显示构建信息和每次查询的回退信息，并发出 `GlutenBuildInfoEvent` 和 `GlutenPlanFallbackEvent` 事件，开发者可通过 `SparkListener` 消费<sup>[9](https://apache.github.io/gluten/get-started/GlutenUI.html)</sup>。资格分析工具（Qualification Tool）分析 Spark 事件日志文件，评估工作负载与 Gluten 的兼容性及预期收益<sup>[3](https://github.com/apache/gluten)</sup>。

## 性能

该项目公布的基准测试在 Intel Xeon Platinum 8592+ 硬件上以 3 TB 规模运行 TPC-H 和 TPC-DS，使用 Spark 3.3.1，报告 Gluten + Velox 的 TPC-H 整体加速 3.34 倍、TPC-DS 整体加速 3.02 倍，单条查询最高分别达 23.45 倍（TPC-H）和 13.75 倍（TPC-DS）<sup>[5](https://gluten.apache.org/)</sup>。创建 Velox 的 Meta 报告称，在 Apache Gluten 项目中——Velox 作为 Spark 内的执行引擎——基准测试中也观察到了类似的 3 倍效率提升<sup>[10](https://engineering.fb.com/2024/05/22/data-infrastructure/composable-data-management-at-meta/)</sup>。

采用范围不仅限于基准测试。微软为 Fabric Spark 构建的原生执行引擎基于 Apache Gluten 和 Velox<sup>[11](https://gluten.apache.org/references/)</sup>，已发表的用例和评估来自 Intel、微软、IBM、Pinterest、美团、BIGO、BONC、网易和 Arm 等公司<sup>[11](https://gluten.apache.org/references/)</sup>。

## 历史与社区

Intel 和 Kyligence 于 2022 年启动 Gluten 项目<sup>[3](https://github.com/apache/gluten)</sup>，随后项目进入 Apache 孵化器，孵化器记录的孵化起始日期为 2024 年 1 月 11 日<sup>[6](https://incubator.apache.org/projects/gluten.html)</sup>。其首个 Apache 版本 1.2.0-incubating 于 2024 年 8 月 21 日发布，随后是 1.2.1（2024 年 11 月 29 日）、1.3.0（2025 年 1 月 16 日）、1.4.0（2025 年 6 月 6 日）和 1.5.0（2025 年 10 月 29 日）<sup>[7](https://release-catalog.apache.org/gluten/index.html)</sup>。ASF 董事会于 2026 年 2 月 18 日批准成立 Apache Gluten 项目，孵化器记录该日期为项目毕业成为顶级项目之日<sup>[6](https://incubator.apache.org/projects/gluten.html)</sup><sup> • </sup><sup>[12](https://www.apache.org/foundation/board/minutes/Gluten.html)</sup>；ASF 于 2026 年 3 月 5 日公开发布毕业公告<sup>[13](https://news.apache.org/foundation/entry/the-apache-software-foundation-graduates-two-open-source-projects-from-incubator)</sup>。毕业后的版本包括 1.6.0（2026 年 3 月 10 日）和 1.7.0（2026 年 8 月 26 日）<sup>[7](https://release-catalog.apache.org/gluten/index.html)</sup>。

截至 2026 年 5 月的董事会报告，该项目有 45 名提交者和 28 名 PMC 成员，GitHub 星标约 1.6k，fork 约 600 个<sup>[12](https://www.apache.org/foundation/board/minutes/Gluten.html)</sup>。除 Intel 和 Kyligence 外，活跃的贡献公司包括 BIGO、美团、阿里云、网易、百度、微软、IBM 和谷歌<sup>[3](https://github.com/apache/gluten)</sup>。Gluten 采用 [Apache License](https://www.edgepedia.org/zh/apache-license) 2.0 许可<sup>[3](https://github.com/apache/gluten)</sup>。

## References

1. [Getting Started with Apache Gluten, Apache Gluten documentation](https://apache.github.io/gluten/getting-started/)
2. [Overview, Apache Gluten documentation](https://apache.github.io/gluten/)
3. [apache/gluten on GitHub](https://github.com/apache/gluten)
4. [Architecture, Apache Gluten documentation (nightlies)](https://nightlies.apache.org/gluten/docs/_site/)
5. [Apache Gluten home page, performance benchmarks](https://gluten.apache.org/)
6. [Apache Gluten Project Incubation Status, Apache Incubator](https://incubator.apache.org/projects/gluten.html)
7. [Apache Gluten, Apache Release Catalog](https://release-catalog.apache.org/gluten/index.html)
8. [Comparison of Comet and Gluten, Apache DataFusion Comet documentation](https://datafusion.apache.org/comet/about/gluten_comparison.html)
9. [Gluten UI, Apache Gluten documentation](https://apache.github.io/gluten/get-started/GlutenUI.html)
10. [Composable data management at Meta, Meta Engineering Blog](https://engineering.fb.com/2024/05/22/data-infrastructure/composable-data-management-at-meta/)
11. [Gluten related Use Cases and Publications, Apache Gluten references](https://gluten.apache.org/references/)
12. [Board history: Gluten, Apache Software Foundation](https://www.apache.org/foundation/board/minutes/Gluten.html)
13. [The Apache Software Foundation Graduates Two Open Source Projects from Incubator, ASF Blog](https://news.apache.org/foundation/entry/the-apache-software-foundation-graduates-two-open-source-projects-from-incubator)

---
*Initially written Oct 26, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › Data mining, warehousing, and big data › Big data platforms and frameworks

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/apache-gluten

English original: https://www.edgepedia.org/apache-gluten
