Skip to content

Audit all info and verbose logs and use lambdas to generate strings#3919

Merged
bgavrilMS merged 6 commits into
mainfrom
bogavril/3901
Feb 9, 2023
Merged

Audit all info and verbose logs and use lambdas to generate strings#3919
bgavrilMS merged 6 commits into
mainfrom
bogavril/3901

Conversation

@bgavrilMS
Copy link
Copy Markdown
Member

@bgavrilMS bgavrilMS commented Jan 26, 2023

Fixes #3901

Changes proposed in this request

Testing
unit

Performance impact

Method Mean Error StdDev Median Min Max Gen0 Allocated
'Compute and log expensive string via direct string' 1,292.38 ns 35.423 ns 33.135 ns 1,287.09 ns 1,253.46 ns 1,371.78 ns 0.1488 944 B
'Compute and log expensive string via Func' 1,369.27 ns 41.625 ns 34.759 ns 1,362.51 ns 1,296.23 ns 1,436.84 ns 0.1678 1056 B
'Compute and skip logging expensive string' 628.37 ns 10.844 ns 10.143 ns 626.69 ns 611.36 ns 650.44 ns 0.0591 376 B
'No compute (Func) and skip logging expensive string' 14.14 ns 0.286 ns 0.239 ns 14.14 ns 13.72 ns 14.66 ns 0.0153 96 B

** AcquireTokenForClient perf tests **

These were modified to run with WithLogging(Console.WriteLine(msg), LogLevel.Info)

Method CacheSize EnableCacheSerialization Mean Min Max Gen0 Gen1 Gen2 Allocated
AcquireTokenForClient (1, 10) False 3.114 ms 3.057 ms 3.204 ms 7.8125 - - 51.26 KB
AcquireTokenForClient (1, 10) True 3.204 ms 3.163 ms 3.280 ms 46.8750 15.6250 - 287.65 KB
AcquireTokenForClient (1, 1000) False 3.121 ms 3.059 ms 3.160 ms 27.3438 - - 190.96 KB
AcquireTokenForClient (1, 1000) True 30.336 ms 29.677 ms 31.857 ms 2687.5000 1312.5000 625.0000 17010.89 KB
AcquireTokenForClient (10000, 10) False 3.116 ms 3.030 ms 3.184 ms 7.8125 - - 51.28 KB
AcquireTokenForClient (10000, 10) True 4.117 ms 3.383 ms 4.852 ms 46.8750 15.6250 - 287.65 KB
Method CacheSize EnableCacheSerialization Mean Min Max Gen0 Gen1 Gen2 Allocated
AcquireTokenForClient (1, 10) False 2.990 ms 2.907 ms 3.063 ms 7.8125 - - 50.23 KB
AcquireTokenForClient (1, 10) True 3.092 ms 3.024 ms 3.180 ms 42.9688 11.7188 - 287.06 KB
AcquireTokenForClient (1, 1000) False 3.012 ms 2.932 ms 3.064 ms 23.4375 - - 158.98 KB
AcquireTokenForClient (1, 1000) True 29.365 ms 27.786 ms 31.487 ms 2625.0000 1250.0000 625.0000 17065.87 KB
AcquireTokenForClient (10000, 10) False 2.966 ms 2.916 ms 3.019 ms 7.8125 - - 50.24 KB
AcquireTokenForClient (10000, 10) True 3.080 ms 3.010 ms 3.147 ms 42.9688 11.7188 - 287.03 KB

Documentation
n/a

@bgavrilMS bgavrilMS enabled auto-merge (squash) January 26, 2023 14:48
@bgavrilMS bgavrilMS marked this pull request as draft January 26, 2023 15:30
auto-merge was automatically disabled January 26, 2023 15:30

Pull request was converted to draft

@bgavrilMS bgavrilMS marked this pull request as ready for review January 30, 2023 13:55
Copy link
Copy Markdown
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.

Cool stuff. Based on perf tests, seems like it does help to not compute when logging is disabled. Would be nice though if there was a syntactic sugar to not add () => part - parameter is Func, you pass in a string, but compiler figures out to change it to a Func.

Comment thread src/client/Microsoft.Identity.Client.Broker/RuntimeBroker.cs Outdated
Comment thread src/client/Microsoft.Identity.Client/ClientApplicationBase.cs Outdated
Comment thread src/client/Microsoft.Identity.Client/ClientApplicationBase.cs Outdated
Comment thread src/client/Microsoft.Identity.Client/OAuth2/Throttling/ThrottlingCache.cs Outdated
@bgavrilMS bgavrilMS enabled auto-merge (squash) February 7, 2023 23:01
bgavrilMS and others added 6 commits February 9, 2023 14:25
Co-authored-by: Peter M <34331512+pmaytak@users.noreply.github.com>
Co-authored-by: Gladwin Johnson <90415114+gladjohn@users.noreply.github.com>
@bgavrilMS bgavrilMS merged commit a07da18 into main Feb 9, 2023
@bgavrilMS bgavrilMS deleted the bogavril/3901 branch February 9, 2023 15:12
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.

[Bug] Logs are created even if logging is disabled

3 participants