TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Speeding up VSCode extensions in 2022

179 点作者 jayflux超过 3 年前

6 条评论

jjwiseman超过 3 年前
One idea for speedups that this article doesn&#x27;t mention, that I&#x27;ve used very successfully, is splitting an extension into two parts: The Javascript extension that runs in VS Code, and a separate language server[1] written in whatever fast language you desire (without having to compile to WASM).<p>I do this with an extension I develop, and it works very well. Microsoft even provides a library to make this easy, and sample code[2]. In my case the language server is written in Rust, and uses tree-sitter. This combination feels like a super power. (The first version of my extension was written in clojurescript, using the instaparse parser. It quickly became apparent that it was way too slow.)<p>A note on my experience with tree-sitter: It&#x27;s awesome in every way except one. It&#x27;s so fast that so far I haven&#x27;t even bothered with incremental parsing: I can do full parsing on every keystroke; and I know that if I ever need a speed boost, I can add incremental parsing. The API is sane and easy to use. The query API is powerful. But the main weakness of tree-sitter is that the error messages are nearly content-free. The most common error looks like this: &quot;(error)&quot;. In my case I can deal with that, but I can imagine that for many purposes that&#x27;s not sufficient. There&#x27;s been an issue open for 3 years about improving the error messages[3] but I haven&#x27;t seen a ton of progress (unless I missed it?).<p>1. <a href="https:&#x2F;&#x2F;microsoft.github.io&#x2F;language-server-protocol&#x2F;specification" rel="nofollow">https:&#x2F;&#x2F;microsoft.github.io&#x2F;language-server-protocol&#x2F;specifi...</a> 2. <a href="https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;vscode-extension-samples&#x2F;tree&#x2F;main&#x2F;lsp-sample" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;vscode-extension-samples&#x2F;tree&#x2F;m...</a> 3. <a href="https:&#x2F;&#x2F;github.com&#x2F;tree-sitter&#x2F;tree-sitter&#x2F;issues&#x2F;255" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tree-sitter&#x2F;tree-sitter&#x2F;issues&#x2F;255</a>
评论 #30119318 未加载
评论 #30119166 未加载
评论 #30119546 未加载
评论 #30118879 未加载
eyelidlessness超过 3 年前
Speaking of tree-sitter, I’ve been experimenting with it for a static analysis and codegen idea and… wow it is fast. And super easy to use. I threw together a naive TypeScript type-stripping “compiler”, using the Node bindings so it’s got a couple bottlenecks. It’s within spitting distance of esbuild for a huge (10k loc) real world module (about 80-90ms vs ESBuild’s 20-30ms), and sometimes faster than esbuild for small (50-100 loc) modules. Granted it’s not doing everything esbuild does. But it was a quick experiment with a familiar domain before I go further. Quick as in mostly working within a few hours, and naively optimized for large source content in another hour.<p>The WASM bindings also perform very well (better in some cases), so it can be used anywhere WASM can. Which, it seems to me, means it’s a very good candidate to replace Babel without depending on language-specific tooling like SWC&#x2F;Rome&#x2F;Bun.
speedgoose超过 3 年前
Tree-sitter is interesting. I see that it is used by the Github Copilot extension for VS-Code, which is the slowest on my machine because it somehow contains megabytes of minified javascript and webassembly to call a remote API.
duped超过 3 年前
The tokenization speed issue is already addressed by the language server protocol, which delegates syntax highlighting to language servers via the &quot;semantic tokens&quot; API. Language servers can choose to implement this however they want, and the API allows for incremental additions.<p>I think this is a much better approach that baking tree sitter into VS Code and continuing to use TextMate grammars (or tree sitter specific grammars) to add syntax highlighting. That way it can be applied to any editor that supports LSP integration. Really the world would be a better place for IDEs and text editors if we could just get LSP more standardized, and VS Code&#x27;s dominance is a decent place to start with it. I&#x27;m tired of relying on editor and IDE authors for language support.
评论 #30116936 未加载
评论 #30116886 未加载
评论 #30117017 未加载
Veuxdo超过 3 年前
Can we stop with the &quot;in 2022&quot; headlines?
评论 #30117209 未加载
评论 #30120941 未加载
评论 #30117633 未加载
egg1超过 3 年前
The more I read about VSCode and Electron apps in general, the more I&#x27;m convinced that all this effort is akin to putting lipstick on a pig. Modern CPU designs have all converged on multi-core as the solution to increasing performance, and yet on the software side of things... we&#x27;ve turned all of our desktop applications into Chrome instances running single-threaded event loops. That these extensions are even more poorly optimized is more icing on the cake.
评论 #30120067 未加载
评论 #30117533 未加载
评论 #30118144 未加载
评论 #30117592 未加载
评论 #30118652 未加载
评论 #30121462 未加载
评论 #30120724 未加载
评论 #30117605 未加载