Winsock closesocket() 性能(本地计算机,127.0.0.1):为什么在某些计算机上如此慢而在其他计算机上却非常快?
我正在努力解决与关闭 C# 代码中的数据库连接相关的奇怪性能问题。我们在本地计算机上使用名为 Raima 的数据库服务器(仅通过本地 TCP 连接 127.0.0.1 到同一台计算机上的本地数据库服务器,而不是跨 LAN)通过其本机 Raima API(不是 ADO.NET,只是 .NET)包装纸)。
问题在于,在许多计算机(高性能双核或四核计算机)上,关闭大部分时间大约需要 120ms-250ms(例如,.NET C# Web 服务中为 120ms,.NET C# Windows 应用程序中为 250ms) )而在其他计算机上只需要 4 毫秒(稳定)。让我困惑的是,在某些计算机上,例如,大多数情况下,它是 120 毫秒,但有时它可能会跳至 4 毫秒。
我们的数据库供应商 (Raima) 告诉我们他们对此无能为力,因为这些速度下降是由 Winsock 方法 closesocket() 引起的。
所以我的问题是,Winsock closesocket() 是否真的可能会导致本地计算机上出现此类速度减慢?或者说,这毕竟只是数据库供应商及其缓慢的数据库驱动程序/服务器的问题?
谢谢!
I'm struggling with an odd performance problem related to closing database connections in my C# code. We are using a database server called Raima on a local computer (only local TCP connection 127.0.0.1 to the local database server on the same computer, not across a LAN) via its native Raima API (not ADO.NET, just a .NET wrapper).
The problem is that on many computers (high-performance dual-core or quad-core computers) the closing takes about 120ms-250ms most of the time (e.g. 120ms in a .NET C# web service and 250ms in a .NET C# Windows application) while on the other computers it takes only 4ms (steady). What confuses me is that on some computers it's, for example, 120ms most of the time, but occasionally it may jump to 4ms.
Our database vendor (Raima) has told us that they can't do anything about it because these slowdowns are caused by the Winsock method closesocket().
So my question is that is it true that Winsock closesocket() may cause these kinds of slowdowns on a local computer? Or is it, after all, just about the database vendor and their slow database driver/server?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议你使用性能工具/压力测试工具来测试你的raima(你称之为);使用网络工具测试您的网络;使用其他数据库(免费版的 SQL Server、IBM DB2、MySQL、Oracle 等)安装您的计算机,并尝试连接它并计算其性能。
AFAIK这不是winsock实现,它是计算机配置。如果所有数据库都变慢,那么您可以怀疑winsock。
如果一切都很慢,也许你可以提到升级硬件。
如果除了raima 之外其他都快的话。您可能怀疑 raima 数据库速度很慢。
如果您像往常一样遇到连接困难(例如断开连接),只需更换 LAN 电缆即可。
I suggest you test your raima (you call it) using performance tools / stress tess tools; test your network using networking tools; install your computer using other database (free edition of SQL server, IBM DB2, MySQL, Oracle and others) and try to connect it and count its performance.
AFAIK it is not winsock implementation, it is computer configuration. If all database is slowdown so you can suspect of winsock.
If all is slow, perhaps you can mention to upgrade hardware.
If all except raima is fast. you can suspect raima database is slow.
If you have difficulty on connection like disconnection as always, just change your LAN cable.
我叫 Jason,来自 Raima。希望您早在 2011 年就收到了我们关于此问题的电子邮件,但对于遇到此性能问题的其他人,我们将解释如何解决此问题:
性能问题出现在 closesocket() 中,并解释说我们对此无能为力。紧接着,我们的一位工程师发现我们正在使用 SO_LINGER 选项,这会导致 closesocket() 阻塞,直到所有未完成的数据都已发送后再返回。我们删除了此选项并于 2011 年 10 月 11 日发送了补丁。在 SO_LINGER 关闭的情况下,closesocket() 函数仍将在关闭套接字之前发送未完成的数据,但它可能会在此操作完成之前返回。该补丁在大多数情况下提高了性能。
My name is Jason from Raima. Hopefully you received our email about this problem back in 2011, but for anyone else who has experienced this performance problem, we will explain how this was fixed:
The performance problem was in closesocket(), and explained that we could not do anything about this. Immediately afterwards one of our engineers found that we were using the SO_LINGER option, which causes closesocket() to block till all outstanding data has been sent before returning. We removed this option and sent a patch on October 11, 2011. With SO_LINGER turned off, the closesocket() function will still send outstanding data before closing the socket, but it may return before this operation is complete. The patch improved performance in most cases.