本文介绍了是否期望使用boost :: thread_specific_ptr<> :: get()是否慢?任何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用Valgrind的Callgrind来分析性能问题的应用程序。在查看分析数据时,看起来在 boost :: detail :: get_tss_data 中花费了25%的处理时间主要目的是物理模拟和可视化的应用程序。

I'm currently profiling an application with performance problems using Valgrind's "Callgrind". In looking at the profiling data, it appears that a good 25% of processing time is being spent inside of boost::detail::get_tss_data in an application whose primary purpose is physics simulation and visualization.

get_tss_data thread_specific_ptr :: get

get_tss_data is apparently called by thread_specific_ptr::get

通常是否暗示其他特定的内容?

Does anyone see this as expected? Does it generally imply something else specific?

编辑

我的平台:Linux-2.6.32,x86,GCC 4.4.3,libc6-2.11.1 / libpthread-2.11.1

My platform is: Linux-2.6.32, x86, GCC 4.4.3, libc6-2.11.1/libpthread-2.11.1

推荐答案

thread_specific_ptr 为POSIX系统使用 pthread_setspecific / pthread_getspecific

thread_specific_ptr uses pthread_setspecific/pthread_getspecific for POSIX systems which is not the fastest possible.

如果您使用的是POSIX系统,您可以使用 __ thread 存储说明符。但是,它只能用于常量表达式的初始化器,例如

If you are on a POSIX system, you can use the __thread storage specifier. However, it can only be used with initializers that are constant expressions e.g gcc's __thread

对于Windows,类似的说明符是 _declspec(thread)

For Windows, a similar specifier is _declspec(thread).

这篇关于是否期望使用boost :: thread_specific_ptr<> :: get()是否慢?任何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 03:34