Skip to content

use BAIDU_VOLATILE_THREAD_LOCAL to declare tls_bls to avoid error compiler optimization - #2934

Merged
chenBright merged 8 commits into
apache:masterfrom
BiteTheDDDDt:fix_0402
Apr 8, 2025
Merged

chenBright merged 8 commits into
apache:masterfrom
BiteTheDDDDt:fix_0402

Conversation

@BiteTheDDDDt

Copy link
Copy Markdown
Contributor

What problem does this PR solve?
解决bthread_setspecific注册的变量,用bthread_getspecific可能会找不到的问题。
Problem Summary:
根据 #1776 , #2156 里的一些相关描述,我尝试将清理tls这段代码抽出来作为单独函数并声明为noinline,在我自己的场景下测试可以修复这个问题

Changed:

Side effects:

  • Performance effects(性能影响):

  • Breaking backward compatibility(向后兼容性):


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).
@wwbmmm

wwbmmm commented Apr 2, 2025

Copy link
Copy Markdown
Contributor

是否可以在访问tls_bls变量时使用 BAIDU_GET_VOLATILE_THREAD_LOCAL宏?这种方法应该更通用一些

@chenBright

Copy link
Copy Markdown
Contributor

是否可以在访问tls_bls变量时使用 BAIDU_GET_VOLATILE_THREAD_LOCAL宏?这种方法应该更通用一些

+1

@chenBright

Copy link
Copy Markdown
Contributor

master已经修复了ci中cmake的问题,麻烦rebase一下。@BiteTheDDDDt

@BiteTheDDDDt BiteTheDDDDt changed the title move clean_tls_bls to single noinline function to avoid compiler optimization Apr 4, 2025
Comment thread src/bthread/task_group.cpp Resolved

@chenBright chenBright left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chenBright
chenBright merged commit 65b550e into apache:master Apr 8, 2025
yanglimingcn pushed a commit to yanglimingcn/brpc that referenced this pull request May 19, 2025
…piler optimization (apache#2934)

* add attribute noinline to tls_bls

update

* update

* fix compile error

* update

* update

* update
@zcfh

zcfh commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

请问下,这个有可复现的demo吗?
目前加上这个patch后,真实的服务场景还是有问题,所以想简化demo复现下。

@BiteTheDDDDt

Copy link
Copy Markdown
Contributor Author

请问下,这个有可复现的demo吗? 目前加上这个patch后,真实的服务场景还是有问题,所以想简化demo复现下。

这个是我在升级apache doris依赖的brpc版本的时候遇见的问题,没有单独的demo。我猜测可能BAIDU_VOLATILE_THREAD_LOCAL在你们的编译器或者平台下没起作用?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants