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

Add time metrics to AuthenticationResult metadata #2581

Merged
merged 11 commits into from
May 3, 2021

Conversation

bgavrilMS
Copy link
Member

  • time in total
  • time spent in HTTP
  • time spent in token cache callbacks

@bgavrilMS bgavrilMS marked this pull request as draft April 26, 2021 17:29
@bgavrilMS bgavrilMS requested a review from pmaytak April 26, 2021 17:29
@bgavrilMS bgavrilMS marked this pull request as ready for review April 27, 2021 18:04
Copy link
Contributor

@pmaytak pmaytak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts + small nits below (but most are shared in our offline discussion). Good to see the data results and comparison. BenchmarkDotNet does seem to offer custom columns that could maybe show the duration metrics; iteration/global setup methods can be used to set up the CCA and cache; and WithIterationCount/WithIterationTime can modify how many times the iterations are called - (although that seems like more work and you already have working test).


/// <summary>
/// Time (in ms) MSAL spent in reading and writing to the token cache, i.e. in the OnBeforeAccess, OnAfterAccess etc. callbacks.
/// Does not include internal MSAL logic for searching through the cache once loaded.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be included to measure the whole cache operation? Otherwise, only measuring accessing serialization cache, the property name might be misleading then.

Comment on lines +221 to +222
Stopwatch sw = new Stopwatch();
sw.Start();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can be combined into Stopwatch sw = Stopwatch.StartNew();

@@ -12,6 +12,8 @@ namespace Microsoft.Identity.Client.Http
{
internal interface IHttpManager
{
long LastRequestTime { get; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LastRequestDurationInMs

// execute won't start here because IEnumerable is lazy
IEnumerable<Task<AuthenticationResult>> tasks = accounts.Select(acc =>
pca.AcquireTokenSilent(TestConstants.s_scope, acc).ExecuteAsync());
//return cca.AcquireTokenForClient(new[] { "scope" })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncomment and use s_cca here?

@@ -234,6 +104,8 @@ private void ConfigureCacheSerialization(IPublicClientApplication pca)
/// </summary>
internal class ParallelRequestMockHanler : IHttpManager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ParallelRequestMockHandler

/// - provides a standard reponse for discovery calls
/// - responds with valid tokens based on a naming convention (uid = "uid" + rtSecret, upn = "user_" + rtSecret)
/// </summary>
internal class ParallelRequestMockHanler : IHttpManager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: ParallelRequestMockHandler

[Route("[controller]")]
public class StaticDictionaryController : ControllerBase
{
private readonly ILogger<SingletonController> _logger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private readonly ILogger<StaticDictionaryController> _logger;

@bgavrilMS bgavrilMS requested a review from pmaytak April 29, 2021 09:21
@bgavrilMS bgavrilMS merged commit fe13aa9 into master May 3, 2021
@bgavrilMS bgavrilMS deleted the bogavril/spike-timein branch May 3, 2021 09:02
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