-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use std::shared_ptr in case if ENABLE_THREAD_SAFE_TILE_REF_COUNT is ON #3067
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Is getting a weak pointer from a shared ptr the main motivation for this change? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I wish we could have just used shared_ptr regardless but the perf penalty was too much.
Yes. Do you have alternative ideas how it can be solved? |
No, I think your solution is good! I was wondering if we still need to have Minor optional nit: we could rename |
@mandeepsandhu the only reason we have it at all is performance issues. iirc it was about a 6% performance reduction |
6% reduction compared to using |
24 thread load test using mem mapped tar with no locking needed (every thread has its own graph reader) |
@kevinkreiser it's usually strongly encouraged to use const references to avoid triggering shared_ptr internal mutexes - is not doing that everywhere possibly the source of the slowdown, and perhaps a less kafkaesque fix might be to fix the usage pattern of graph tile pointers? |
@danpat good question! at the end of the day the various |
The proposed name is definitely better, but I don't want to break backward compatibility(some Valhalla users use this flag already) and probably I'll leave it as is. |
432791d
432791d
to
35482c4
Compare
f81b2f2
Issue
During implementation of #2730 we learnt that using of
std::shared_ptr
(which has such ability) has certain performance impact, that's why we ended up usingboost::intrusive_ptr
. Then we addedENABLE_THREAD_SAFE_TILE_REF_COUNT
to work around issues with non thread-safe reference counter in multithreading environment. SinceENABLE_THREAD_SAFE_TILE_REF_COUNT
is supposed to be used in the cases when performance is not top-1 priority and sometimes it is very useful to be able to get weak pointer to tile I propose to usestd::shared_ptr
as tile pointer in case ofENABLE_THREAD_SAFE_TILE_REF_COUNT
(instead ofboost::intrusive_ptr
with thread-safe counter).Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?