Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prettier.format() slow for deeply nested function calls in input string #4672

Closed
tony19 opened this issue Jun 12, 2018 · 3 comments
Closed
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:perf Issue with performance of Prettier

Comments

@tony19
Copy link
Contributor

tony19 commented Jun 12, 2018

When the input string contains many (about 25) nested function calls in JavaScript, prettier.format() takes about 2.5 minutes to return. This seems to occur when coreFormat() converts the AST to a document (in printAstToDoc()).

Environment:

  • macOS High Sierra 10.13.4
  • Node 8.9.4 and 9.11.1
  • MacBook Pro 2017, 2.7GHz i7, 16GB 2133MHz LPDDR3

Prettier 1.13.5
Playground link

Input:

_c("div", [
  _c("div", [
    _c("div", [
      _c("div", [
        _c("div", [
          _c("div", [
            _c("div", [
              _c("div", [
                _c("div", [
                  _c("div", [
                    _c("div", [
                      _c("div", [
                        _c("div", [
                          _c("div", [
                            _c("div", [
                              _c("div", [
                                _c("div", [
                                  _c("div", [
                                    _c("div", [
                                      _c("div", [
                                        _c("div", [
                                          _c("div", [
                                            _c("div", [_c("div", [_c("div")])])
                                          ])
                                        ])
                                      ])
                                    ])
                                  ])
                                ])
                              ])
                            ])
                          ])
                        ])
                      ])
                    ])
                  ])
                ])
              ])
            ])
          ])
        ])
      ])
    ])
  ])
])

Output:
(same as input after 159 seconds)

Expected behavior:
prettier.format(input) returns within a few seconds (much sooner than 159 seconds)

@ikatyang ikatyang added lang:javascript Issues affecting JS type:perf Issue with performance of Prettier labels Jun 12, 2018
@tony19
Copy link
Contributor Author

tony19 commented Jun 13, 2018

Possibly related to #1250 and #2259

@fisker
Copy link
Member

fisker commented May 22, 2020

This is not slow anymore, not sure how and when it got improved

@thorn0
Copy link
Member

thorn0 commented May 22, 2020

#6229 fixed it most probably.

@thorn0 thorn0 closed this as completed May 22, 2020
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Aug 21, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:perf Issue with performance of Prettier
Projects
None yet
Development

No branches or pull requests

4 participants