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

Use a shared_ptr and thread_local to store credentials for use #202

Merged
merged 11 commits into from
Apr 16, 2018

Conversation

pfifer
Copy link
Contributor

@pfifer pfifer commented Apr 12, 2018

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.

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.
@pfifer pfifer requested a review from sayantacC April 12, 2018 19:47
#else
#define update_step(...)
#endif
thread_local aws::auth::VersionedCredentials current_creds;
Copy link
Contributor

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);
Copy link
Contributor

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.
@pfifer pfifer added this to the v0.12.9 milestone Apr 16, 2018
@pfifer pfifer merged commit 7b50aca into awslabs:master Apr 16, 2018
@pfifer pfifer deleted the thread_local_creds branch April 16, 2018 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants