简体   繁体   English

.Net 3.5 Windows Forms应用程序:64位Vista上x86与x64的加载时间

[英].Net 3.5 Windows Forms Application: x86 vs x64 load times on 64 bit Vista

We are developing a Winforms application and in the process of optimizing the start-up time. 我们正在开发Winforms应用程序,并正在优化启动时间。

The app runs on 64 bit Vista machines. 该应用程序可在64位Vista计算机上运行。 In our testing we found what seems like a counter intuitive result. 在我们的测试中,我们发现了看起来与直觉相反的结果。 All else equal, targeting 32-bit vs 64-bit loads in half the time. 其他所有条件都相同,只需一半的时间即可针对32位和64位负载。 Can anyone shed some light as to why? 谁能阐明为什么?

Thanks. 谢谢。

[Edit] We deploy the app via ClickOnce which, from our research starts apps in a unique sandbox. [编辑]我们通过ClickOnce部署应用程序,根据我们的研究,该应用程序将在一个独特的沙箱中启动应用程序。 Therefore it always cold-starts so looking to improve performance here was fruitless. 因此,它总是冷启动,因此在这里寻求改善性能是徒劳的。

Our main problem was the existence of 32-bit dlls in the project. 我们的主要问题是项目中存在32位dll。 Once we targeted the project at x86 (even though it runs on x64) the load times were cut in half. 一旦我们将项目定位在x86上(即使它在x64上运行),那么加载时间就会缩短一半。 [/Edit] [/编辑]

.NET 3.5 SP1 gets its improved startup perf by no longer verifying the strong name of assemblies that come from trusted locations. .NET 3.5 SP1通过不再验证来自受信任位置的程序集的强名称来提高其启动性能。 A bit controversial in my book but somewhat defensible. 我的书有些争议,但有些道理。

I did check if the 64-bit version of the CLR also bypasses that time-consuming step. 我确实检查了64位版本的CLR是否也绕过了这一耗时的步骤。 Signed a DLL, put it in the GAC, then patched a byte. 对DLL签名,将其放入GAC中,然后修补一个字节。 No complaints when loading the assembly. 装配件时无怨言。 So it is not the SP1 startup pref improvement that explains the difference. 因此,差异的原因不是SP1启动首选项的改进。

Other factors in the startup time are: - Loading the CLR from disk (coldstart only) - Groveling for the dependent assemblies - JIT compiling the startup code 启动时间中的其他因素包括:-从磁盘加载CLR(仅适用于Coldstart)-依赖程序集的合并-JIT编译启动代码

Coldstart could well be a factor, you probably don't have other processes running that have the 64-bit version of the CLR loaded. 冷启动很可能是一个因素,您可能没有其他正在运行加载了64位版本的CLR的进程。 Easy to eliminate by running a dummy .NET app while you do the test. 在执行测试时,通过运行虚拟.NET应用程序可以轻松消除这种情况。

Groveling assemblies could take longer for the same reason. 出于同样的原因,装配装配可能需要更长的时间。 It is unlikely that the 64-bit ngen-ed images of the .NET assemblies are in the file system cache. .NET程序集的64位ngen-ed映像不太可能位于文件系统缓存中。 Again, easy to eliminate with the dummy app having a dependency on the same assemblies. 同样,由于虚拟应用程序依赖于相同的程序集,因此很容易消除。

The 64-bit JITter is a tougher nut to crack. 64位JITter是更难破解的螺母。 An arbitrary call is to assume that MSFT didn't spend as much time making that one performant as the 32-bit JITter. 一个任意调用是假定MSFT花费的时间不如32位JITter那样多。 Nothing backed-up by any evidence though. 虽然没有任何证据支持。 Difficult to measure too, you'd have load an assembly with Assembly.Load, then time Activator.CreateInstance() where the class constructor calls as much code as possible. 也很难测量,您需要使用Assembly.Load加载程序集,然后使用Activator.CreateInstance()进行加载,其中类构造函数将调用尽可能多的代码。

The 64-bit version would typically use twice as much memory on the heap: each pointer takes twice as much space, and .NET is full of pointers. 64位版本通常在堆上使用两倍的内存:每个指针占用两倍的空间,.NET充满了指针。 As startup heavily influenced by memory initialization, this may account for part of the additional overhead. 由于启动受内存初始化的影响很大,因此这可能占部分额外开销。 Refer also Donald Knuth's flame about 64-bit pointers . 另请参阅Donald Knuth关于64位指针的内容

请注意,根据Microsoft的说法,.Net 3.5 SP1在启动性能方面做了很多工作(某些应用程序最多可提高40%),因此您可能会发现这是否也有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM