High compile time of crates using sqlparser(codegen phase) - any way to reduce generated code?​​

未关闭
#2,066 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
重构
描述清晰度
需要澄清
活跃度
停滞
技术栈
rust
领域
performance

调研方向

首先使用 cargo llvm-lines 重现报告中的编译配置,并检查为报告中提到的 AST 类型生成的 VisitMut 实现。比较采用任何方案前后的代码生成规模和编译时间;在不破坏 visitor 行为的情况下,证明生成代码量或编译时间有所减少,即表示完成。

由索引模型根据 Issue 内容生成。

描述

In my project, some crates have very long compilation times (e.g., 40-50 seconds, with the codegen phase accounting for 70%-90% of that time). I suspect these crates are slow to compile due to their dependency on sqlparser.

I analyzed the compilation of one such crate using cargo llvm-lines. The top functions by lines are listed below:

Lines                  Copies               Function name
  -----                  ------               -------------
  2180708                31532                (TOTAL)
   220326 (10.1%, 10.1%)    21 (0.1%,  0.1%)  <sqlparser::ast::Statement as sqlparser::ast::visitor::VisitMut>::visit
   163970 (7.5%, 17.6%)   1995 (6.3%,  6.4%)  <alloc::vec::Vec<T> as sqlparser::ast::visitor::VisitMut>::visit
   117960 (5.4%, 23.0%)   3654 (11.6%, 18.0%) <core::option::Option<T> as sqlparser::ast::visitor::VisitMut>::visit
    76507 (3.5%, 26.5%)     21 (0.1%, 18.0%)  <sqlparser::ast::Expr as sqlparser::ast::visitor::VisitMut>::visit

As shown, the visitor trait implementations for the AST types generate a significant amount of code. Is there any way to reduce the code generation footprint of sqlparser?

主要语言
Rust
星标
3.5k
派生
774
平均合并
3 天 4 小时
30 天内合并 PR
19

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/datafusion-sqlparser-rs 的其他 Issue

查看 apache/datafusion-sqlparser-rs 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。