-
Notifications
You must be signed in to change notification settings - Fork 38
Description
At this moment, if a user wants to free an allocation from the proxy pool, they can do something like this:
umf_pool_by_ptr(ptr, &pool);
umf_pool_free(pool, ptr);
Internally, proxy_free()
calls umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
to retrieve the allocation size. Then, the free function from the tracking provider is called, which removes the entry for ptr from the critnib tree (the removal process itself involves a tree search).
In this example, the same pointer is being searched for three times (noting that the removal process also performs a tree search).
This issue proposes introducing caching of the last search in the tracking provider. We have two approaches:
Extend Critnib with a Caching Feature
This approach requires using functions like pthread_setspecific (though the performance impact of this function is uncertain).
With this method, the pointer lookup could be reduced to one search.
Add Cache at the Tracking Provider Level
Since the tracking provider is static, a TLS cache can be added easily using __thread.
However, with the current implementation of critnib, a tree search is still required for removal, so this approach would reduce the number of searches from three to two