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

format imports is slow #89

Open
tjx666 opened this issue Dec 31, 2022 · 2 comments
Open

format imports is slow #89

tjx666 opened this issue Dec 31, 2022 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@tjx666
Copy link
Contributor

tjx666 commented Dec 31, 2022

Describe the bug

This happen in a large monorepo project.

[2022-12-31T17:17:20.334] [INFO] vscode.resolveConfig - Resolving config for fileName: /Users/yutengjing/code/xxx/packages/yyy/src/components/attribute-panel/element-panel/chart/utils/chart-category.ts languageId: typescript
[2022-12-31T17:17:20.413] [INFO] format-imports.extractOptions - Found ESLint rule import/newline-after-import: { count: 1 }
[2022-12-31T17:17:20.414] [INFO] format-imports.formatSource - Formatting /Users/yutengjing/code/xxx/packages/yyy/src/components/attribute-panel/element-panel/chart/utils/chart-category.ts with enhanced config: {
  configurationFileName: 'import-sorter.json',
  autoFormat: 'off',
  formatExports: true,
  exclude: [ 'node_modules' ],
  excludeGlob: [],
  sortImportsBy: 'paths',
  nodeProtocol: 'always',
  groupRules: [
    [ [Object], '^[@][^/]', {} ],
    { flags: 'named', regex: '^[.]' },
    [ [Object], [Object] ]
  ],
  sortRules: { paths: [ '_', 'aA' ], names: [ '_', 'aA' ] },
  keepUnused: [ '.*' ],
  emptyLinesBetweenGroups: 1,
  emptyLinesAfterAllImports: 1,
  removeLastSlashInPath: false,
  removeLastIndexInPath: false,
  wrappingStyle: 'prettier',
  development: { enableDebug: false },
  insertFinalNewline: true,
  eol: 'LF',
  force: false,
  maxLineLength: 100,
  tabType: 'space',
  tabSize: 4,
  hasSemicolon: true,
  quoteMark: 'single',
  trailingComma: 'multiLine',
  bracketSpacing: true,
  '$schema': './node_modules/format-imports/schemas/import-sorter.schema.json'
}
[2022-12-31T17:17:20.436] [INFO] vscode.formatDocument - Finished format
[2022-12-31T17:17:20.508] [INFO] vscode.resolveConfig - Resolving config for fileName: /Users/yutengjing/code/xxx/packages/yyy/src/components/attribute-panel/element-panel/chart/utils/chart-category.ts languageId: typescript
[2022-12-31T17:17:20.508] [INFO] vscode.formatDocument - Auto format is off

Expected behavior

should be faster, my ideal speed is to <= 50ms

Actual behavior

170ms ~ 200ms, however the prettier format can control under 50~100ms

Screenshots

2022-12-31.17.28.19.mov

OS (please complete the following information):

System:
OS: macOS 13.1
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory: 241.86 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh

VS Code (please complete the following information):

Version: 1.74.2 (Universal)
Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161
Date: 2022-12-20T10:26:09.430Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin x64 22.2.0
Sandboxed: No

package.json (please remove any sensitive info)

tsconfig.json (if any)

.prettierrc/.prettierrc.js/prettier.config.js/.prettierrc.toml (if any)
filename:

.editorconfig (if any)

Installed VS Code extensions
[Execute $ code --list-extensions in terminal to get the list. How to run VS Code from terminal in MacOS]

aaron-bond.better-comments
adam-bender.commit-message-editor
Adobe.extendscript-debug
alefragnani.read-only-indicator
amodio.tsl-problem-matcher
andersonbruceb.json-in-html
antfu.file-nesting
arichy.vscode-ast-explorer
berublan.vscode-log-viewer
bierner.color-info
bierner.emojisense
bierner.gif-player
bierner.jsdoc-markdown-highlighting
bierner.markdown-preview-github-styles
bodil.file-browser
brunnerh.file-properties-viewer
caiqichang.vscode-translation
chekweitan.compare-view
chrisdias.vscode-opennewinstance
chriskirknielsen.visubezier
chunsen.bracket-select
CodeQue.codeque
codezombiech.gitignore
colder.source-map-visualization
connor4312.esbuild-problem-matchers
cschleiden.vscode-github-actions
DavidAnson.vscode-markdownlint
dbaeumer.vscode-eslint
devonray.snippet
donjayamanne.githistory
dozerg.tsimportsorter
dracula-theme.theme-dracula
dtsvet.vscode-wasm
dzhavat.css-flexbox-cheatsheet
dzhavat.css-initial-value
eamodio.gitlens
ecmel.vscode-html-css
EditorConfig.EditorConfig
esbenp.prettier-vscode
formulahendry.code-runner
foxundermoon.shell-format
Gruntfuggly.todo-tree
haberdashPI.vscode-select-by-indent
idered.npm
infarkt.css-to-jss
ionutvmi.path-autocomplete
IronGeek.vscode-env
jakearl.search-editor-apply-changes
jjaakko.markdown-kbd
jock.svg
karenpommeroy.batch-rename
kisstkondoros.vscode-gutter-preview
L13RARY.l13-diff
liulongbin1314.escook-translate
medo64.render-crlf
meganrogge.template-string-converter
mhutchie.git-graph
mkxml.vscode-filesize
mrmlnc.vscode-scss
ms-vscode.hexeditor
ms-vscode.live-server
ms-vscode.vscode-typescript-next
octref.vetur
Orta.vscode-twoslash-queries
pomber.git-file-history
pomdtr.excalidraw-editor
pucelle.vscode-css-navigation
qcz.text-power-tools
redhat.vscode-xml
redhat.vscode-yaml
robole.snippets-ranger
rust-lang.rust-analyzer
saber2pr.ts-ast-viewer
sleistner.vscode-fileutils
streetsidesoftware.code-spell-checker
stylelint.vscode-stylelint
thzt.vscode-ast
trietho.file-size-explorer
uctakeoff.vscode-counter
ultram4rine.vscode-choosealicense
VisualStudioExptTeam.vscodeintellicode
vscode-icons-team.vscode-icons
Vue.volar
Vue.vscode-typescript-vue-plugin
vunguyentuan.vscode-css-variables
YuTengjing.adobe-extension-devtools
YuTengjing.modify-file-warning
YuTengjing.neo-vue-helper
YuTengjing.open-in-external-app
YuTengjing.scripting-listener
YuTengjing.view-github-repository
YuTengjing.vscode-archive
YuTengjing.vscode-colorize-plus
YuTengjing.vscode-fe-helper
YuTengjing.vscode-neo-file-utils
YuTengjing.vscode-versionlens-plus
YuTengjing.ytj-snippets
yzhang.markdown-all-in-one
zenghongtu.vscode-asciiflow2
zhaouv.vscode-markdown-draw
zhuangtongfa.material-theme
zyrong.node-modules
@tjx666
Copy link
Contributor Author

tjx666 commented Dec 31, 2022

Because I add it to codeActions, I can see a big delay after I cmd + s:

{
    "editor.codeActionsOnSave": {
        "source.addMissingImports": true,
        "source.fixAll.eslint": true,
        "source.fixAll.stylelint": true,
        "source.fixAll.markdownlint": true,
        "source.organizeImports.sortImports": true
    },
}

@tjx666
Copy link
Contributor Author

tjx666 commented Dec 31, 2022

I try to analyze why slow from extension log:

  1. format-imports seems try to get eslint rules info? I tiink it would be better to provide option instead of get eslint info. Like prettier, prettier hope user close all rules that should be handled by prettier.
  2. After Finish format, why resolve config again?

@daidodo daidodo added enhancement New feature or request help wanted Extra attention is needed labels Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants