部署时 Portable 和 win-x64 有什么区别? [英] What are differences between Portable and win-x64 when deploying?

查看:181
本文介绍了部署时 Portable 和 win-x64 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的代码部署到 Windows Server 2016 上的 IIS,我试图了解在发布/设置/目标中选择 Portablewin-x64 之间的有效区别运行时下拉菜单.

I deploy my code to IIS on Windows Server 2016 and I am trying to understand the effective difference between selecting Portable vs win-x64 in the Publish/Settings/Target Runtime dropdown.

由于 JIT 需要将代码编译到特定的架构,所以网站在 Portable 下启动会花费更长的时间吗?还有别的事吗?

Will the site take longer to start under Portable because the JIT needs to compile the code to the specific architecture? Is there anything else?

推荐答案

编辑 - 简答

如果您选择portable,则每次应用启动时,它都需要对实际执行的应用部分进行JIT 编译.如果您的应用程序很大,则性能可能会受到影响.

If you choose portable, every time the app starts up it will need to go through JIT compilation on the parts of the application that actually execute. If your application is large, the performance can be impacted.

如果您选择 x64,应用程序将不会因编译而变慢,因为这已经由构建机器(您的笔记本电脑)上的发布过程完成.

If you choose x64, the application will not slow down from compilation, because that is already done by the publish process on the build machine (your laptop).

原答案

当您选择 Portable 发布选项时,您将获得一个能够在 x86(32 位)机器和 x64(64 位)机器上运行的包.选择可移植选项后,在应用程序启动时,您将在应用程序保持运行时获得目标机器(x64 或 x86)的 JIT 编译代码.但是,如果应用程序关闭,所有经过 JIT 编译的代码都将丢失.编译后的代码会保存在内存中,直到应用程序进程结束.下一次运行必须在使用时再次 JIT 编译应用程序.这样做的好处是你只需要分发一个包,它就可以在两台 x86/x64 机器上运行.

When you choose the Portable publish option, you'll get a package that is capable of running on either x86 (32-bit) machines and x64 (64-bit) machines. With the portable option selected, on application launch you'll get JIT compiled code for the target machine (either x64 or x86) as the application stays running. However, if the application closes, all the code that was JIT compiled would be lost. The compiled code sits in memory until the application process ends. The next run would have to JIT compile the application again as it is used. The advantage here is that you'd only need to distribute one package, and it'll run on both x86/x64 machines.

另一种方法是生成多个包,一个用于您打算分发应用程序的每个目标平台.在这种情况下,您将获得已编译的特定于机器的包,即使在应用程序进程结束并稍后重新启动后也不需要重新编译.在这种情况下,您的应用程序将看起来运行得更快,因为编译只在构建服务器/机器上完成一次.但是,它确实会影响您的部署风格.

The alternative is generating multiple packages, one for each target platform you intend to distribute your application on though. In this case, you'll get machine-specific packages that are already compiled, and do not require recompilation even after the application process ends and is restarted later. In this case your application will appear to run faster since the compilation is done once and only once, on the build server / machine. However it does impact your deployment style.

可以在此处找到有关 .NET 运行时标识符的更多信息:https://docs.microsoft.com/en-us/dotnet/core/rid-catalog

More information on .NET runtime identifiers can be found here: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog

关于 JIT 编译代码的好文档在这里:https://www.telerik.com/blogs/understanding-net-just-in-time-compilation

And a good document on JIT compiled code is here: https://www.telerik.com/blogs/understanding-net-just-in-time-compilation

这篇关于部署时 Portable 和 win-x64 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆