ZhengweiZhu commented on PR #3096: URL: https://github.com/apache/brpc/pull/3096#issuecomment-3307762213
> Maybe you can try to get all bthread_id from the `butil::ResourcePool<bthread::TaskMeta>`? (needs to add some interface to butil::ResourcePool) @wwbmmm @chenBright Yes I have thought of this approach but with no result. Firstly, when we create a bthread, a ResourceId and TaskMeta instance is acquired from butil::ResourcePool by this way: ` butil::ResourceId<TaskMeta> slot; TaskMeta* m = butil::get_resource(&slot); ` If we know all the ResourceId<TaskMeta> slot then we can get all living bthread id by address_resource(slot)->tid. Inside the ResourcePool implementation, the slot is acquired by the following order: 1. thread local FreeChunk 2. global FreeChunk 3. thread local Block 4. global Block (from BlockGroup). The problem is the ResourcePool does not record the slot **in use** and it only knows the slot after it is not in use and returned to ResourcePool, which does not satisfy our requirement here. Secondly, if we add some interface in ResourcePool to record the slot when get_resource and consider removing it when return_resource, certainly we might use thread local LocalPool to record for the sake of performance effect. The problem is the get_resource and return_resource may run in different pthread (different tls) as bthread switches to another worker. What's more, if we plan to get all living bthread id by summarizing **all** thread local records, the tricky part is the ResourcePool interface can be called from worker and non worker, making it even impossible to summarize. Any ideas? -- 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 specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org