Skip to content
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

Track length of time mutexes are held for #2267

Merged
merged 5 commits into from
Sep 3, 2019

Conversation

wezrule
Copy link
Contributor

@wezrule wezrule commented Sep 1, 2019

Replaced all std::lock_guard and std::unique_lock with new nano:: equivalents (apart from ones in crypto_lib as they don't have any nano dependencies). If -DNANO_TIMED_LOCKS=100 is set for instance, it will use the new classes which will output the stacktrace of any mutexes held for longer than this (100ms). It also reports which ones were waiting on other mutexes as well as the pointer address so that they can be later connected.

I'm only tracking the containers using a std::mutex, as things like recursive_mutex, shared_mutex are quite a bit more difficult and not nearly as useful. Speaking of which this will be useful for checking whether we have a lot of readers (and few writers) blocking each other, where using std::shared_mutex & std::shared_timed_mutex may be more appropriate.

Annoyingly std::condition_variable methods are not based on a template, it only expects std::unique_lock, so it makes it difficult to use the new nano::unique_lock, for this reason I also had to add nano::condition_variable, which is quite a bit more difficult to wrap as it uses spin-locks etc... So I'm using boost's condition_variable_any, which is based on a template! and wrapped my class around that. But this does mean we need the context & fiber boost libraries. But I made sure that they are only required if DNANO_TIMED_LOCKS is set to greater than 0 to maintain backwards compatibility because this is very much a Diagnostics only options only really useful for debugging purposes. I started to add a test, but again, this could only be tested if using DNANO_TIMED_LOCKS, which would then affect all other tests so this didn't seem worth the hassle it for a diagnostics only option.

@wezrule wezrule added documentation This item indicates the need for or supplies updated or expanded documentation quality improvements This item indicates the need for or supplies changes that improve maintainability labels Sep 1, 2019
@wezrule wezrule added this to the V20.0 milestone Sep 1, 2019
@wezrule wezrule self-assigned this Sep 1, 2019
@guilhermelawless guilhermelawless added the tool Introduces or updates a tool or command label Sep 2, 2019
@wezrule wezrule merged commit 732de66 into nanocurrency:master Sep 3, 2019
@wezrule wezrule deleted the debug_time_locks_held branch September 3, 2019 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This item indicates the need for or supplies updated or expanded documentation quality improvements This item indicates the need for or supplies changes that improve maintainability tool Introduces or updates a tool or command
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants