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

fix: improve repl/variable/completion performance for TS #1473

Merged
merged 3 commits into from
Dec 9, 2022

Conversation

connor4312
Copy link
Member

Fixes #1433

There were a couple problems:

  • TS uses a customDescriptionGenerator. Previously this was being invoked on each individual property. I've merged this with the logic we added for custom toString() representations, so that we run it only once for an object and return a map of its properties.
  • TS has thousands of variables in each scope. We call Runtime.getProperties to get scope variables to use in completions. It seems like getProperties, which does not have any 'limit' parameter, is blocking. We still need this to do sensible completions, but now each stacktrace caches its completions instead of getting new ones on every request.

With these changes, there may still be a little REPL stall on the first evaluation (until the first completions call finishes, which takes 3-5s on my macbook), but after that it should be appropriately snappy.

Fixes #1433

There were a couple problems:

- TS uses a `customDescriptionGenerator`. Previously this was being
  invoked on each individual property. I've merged this with the logic
  we added for custom `toString()` representations, so that we run it
  only once for an object and return a map of its properties.
- TS has thousands of variables in each scope. We call `Runtime.getProperties`
  to get scope variables to use in completions. It seems like getProperties,
  which does not have any 'limit' parameter, is blocking. We still need
  this to do sensible completions, but now each stacktrace caches its
  completions instead of getting new ones on every request.

With these changes, there may still be a little REPL stall on the first
evaluation (until the first completions call finishes, which takes 3-5s
on my macbook), but after that it should be appropriately snappy.
@connor4312 connor4312 force-pushed the fix/ts-completion-improvements branch from d6e916e to 647a933 Compare December 8, 2022 23:20
@connor4312
Copy link
Member Author

Updated test fixtures to make tests happy. The issue was previously we showed the custom description in the [[Prototype]] of an object. But this doesn't exist (reliably/safely) at runtime, so the new approach doesn't get it. I think that's fine, perhaps even desirable.


constructor(
@inject(IRenameProvider) private readonly renameProvider: IRenameProvider,
@inject(ICdpApi) private readonly cdp: Cdp.Api,
@inject(IDapApi) private readonly dap: Dap.Api,
@inject(AnyLaunchConfiguration) private readonly launchConfig: AnyLaunchConfiguration,
private readonly locationProvider: IVariableStoreLocationProvider,
) {}
) {
this.contextSettings = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we were code-genning every time we made a preview for a variable. Fortunately Acorn is pretty speedy, but we can precompute that instead easily :)

src/adapter/templates/getStringyProps.ts Outdated Show resolved Hide resolved
src/adapter/templates/getStringyProps.ts Outdated Show resolved Hide resolved
src/adapter/variableStore.ts Outdated Show resolved Hide resolved
src/adapter/variableStore.ts Outdated Show resolved Hide resolved
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests failing?

@connor4312
Copy link
Member Author

flake that I need to fix

@connor4312 connor4312 merged commit 059d704 into main Dec 9, 2022
@connor4312 connor4312 deleted the fix/ts-completion-improvements branch December 9, 2022 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug console very slow when debugging new module-ified/bundled TypeScript compiler
2 participants