-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Account cache optimization #5792
Conversation
…tion-library-for-js into account-cache-optimization
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.
This PR is still marked as draft, I'll re-review it once it's marked ready for review. Thanks!
…tion-library-for-js into account-cache-optimization
Codecov Report
*This pull request uses carry forward flags. Click here to find out more.
|
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.
Just the one comment on the '-' separator. I'm likely missing something here. Thanks.
Co-authored-by: Doğan Erişen <v-derisen@microsoft.com>
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. Have some qs on size.
Follow up to #5792, addressing the same problem but for token lookups. Today on every lookup of tokens in the cache we iterate through every entry in the cache (including cache entries not belonging to MSAL), attempt to parse it into JSON and then validate that it matches our credential shape. This is incredibly inefficient and becomes more inefficient with each additional thing stored in browser storage. This PR adds a new cache entry which contains an object of keys to all of the tokens known to MSAL for a given clientId. Now when the tokens need to be enumerated the worst case number of cache entries touched and parsed is 1 + number of tokens of the given type. Example: ```js key: msal.token.keys.<clientId> value: { idToken: ["idToken-key-1", "idToken-key-2"], accessToken: ["accessToken-key-1", "accessToken-key-2"], refreshToken: ["refreshToken-key-1"] } ``` --------- Co-authored-by: Thomas Norling <thnorlin@microsoft.com>
Today on every lookup of an account in the cache we iterate through every entry in the cache (including cache entries not belonging to MSAL), attempt to parse it into JSON and then validate that it matches our account shape. This is incredibly inefficient and becomes more inefficient with each additional thing stored in browser storage. This PR adds a new cache entry (with a static key) which contains an array of keys to all of the accounts known to MSAL. Now when the accounts need to be enumerated the worst case number of cache entries touched and parsed is 1 + number of accounts. A new configuration option is added which determines whether or not this new cache entry should be created on initialization. This is to help migrate apps using localStorage from versions before this change. Follow up PR will address the same issue for id, access and refresh tokens. --------- Co-authored-by: Thomas Norling <thnorlin@microsoft.com> Co-authored-by: Doğan Erişen <v-derisen@microsoft.com>
Follow up to #5792, addressing the same problem but for token lookups. Today on every lookup of tokens in the cache we iterate through every entry in the cache (including cache entries not belonging to MSAL), attempt to parse it into JSON and then validate that it matches our credential shape. This is incredibly inefficient and becomes more inefficient with each additional thing stored in browser storage. This PR adds a new cache entry which contains an object of keys to all of the tokens known to MSAL for a given clientId. Now when the tokens need to be enumerated the worst case number of cache entries touched and parsed is 1 + number of tokens of the given type. Example: ```js key: msal.token.keys.<clientId> value: { idToken: ["idToken-key-1", "idToken-key-2"], accessToken: ["accessToken-key-1", "accessToken-key-2"], refreshToken: ["refreshToken-key-1"] } ``` --------- Co-authored-by: Thomas Norling <thnorlin@microsoft.com>
🎉 We recommend upgrading to the latest version of Handy links: |
🎉 Handy links: |
🎉 Handy links: |
Today on every lookup of an account in the cache we iterate through every entry in the cache (including cache entries not belonging to MSAL), attempt to parse it into JSON and then validate that it matches our account shape. This is incredibly inefficient and becomes more inefficient with each additional thing stored in browser storage. This PR adds a new cache entry (with a static key) which contains an array of keys to all of the accounts known to MSAL. Now when the accounts need to be enumerated the worst case number of cache entries touched and parsed is 1 + number of accounts. A new configuration option is added which determines whether or not this new cache entry should be created on initialization. This is to help migrate apps using localStorage from versions before this change. Follow up PR will address the same issue for id, access and refresh tokens. --------- Co-authored-by: Thomas Norling <thnorlin@microsoft.com> Co-authored-by: Doğan Erişen <v-derisen@microsoft.com>
Today on every lookup of an account in the cache we iterate through every entry in the cache (including cache entries not belonging to MSAL), attempt to parse it into JSON and then validate that it matches our account shape. This is incredibly inefficient and becomes more inefficient with each additional thing stored in browser storage.
This PR adds a new cache entry (with a static key) which contains an array of keys to all of the accounts known to MSAL. Now when the accounts need to be enumerated the worst case number of cache entries touched and parsed is 1 + number of accounts.
A new configuration option is added which determines whether or not this new cache entry should be created on initialization. This is to help migrate apps using localStorage from versions before this change.
Follow up PR will address the same issue for id, access and refresh tokens.