Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 2, 2022 09:53 pm GMT

Faster JetBrains IDEs with shared indexes

If you develop with IntelliJ IDEA, PyCharm, GoLand, or other JetBrains IDEs, its likely youve waited for indexing to complete after opening a project. While this may be annoying, its necessary for IntelliJ and other heavy-weight IDEs to have features such as code search, highlighting, refactoring, and code completion.

Waiting for an IDE to finish indexing a project might not be a big problem for many workflows. After the first load, indexes are cached and subsequent runs are faster. However, indexing time can be a huge blocker for developers, especially in these cases:

  • large projects (monorepos, many dependencies, monolithic applications)

  • running old/slow machines (indexing is CPU-intensive)

  • ephemeral developer workspaces (containers, remote IDEs)

edit of xkcd's "compiling" comic: https://xkcd.com/303/

In this post, well cover how shared indexes can significantly reduce IDE load times, share some examples, and a one-line command to generate these for your project. (Historically, shared indexes have been difficult to set up)

First, how indexing works

Indexing works by traversing the projects codebase to create a virtual map of classes, methods, and objects for future lookups. After the index is generated, it is cached on your device for later use.

Indexing a codebase will likely take the longest the first time you open it on your machine. When the codebase changes, such as pulling code or switching branches, your indexes will update, but significantly faster than the first time.

Shared indexes

Shared indexes make it possible to host pre-generated indexes for others to download, significantly improving loading speeds across your team. These remote indexes work in conjunction with local indexing to ensure your IDE always has up-to-date information on the codebase.

Comparison: local vs shared indexesGIF: Loading the code-server project in WebStorm

Generating shared indexes for your project

JetBrains has a guide for creating shared indexes, but it involves many steps, including downloading custom tooling and uploading indexes to a CDN. It also lacks instructions for automating this process, to generate indexes in CI, for example.

Using a Docker container to generate shared indexes makes it simple to try locally or automate with cron/CI:

cd your_large_codebase/# generate shared indexesdocker run -it --rm \  -v "$(pwd)":/var/project \  -v "$HOME"/indexes-output:/shared-index \  -e INDEXES_CDN_URL=https://cdn.myserver.com/project \    -u "$(id -u):$(id -g)" \  bencdr/indexer:idea-2021.3

After generating indexes, you can upload the output folder to your CDN, or a local server. You can also use shared indexes without a CDN by using a network share or even your local filesystem for testing. Check out my GitHub repo for details:

GitHub logo bpmct / jetbrains-indexer

Generate & package JetBrains shared indexes with a Docker container.

Benchmarking shared indexes

I tested indexing time for some popular projects on my 2019 MacBook Pro. To benchmark your own projects, File Invalidate Caches in your IDE will allow you to opt in/out of downloading shared indexes to simulate first launching your project.

ProjectLanguage(s)Local indexing With shared indexes Improvement %
kubernetes/kubernetesGo2m 40s22s727%
cdr/code-serverTypescript2m 30s34s441%
Coder internal monorepoGo & Typescript3m 20s32s625%
jetbrains/intellij-communityJava6m 30s2m 15s288%

These times were averaged across two test runs. Your mileage will vary depending on network speeds, device performance, etc.

Remote development & shared indexes

Recently, JetBrains released remote development support, making it simple to develop from powerful, remote workspaces. On-demand workspaces have a lot of benefits, such as faster onboarding and better reproducibility. However, first-time indexing happens much more frequently, since, after all, workspaces are meant to be ephemeral.

Shared indexes work with Coder, our remote development platform. Coder supports all JetBrains IDEs locally, or via the web browser. If you dont want to host a CDN for shared indexes, you can include them in the workspace image, so everything loads in a snap

If youd like to learn more about Coder, you can request a demo or try it for free.

References


Original Link: https://dev.to/coder/faster-jetbrains-ides-with-shared-indexes-10n1

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To