Skip to content

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

@echou

Description

@echou

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions