Skip to content

Four calls to Parser.parse cause performance issues #552

@TomerAberbach

Description

@TomerAberbach

Hey! We've been using ktfmt for our generated SDKs at Stainless. We've found the formatter can be slow sometimes due to the size of the SDKs we generate (the larger the API, the larger the generated SDK).

I decided to do some profiling and I found Parser.parse takes a significant amount of time (ktfmt-flamegraph.html.zip attached for running anthropic-sdk-java) because it's called four times per file.

Do you think it's possible to ensure each file gets parsed exactly once? I recognize it's not a trivial problem because subsequent transformations would somehow need to take into account edits from previous transformations, but seems like a worthwhile investment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions