microsoft-authentication-library-for-java icon indicating copy to clipboard operation
microsoft-authentication-library-for-java copied to clipboard

Perf: Investigate optimizations around AcquireTokenSilentSupplier.getAuthorityWithPrefNetworkHost

Open billwert opened this issue 10 months ago • 0 comments

While doing some perf investigations on Azure Identity I noticed that we spend a ton of time in getAuthorityWithPrefNetworkHost when getting tokens out of the cache. The perf test is literally calling acquireTokenForManagedIdentity in a hot loop with no parameters or authority configured.

It ends up being ~70% of the time under AcquireSilentTokenSupplier.execute():

image image

Discussion with @Avery-Dunn offline leads to the thought that we can optimize this path some - there's no reason to recompute and reconstruct an authority every call.

This should be investigated in the silent, device code, and auth grant flows.

billwert avatar Jan 09 '25 17:01 billwert