从 Microsoft STL 切换到 STLport

发布于 2024-07-14 00:39:58 字数 269 浏览 6 评论 0原文

我在 Windows 下的性能关键的 C++ 代码中使用了大量的 STL。 获得额外性能的一种可能的“廉价”方法是更改​​为更快的 STL 库。

根据这个 帖子 STLport 更快并且使用内存较少,但已经有几年了。

最近有人进行过此更改吗?结果如何?

I'm using quite much STL in performance critical C++ code under windows. One possible "cheap" way to get some extra performance would be to change to a faster STL library.

According to this post STLport is faster and uses less memory, however it's a few years old.

Has anyone made this change recently and what were your results?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

静若繁花 2024-07-21 00:39:58

我还没有比较 STLPort 和 MSCVC 的性能,但如果存在显着差异,我会感到惊讶。 (当然,在发布模式下 - 调试版本可能会完全不同。)不幸的是,您提供的链接 - 以及我见过的任何其他比较 - 细节太少而无用。

在考虑更改标准库提供程序之前,我建议您仔细分析代码以确定瓶颈所在。 这是标准建议; 在尝试任何性能改进之前始终进行分析!

即使分析确实揭示了标准库容器或算法中的性能问题,我建议您首先分析如何使用它们。 算法改进和适当的容器选择,尤其是考虑到 Big-O 成本,更有可能带来更大的性能回报。

I haven't compared the performance of STLPort to MSCVC but I'd be surprised if there were a significant difference. (In release mode of course - debug builds are likely to be quite different.) Unfortunately the link you provided - and any other comparison I've seen - is too light on details to be useful.

Before even considering changing standard library providers I recommend you heavily profile your code to determine where the bottlenecks are. This is standard advice; always profile before attempting any performance improvements!

Even if profiling does reveal performance issues in standard library containers or algorithms I'd suggest you first analyse how you're using them. Algorithmic improvements and appropriate container selection, especially considering Big-O costs, are far more likely to bring greater returns in performance.

堇色安年 2024-07-21 00:39:58

Before making the switch, be sure to test the MS (in fact, Dinkumware) library with checked iterators turned off. For some weird reason, they are turned on by default even in release builds and that makes a big difference when it comes to performance.

甜是你 2024-07-21 00:39:58

我们最近做了相反的任务。 我们的应用程序是一个跨平台的 C++ 服务器程序,它是在 Windows 上使用 VS 2008 (x86) 以及 HP-UX ia64 和 Linux 上使用 gcc 4.3 构建的。 在每个平台上,我们都使用 STLport 5.1.7 作为 STL 库和 Boost 1.38。

为了比较性能,前段时间我们还构建了没有 STLport 的应用程序,然后我们测量了性能。

之后在 Windows 上的性能稍微好一些。 因此我们选择停止在 VS 2008 中使用 STLport 并使用默认的 VS 2008 STL 库。

在 HP-UX ia64 上,性能下降了 20%。 Caliper(HP-UX 分析器)显示字符串分配需要更多时间。 在默认的 gcc STL 库中的字符串赋值内部,调用了 pthread_mutex_unock。 据我所知,由于默认的 gcc 的 STL 库使用 COW 字符串,所以使用了 pthread_mutex_lock/pthread_mutex_unlock 。 在我们的应用程序中,我们进行了大量的字符串分配,由于使用了 COW 字符串,我们的性能变得更差。 所以我们仍然在 HP-UX 上使用 STLPort 和 gcc。

We have done the opposite task recently. Our application is a cross-platform C++ server program and it is built on Windows with VS 2008 (x86) and on HP-UX ia64 and Linux with gcc 4.3 . On every platform we used the STLport 5.1.7 as an STL library and Boost 1.38.

In order to compare performance some time ago we also built our application without STLport and after that we measured performance.

After that on Windows the performance became slightly better. So we chose to stop using the STLport with VS 2008 and to use the default VS 2008 STL library.

On HP-UX ia64 there was 20% decrease in performance. Caliper (the HP-UX profiler) showed that string assignments took more time. And inside of string assignment in the default gcc STL library there were calls to pthread_mutex_unock. As far as I know pthread_mutex_lock/pthread_mutex_unlock are used since the default gcc's STL library uses COW-strings. In our application we do lots of string assignments and as a result of the COW strings we get worse performance. So we still use STLPort on HP-UX with gcc.

妄想挽回 2024-07-21 00:39:58

在我从事的一个项目中,大量使用了 stl,切换到 STLport 后,完成工作的时间是使用 Microsoft STL 实现的一半。 这不是证据,但我想这是表现的良好标志。 我相信这部分归功于 STLport 先进的内存管理系统。

我确实记得在进行此更改时收到了一些警告,但没有什么不能快速解决的。 作为一个缺点,我要补充一点,使用 Visual Studio 的调试器进行 STLport 调试不如使用 Microsoft 的 STL 容易(更新:似乎有一种方法可以向调试器解释如何处理 STLport 容器,谢谢 Jalf!)。

最新版本可以追溯到 2008 年 10 月,因此仍然有人在开发它。 请参阅此处下载它。

In a project i worked on that makes quite heavy use of stl, switching to STLport resulted in getting things done in half the time it took with Microsoft's STL implementation. It's no proof, but it's a good sign of performance, i guess. I believe it's partly due to STLport's advanced memory management system.

I do remember getting some warnings when making this change, but nothing that couldn't be worked around fast. As a drawback, I'd add that debugging with STLport is less easy with Visual Studio's debugger than with Microsoft's STL (Update : it seems there is a way to explain to the debugger how to handle STLport containers, thanks Jalf !).

The latest version goes back to October 2008 so there are still people working on it. See here for downloading it.

青柠芒果 2024-07-21 00:39:58

一年前我做了完全相反的事情,原因如下:

  • StlPort 很少更新(据我所知只有一个开发人员正在开发它,你可以看看他们的提交 历史)
  • 每当您切换到新的 Visual Studio 版本时,构建它都会出现问题。 您等待新的 make 文件或自己创建它,但有时由于您正在使用的某些配置选项而无法构建它。 然后你就等着他们把它建造起来。
  • 当你提交错误报告时,你会永远等待,所以基本上没有支持(也许如果你付费的话)。 如果你知道怎么做的话,你通常最终会自己修复它。
  • Visual Studio 中的 STL 具有检查的迭代器调试迭代器支持比StlPort 的那个。 这是大部分速度下降的原因,尤其是在调试过程中。 检查迭代器在调试和发布中都启用,这并不是每个人都知道的(您必须自己禁用它们)。
  • Visual Studio 2008 SP1 中的 STL 附带了 TR1,而 StlPort 中没有此功能。
  • Visual Studio 2010 中的 STL 使用 C++0x 中的右值引用,这就是您获得真正性能优势的地方。

I've done the exact opposite a year ago and here is why:

  • StlPort is updated very rarely (as far as I know only one developer is working on it, you can take a look at their commit history)
  • Problems building it whenever you switch to new Visual Studio release. You wait for the new make file or you create it yourself but sometimes you can't build it because of some configuration option that you're using. Then you wait for them to make it build.
  • When you submit a bug report you wait forever, so basically no support (maybe if you pay). You usually end up fixing it yourself, if you know how.
  • STL in Visual Studio has checked iterators and debug iterator support that is much better than the one in StlPort. This is where most of the slowdown comes from especially in debug. Checked iterators are enabled in both debug and release and this is not something everybody knows (you have to disable them yourself).
  • STL in Visual Studio 2008 SP1 comes with TR1 and you don't have this in StlPort
  • STL in Visual Studio 2010 uses rvalue references from C++0x and this is where you get a real performance benefit.
彩扇题诗 2024-07-21 00:39:58

如果您使用 STLPort,您将进入一个世界,您使用的每个基于 STL 的第三方库都必须使用 STLPort 重新编译以避免出现问题...

STLPort 确实有不同的内存策略,但如果这是您的瓶颈,那么你的性能增益路径是改变分配器(例如切换到 Hoard),而不是改变 STL。

If you use the STLPort you will enter a world where every STL-based third party library you use will have to be recompiled with STLPort as well to avoid problems...

STLPort does have a different memory strategy, but if this is your bottleneck then your performance gain path is changing the allocator (switching to Hoard for example), not changing the STL.

风吹短裙飘 2024-07-21 00:39:58

我没有尝试过,但据我所知,微软的STL实现并没有发生重大变化。 (与 2005 年相比,VS2008 编译器也没有重大的新优化)因此,如果当时 STLPort 更快,情况可能仍然如此。

但这只是猜测。 :)
如果您尝试一下,请务必报告结果。

I haven't tried it, but as far as I know, there have been no major changes to Microsoft's STL implementation. (There are no huge new optimizations in VS2008 compiler over 2005 either) So if STLPort was faster then, it's probably still the case.

But that's just speculation. :)
Be sure to report back on the results if you try it out.

梦初启 2024-07-21 00:39:58

stlport 的好处之一是它是开源的。

One benefit of stlport is that it's open source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文