Perf/sdk internal processing v2#46
Open
xinlian12 wants to merge 4 commits into
Open
Conversation
Eliminate per-response intermediate HashMap allocation by adding a new StoreResponse constructor that accepts HttpHeaders directly. Header names and values are populated into String[] arrays without materializing an intermediate Map. The JsonNodeStorePayload is updated to accept header arrays and only builds a Map lazily on error paths (extremely rare). Pre-size HashMaps throughout the hot path to avoid resize/rehash: - HttpHeaders request construction: sized to defaultHeaders + request headers - StoreResponse.replicaStatusList: pre-sized to 4 - StoreResponse.withRemappedStatusCode: pre-sized to header count - RxDocumentServiceRequest fallback maps: pre-sized to 32 Fix HttpUtils.asMap() double-allocation by iterating HttpHeaders directly instead of calling toMap() which creates an intermediate HashMap. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Case fast-path Change 1: Replace vendored UnmodifiableList with Collections.unmodifiableList() - UnmodifiableList wraps via 4-level virtual dispatch chain (UnmodifiableList -> AbstractSerializableListDecorator -> AbstractListDecorator -> AbstractCollectionDecorator) - AbstractListDecorator.decorated() called on every list operation accounts for ~1.02% CPU (398 samples at 1t-c128) - Collections.unmodifiableList() returns a simple wrapper that JIT can inline efficiently Change 2: Add isAsciiLowerCase fast-path in HttpHeaders - HTTP/2 headers are already lowercase per protocol spec - Most x-ms-* custom headers are already lowercase - Skip String.toLowerCase(Locale.ROOT) when string is already all-lowercase via simple char range check - StringLatin1.toLowerCase accounts for ~1.29% CPU (500 samples) Files changed: - LocationCache.java: field types + return types + constructors - GlobalEndpointManager.java: return types - ClientRetryPolicy.java: variable type - GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker.java: variable types - HttpHeaders.java: set() and getHeader() fast-path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.