且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与 32 位相比,64 位对于 Visual Studio Code 的可量化优势是什么?

更新时间:2023-02-27 14:47:27

64 位 Visual Studio Code 的存在很大程度上是 Node.js- 和基于 Chromium 的运行时Electron 支持 32 位和 64 位架构,这不是应用程序的主要设计目标.Microsoft 使用 Electron 开发了 VS Code,这是一个用于使用 Web 技术构建桌面应用程序的框架.

The existence of 64-bit Visual Studio Code is largely a side-effect of the fact that the Node.js- and Chromium-based runtimes of Electron support both 32- and 64-bit architectures, not a primary design goal for the application. Microsoft developed VS Code with Electron, a framework used to build desktop applications with web technologies.

因为 Electron 已经包含了适用于两种架构(以及适用于不同操作系统)的运行时,所以 VS Code 可以提供两个版本而无需额外的努力——Electron 从 JavaScript 代码中抽象出机器之间的差异.

Because Electron already includes runtimes for both architectures (and for different operating systems), VS Code can provide both versions with little additional effort—Electron abstracts the differences between machines from the JavaScript code.

相比之下,Microsoft 将大部分 Visual Studio 分发为包含机器特定指令的编译二进制文件,并且重写和维护 64 位源代码的成本历来超过任何好处.一般来说,如果 64 位程序从不超过 32 位系统的限制,那么它对最终用户来说并不比 32 位程序明显快.Visual Studio 的 IDE shell 没有做太多繁重的工作——典型工作流中的大部分昂贵处理都是由通常支持 64 位系统的集成工具链(编译器等)执行的.

By contrast, Microsoft distributes much of Visual Studio as compiled binaries that contain machine-specific instructions, and the cost of rewriting and maintaining the source code for 64-bits historically outweighed any benefits. In general, a 64-bit program isn't noticeably faster to the end user than its 32-bit counterpart if it never exceeds the limitations of a 32-bit system. Visual Studio's IDE shell doesn't do much heavy-lifting—the bulk of the expensive processing in a typical workflow is performed by the integrated toolchains (compilers, etc.) which usually support 64-bit systems.

考虑到这一点,我们从运行 64 位版本的 VS Code 中可能注意到的任何好处与我们从使用 64 位 Web 浏览器中看到的好处相似.最重要的是,64 位版本可以处理超过 4 GB 的内存,如果我们需要同时打开大量文件或非常大文件,这可能很重要,或者如果我们使用许多扩展.所以—对我们开发人员来说最重要的是—编辑器在滥用时不会耗尽内存.

With this in mind, any benefits we may notice from running a 64-bit version of VS Code are similar to those we would see from using a 64-bit web browser. Most significantly, a 64-bit version can address more than 4 GB of memory, which may matter if we need to open a lot of files simultaneously or very large files, or if we use many heavy extensions. So—most important to us developers—the editor won't run out of memory when abused.

虽然这听起来像是一项值得签署的保险单,但即使我们从未达到这些内存限制,请记住,64 位应用程序通常比 32 位应用程序消耗更多内存.如果我们需要较小的内存占用,我们可能希望选择 32 位版本.大多数开发者可能永远不会达到 4 GB 的上限.

While this sounds like an insurance policy worth signing, even if we never hit those memory limits, remember that 64-bit applications generally consume more memory than their 32-bit counterparts. We may want to choose the 32-bit version if we desire a smaller memory footprint. Most developers may never hit that 4 GB wall.

在极少数情况下,如果我们使用包装本机代码(如为特定架构构建的 DLL)的扩展,我们可能需要选择 32 位或 64 位版本.

In rare cases, we may need to choose either a 32-bit or 64-bit version if we use an extension that wraps native code like a DLL built for a specific architecture.

我们在使用 64 位版本的 VSCode 时遇到的任何其他后果,无论是正面的还是负面的,都取决于 Electron 的底层运行时组件的版本以及它们运行的​​操作系统.这些特征随着开发的进行而不断变化.出于这个原因,很难笼统地说 32 位或 64 位版本优于另一个.

Any other consequences, positive or negative, that we experience from using a 64-bit version of VSCode depend on the versions of Electron's underlying runtime components and the operating system they run on. These characteristics change continuously as development progresses. For this reason, it's difficult to state in a general manner that the 32-bit or 64-bit versions outperform the other.

例如,V8 JavaScript 引擎过去禁用了今天启用的 64 位系统上的一些优化.某些优化只有在操作系统为其提供便利时才可用.

For example, the V8 JavaScript engine historically disabled some optimizations on 64-bit systems that are enabled today. Certain optimizations are only available when the operating system provides facilities for them.

Windows 上的未来 64 位版本可能会利用地址空间布局随机化来提高安全性(地址空间中的更多位会增加熵).

Future 64-bit versions on Windows may take advantage of address space layout randomization for improved security (more bits in the address space increases entropy).

对于大多数用户来说,这些细微差别真的无关紧要.选择与您的系统架构相匹配的版本,并仅在遇到问题时才保留切换.编辑器的更新将继续为其底层组件带来优化.如果资源使用是一个大问题,您可能不想首先使用 GUI 编辑器.

For most users, these nuances really don't matter. Choose a version that matches the architecture of your system, and reserve switching only if you encounter problems. Updates to the editor will continue to bring optimizations for its underlying components. If resource usage is big concern, you may not want to use a GUI editor in the first place.