apache / apache/datafusion-sqlparser-rs
[EPIC] Improve sqlparser performance
- 主要语言
- Rust
- 星标
- 3.5k
- 派生
- 772
- 平均合并
- 4 天 9 小时
- 30 天内合并 PR
- 17
描述
## What problem are you trying to solve?
Normally, in a SQL processing system, parsing SQL is not a major bottleneck compared to actually processing data. That being said, given how many SQL strings are parsed by this crate, I think there is significant benefit to improving the performance of the SQL parser in this crate.
That being said, I also think it is important to minimize the impact on downstream crates as much as possible.
Recently, we started [introducing locations into the parser](https://github.com/apache/datafusion-sqlparser-rs/pull/1435) (thanks again @Nyrox!), which we found slows things down a bit (see https://github.com/apache/datafusion-sqlparser-rs/pull/1435#issuecomment-2500664144).
Thankfully, I think there is significant room for improvement. As as part of the adding location information, I spent some time profiling and I think there are some obvious ways to improve the performance without impacting downstream crates.
Here is the flamegraph for anyone who is interested (you can download it locally to get zoom / etc):
[fixed-flamegraph](https://github.com/user-attachments/assets/7ceae3a0-dec2-462d-9a00-0b49afd9d2bc)

## What would you like to see?
The idea would be
1. Run the benchmarks (instructions in https://github.com/apache/datafusion-sqlparser-rs/pull/1555)
2. Maybe add additional benchmarks so they are more representative
3. Improve the benchmarks
## Ideas to improve performance:
- The most obvious one is to next_token / peek to not clone each `Token` (which involves copying strings)L: https://github.com/apache/datafusion-sqlparser-rs/issues/1558
- https://github.com/apache/datafusion-sqlparser-rs/issues/1381
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 PR #1555 中的基准测试说明开始,运行现有的基准测试,然后查看关联的 flamegraph 以及 issues #1558 和 #1381 中关于性能的想法。完成标准是在需要的地方添加具有代表性的基准测试,并在不对下游 crates 造成实质性影响的情况下改进 parser 性能。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- databases, performance
- Issue 类型
- 重构
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100