Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-22 Thread via GitHub
MJY-HUST commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2126086597 @chenBright hello,我根据讨论修改了实现,可以帮忙看一下么 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the spe

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
chenBright commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121822911 https://github.com/apache/brpc/blob/b601c89aec9042a1f509ddbdad478aa4e3f118fe/src/butil/thread_key.h#L144-L154 -- This is an automated message from the Apache Git Service. To respond to

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
MJY-HUST commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121738852 > > > > 如果使用TLS的话,当server结束调用Join时,通过bthread_keytable_pool_destroy方法需要删除所有线程内保存的TLS free_keytables才行,感觉也不是很方便? > > > > > > > > > 用butil::ThreadLocal应该挺方便的吧。 bthread_keytable_poo

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
chenBright commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121703973 > 我看ResourcePool获取对象的模式是如下图,那么reserve时初始化多个全局的block是否可行。 ResourcePool也是单例哦。 > return_keytable时,加读锁的临界区是判断destroyed + 将对象返回给pool,感觉不能直接使用原子变量 嗯嗯,return_keytable和bthread_

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
chenBright commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121677162 > > > 如果使用TLS的话,当server结束调用Join时,通过bthread_keytable_pool_destroy方法需要删除所有线程内保存的TLS free_keytables才行,感觉也不是很方便? > > > > > > 用butil::ThreadLocal应该挺方便的吧。 bthread_keytable_pool_init

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
MJY-HUST commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121670376 > > 我的理解,目前的实现是一个server会绑定一个全局的bthread_keytable_pool_t,在server的声明周期内,server和其生成的bthread使用同一个pool,在server结束时会销毁所有创建的KeyTable,通过bthread_keytable_pool_t内的链表;然后会从全局的KeyInfo中删除所有注册的Key。但是使用全局一个链表

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
MJY-HUST commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121665236 > > 改造bthread_keytable_pool_t ,其中引入一个类似Object_pool的成员,通过在成员内部使用tls变量来避免加互斥锁。然后对bthread_keytable_pool_t 中的锁的使用从互斥锁改为读写锁,来维护destroyed的值。在return_keytable内使用读锁,bthread_keytable_pool_init,bthrea

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
MJY-HUST commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121660473 > > 如果使用TLS的话,当server结束调用Join时,通过bthread_keytable_pool_destroy方法需要删除所有线程内保存的TLS free_keytables才行,感觉也不是很方便? > > 用butil::ThreadLocal应该挺方便的吧。 bthread_keytable_pool_init的时候,new一个butil::

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
chenBright commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121640057 > 如果使用TLS的话,当server结束调用Join时,通过bthread_keytable_pool_destroy方法需要删除所有线程内保存的TLS free_keytables才行,感觉也不是很方便? 用butil::ThreadLocal应该挺方便的吧。 bthread_keytable_pool_init的时候,new一个butil::Th

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
chenBright commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121630465 > 改造bthread_keytable_pool_t ,其中引入一个类似Object_pool的成员,通过在成员内部使用tls变量来避免加互斥锁。然后对bthread_keytable_pool_t 中的锁的使用从互斥锁改为读写锁,来维护destroyed的值。在return_keytable内使用读锁,bthread_keytable_pool_init,bthrea

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
chenBright commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2121602397 > > https://github.com/apache/brpc/blob/b601c89aec9042a1f509ddbdad478aa4e3f118fe/src/brpc/server.h#L170-L183 > > > > https://github.com/apache/brpc/blob/b601c89aec9042a1f509ddbdad4

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
MJY-HUST commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2120990105 改造bthread_keytable_pool_t ,其中引入一个类似Object_pool的成员,通过在成员内部使用tls变量来避免加互斥锁。然后对bthread_keytable_pool_t 中的锁的使用从互斥锁改为读写锁,来维护destroyed的值。在return_keytable内使用读锁,bthread_keytable_pool_init,bthread_ke

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
MJY-HUST commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2120855523 改造bthread_keytable_pool_t,其中引入一个类似于Object_pool的成员,但是和Object_pool不同的是,它不是单例。这样就可以和 bthread_keytable_pool_t绑定。然后使用bthread_key_create记录KeyInfo时,将index保存到一个bthread_keytable_pool_t的成员中。这样既可以使

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-20 Thread via GitHub
MJY-HUST commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2120363076 > https://github.com/apache/brpc/blob/b601c89aec9042a1f509ddbdad478aa4e3f118fe/src/brpc/server.h#L170-L183 > > > https://github.com/apache/brpc/blob/b601c89aec9042a1f509ddbdad478

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-19 Thread via GitHub
chenBright commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2119559198 https://github.com/apache/brpc/blob/b601c89aec9042a1f509ddbdad478aa4e3f118fe/src/brpc/server.h#L170-L183 https://github.com/apache/brpc/blob/b601c89aec9042a1f509ddbdad478aa4e3f118fe/sr

Re: [PR] Use object_pool to store keytable by gflag (brpc)

2024-05-19 Thread via GitHub
chenBright commented on PR #2645: URL: https://github.com/apache/brpc/pull/2645#issuecomment-2119556697 object_pool应该没法完全解决 #1449 的问题吧,从object_pool取出来的KeyTable有可能已经有data了,先调用bthread_setspecific函数,旧data还是会泄漏。 -- This is an automated message from the Apache Git Service. To respond to the me

[PR] Use object_pool to store keytable by gflag (brpc)

2024-05-19 Thread via GitHub
MJY-HUST opened a new pull request, #2645: URL: https://github.com/apache/brpc/pull/2645 ### What problem does this PR solve? Issue Number: #2635 Problem Summary: 如issue讨论,使用object_pool来管理KeyTable,避免如使用bthread_keytable_pool_t管理时出现的锁的竞争。此PR是一个初步实现,通过gflags控制是否使用object_pool,未删除