Parent issue: #5747
Problem
AddressResolver.TryResolveServerPartitionAsync() (src/Routing/AddressResolver.cs:497-510) accesses PartitionKeyRange.Id 3 times during address resolution. Since Id inherits from Resource JsonSerializable, each access triggers JToken.ToObject<T>(). This method is called on every single request as part of core routing.
Hot path assessment: HOT
Every SDK operation goes through ResolveAsync() TryResolveServerPartitionAsync(). This is the most frequently executed code path in the SDK.
Suggested fix
Cache range.Id in a local variable at the top of the method before the 3 usages at lines 497, 501, and 510.
Lines
AddressResolver.cs:497 routingMap.TryGetInfoByPartitionKeyRangeId(range.Id)
AddressResolver.cs:501 new PartitionKeyRangeIdentity(collection.ResourceId, range.Id)
AddressResolver.cs:510 new PartitionKeyRangeIdentity(collection.ResourceId, range.Id)
Constraint
PartitionKeyRange is in compiled NuGet (Microsoft.Azure.Cosmos.Direct) fix must be at the call site.
Parent issue: #5747
Problem
AddressResolver.TryResolveServerPartitionAsync()(src/Routing/AddressResolver.cs:497-510) accessesPartitionKeyRange.Id3 times during address resolution. SinceIdinherits fromResource JsonSerializable, each access triggersJToken.ToObject<T>(). This method is called on every single request as part of core routing.Hot path assessment: HOT
Every SDK operation goes through
ResolveAsync() TryResolveServerPartitionAsync(). This is the most frequently executed code path in the SDK.Suggested fix
Cache
range.Idin a local variable at the top of the method before the 3 usages at lines 497, 501, and 510.Lines
AddressResolver.cs:497routingMap.TryGetInfoByPartitionKeyRangeId(range.Id)AddressResolver.cs:501new PartitionKeyRangeIdentity(collection.ResourceId, range.Id)AddressResolver.cs:510new PartitionKeyRangeIdentity(collection.ResourceId, range.Id)Constraint
PartitionKeyRangeis in compiled NuGet (Microsoft.Azure.Cosmos.Direct) fix must be at the call site.