简体   繁体   English

Linux vs Win运行时计时

[英]Linux vs Win runtime timings

I have an application which was ported from Windows to Linux. 我有一个从Windows移植到Linux的应用程序。 Now the same code compiles on VS C++ and g++, but there is a difference in performance when it's running on Win and when it's running on Linux. 现在,相同的代码可以在VS C ++和g ++上编译,但是在Win上运行和在Linux上运行时的性能有所不同。 The scope of this application is caching. 此应用程序的范围是缓存。 It's a node between a server and a client, and it's caching client requests and server response in a list, so that any other client which makes requests that was already processed by the server, this node will response instead of forwarding it to server. 它是服务器和客户端之间的节点,并且将客户端请求和服务器响应缓存在列表中,以便发出请求的其他任何客户端已经由服务器处理,此节点将响应而不是将其转发到服务器。

When this node runs on Windows, the client gets all it needs in about 7 seconds. 当此节点在Windows上运行时,客户端将在7秒钟内获得所需的全部信息。 But when same node is running on Linux (Ubuntu 9.04), the client starts up in 35 seconds. 但是,当同一节点在Linux(Ubuntu 9.04)上运行时,客户端将在35秒内启动。 Every test is from scratch. 每个测试都是从头开始的。 I'm trying to understand why is this timing difference. 我试图理解为什么这个时间差异。 A weird scenario is when the node is running on Linux but in a Virtual Machine, hosted by Win. 奇怪的情况是该节点在Linux上但在Win托管的虚拟机中运行。 In this case, load time is around 7 seconds, just like it was running Win natively. 在这种情况下,加载时间约为7秒,就像它在本地运行Win一样。 So, my impression is that there is a problem with networking. 因此,我的印象是网络存在问题。

This node is using UDP protocol for sending and receiving network data, and it's using boost::asio as implementation. 该节点使用UDP协议发送和接收网络数据,并且使用boost :: asio作为实现。 I tried to change all supported socket flags, changed buffer size, but nothing. 我试图更改所有受支持的套接字标志,更改了缓冲区大小,但是什么也没有。

Does someone know why is this happening, or any network settings related with UDP that might influence the performance? 有人知道为什么会这样吗,或者与UDP相关的任何网络设置可能会影响性能吗?

Thanks. 谢谢。

If you suspect a network problem take a network capture (Wireshark is great for this kind of problem) and look at the traffic. 如果您怀疑网络问题,请进行网络捕获(Wireshark非常适合此类问题),然后查看流量。

Find out where the time is being spent, either based on the network capture or based on the output of a profiler. 基于网络捕获或基于探查器的输出,找出将时间花费在哪里。 Once you know that you're half way to a solution. 一旦您知道您已经到了解决方案的一半。

These timing differences can depend on many factors, but the first one coming to mind is that you are using a modern Windows version. 这些时间上的差异可能取决于许多因素,但是首先想到的是您正在使用现代Windows版本。 XP already had features to keep recently used applications in memory, but in Vista this was much better optimized. XP已经具有将最近使用过的应用程序保留在内存中的功能,但是在Vista中,它的优化要好得多。 For each application you load, a special load file is created that is equal to how it looks in memory. 对于您加载的每个应用程序,都会创建一个特殊的加载文件,该文件等于它在内存中的外观。 Next time you load your application, it should go a lot faster. 下次加载应用程序时,它应该运行得更快。

I don't know about Linux, but it is very well possible that it needs to load your app completely each time. 我不了解Linux,但是很有可能每次都需要完全加载您的应用程序。 You can test the difference in performance between the two systems much better if you compare performance when running. 如果在运行时比较性能,则可以更好地测试两个系统之间的性能差异。 Leave your application open (if it is possible with your design) and compare again. 将您的应用程序保持打开状态(如果您的设计可行),然后再次进行比较。

These differences in how the system optimizes memory are backed up by your scenario using the VM approach. 您的方案使用VM方法来备份系统在优化内存方面的这些差异。

Basically, if you rule out other running applications and if you run your application in high priority mode, the performance should be close to equal, but it depends on whether you use operating system specific code, how you access the file system, how you you use the UDP protocol etc etc. 基本上,如果您排除其他正在运行的应用程序并且以高优先级模式运行应用程序,则性能应该接近相等,但是这取决于您是否使用操作系统特定的代码,如何访问文件系统以及如何使用使用UDP协议等

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

相关问题 scanmem(Linux)与CheatEngine(Win) - scanmem (Linux) vs. CheatEngine (Win) Win32(相对于Linux)的内存不足(?)问题 - Out of memory (?) problem on Win32 (vs. Linux) pthread条件变量vs win32事件(linux vs windows-ce) - pthread condition variables vs win32 events (linux vs windows-ce) 无法为LVDS显示配置时序(rk3288上的linux) - trouble configuring timings for LVDS display (linux on rk3288) Linux DRM(直接渲染管理器)自定义分辨率和时间 - Linux DRM (Direct Rendering Manager) custom resolution and timings 为什么多线程Java程序在“超级”Linux服务器和笔记本电脑Win7上的速度不快? - Why is multithreaded Java Program not faster on 'super' Linux server vs laptop Win7? Linux与Windows,C ++运行时在读取CSV文件方面的性能差异 - Linux vs Windows, C++ runtime performance difference over reading CSV file Win 10 -> VS 2019 -> .NET Core 3 WPF 应用程序 -> 发布到目录(对于 linux-x64 自包含) -> 发布失败 - Win 10 -> VS 2019 -> .NET Core 3 WPF application -> Publish to directory (self-contained for linux-x64) -> Publish failed Linux中的运行时exec问题 - Runtime exec issues in Linux 测量Linux中应用程序的运行时 - Measuring the Runtime of Applications in Linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM