-
Notifications
You must be signed in to change notification settings - Fork 332
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 a shared_ptr and thread_local to store credentials for use #202
Conversation
Turns out gcc 4.9.3 doesn't support put_time
Increased the number of reader threads in mutable_static_creds_provider_test to test performance under higher contention.
The performance of shared_ptr atomic loads/stores on gcc appears really bad when compared to clang. Not sure if this is Linux/macOS or just stdlib implementation.
#else | ||
#define update_step(...) | ||
#endif | ||
thread_local aws::auth::VersionedCredentials current_creds; |
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.
I think a short comment about the role of the thread local current creds and how its version is compared against the global version would make it easier to follow.
update_step(debug_stats.success_); | ||
return true; | ||
std::shared_ptr<VersionedCredentials> new_credentials = std::make_shared<VersionedCredentials>(next_version, akid, sk, token); | ||
std::atomic_store(&creds_, new_credentials); |
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.
would it be good to add a comment that this is updating the global credentials ?
Added some comments to explain how thread local credentials are updated.
Indicate that version is packaged with its credentials, and using unsigned integers ensure that this will work if the value wraps around.
Switched to use a shared_ptr for credential transfer, and thread_local for normal usage.
This gets rid of a bug that could occur with the previous approach around destruction of the string objects, while preserving performance in most cases.