Skip to content

Conversation

@dgieselaar
Copy link
Member

@dgieselaar dgieselaar commented Oct 22, 2019

This is an experiment/attempt to speed up TypeScript suggestions and code navigation by splitting up the main TS projects (Kibana and X-Pack) into lots of smaller TypeScript projects (e.g., one for each X-Pack plugin). I've personally seen TS latency improve from 20s to sub-second response times.

Previously I investigated creating an APM specific TypeScript config that extends the X-Pack one, and there's some pretty big speed improvements for APM source files. However, type resolution from npm modules is still slow because the TS server has to jump back and forth between the APM TS project and the X-Pack one, resulting in latency of up to 20s for suggestions and navigation.

This PR removes the files from the Kibana/X-Pack TypeScript projects and creates more granular configurations for sub-projects, like ./src, or x-pack/plugins, or x-pack/legacy/plugins/apm. This means that even if TypeScript has to switch projects, start up time is much faster because the project is smaller.

To get a good comparison, I've checked out kibana in a separate directory, and opened that in vs code. In another instance of vs code, I've opened just the APM folder. In both instances, typescript.tsserver.trace is set to messages in order to get back some latency numbers. I then close down all tabs to stop the TS server, and then open one file (in this case, x-pack/legacy/plugins/apm/public/components/shared/ApmHeader/index.tsx) to see how responsive feedback is. What I see is that it takes about 35s vs 8s to start up TypeScript, and when navigating to react (cmd + click), it takes about 10s vs 300ms.

One downside is that type checking the whole of X-Pack is now around 3m30s instead of the ~1m it was before, but type checking the APM plugin for instance takes around 15s, so it is likely still a net win for most of us.

Would like to get some others to try this out and some feedback from operations whether this is a sensible approach. Keeping this in draft because I don't want to ping all the code owners.

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't think this is needed anymore, I moved the declaration that it needed to x-pack/typings.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

Adds a template for a tsconfig.json file that only type checks APM files.
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team:Operations Kibana-Operations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants