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

Performance: Direct code path performance improvements (both memory and CPU) #14147

Closed
wants to merge 5 commits into from

Conversation

kirankumarkolli
Copy link
Member

@kirankumarkolli kirankumarkolli commented Aug 14, 2020

  • O(n) headers iteration in StoreResult for ReqeustCharge (DirectConnectivity header names are always populated inside SDK)
  • O(n) Map headers to arrays and then reverse conversion overhead (including memory) StoreResponse
  • Extra map materialization in StoreClient
  • Avoid intermediate List materializations in RntbdResponseHeaders
  • O(n) -O(1) handling for OWNER_FULL_NAME_VALUE header value

DO_NOT_MERGE

- O(n) headers iteration in StoreResult for ReqeustCharge (DirectConnectivity header names are always populated inside SDK)
- O(n) Map headers to arrays and then reverse conversion overhead (including memory) StoreResponse
- Extra map materialization in StoreClient
- Avoid intermediate List<Entry> materializations in RntbdResponseHeaders
- O(n) -O(1) handling for OWNER_FULL_NAME_VALUE header value
@kirankumarkolli
Copy link
Member Author

Yet to run the performance benchmark

- O(n) headers iteration in StoreResult for ReqeustCharge (DirectConnectivity header names are always populated inside SDK)
- O(n) Map headers to arrays and then reverse conversion overhead (including memory) StoreResponse
- Extra map materialization in StoreClient
- Avoid intermediate List<Entry> materializations in RntbdResponseHeaders
- O(n) -O(1) handling for OWNER_FULL_NAME_VALUE header value
result.add(entry);
public static void unescape(Map<String, String> headers) {
if (headers != null) {
headers.computeIfPresent(HttpConstants.HttpHeaders.OWNER_FULL_NAME,
Copy link
Contributor

Choose a reason for hiding this comment

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

very good change. thanks.

@@ -19,7 +19,7 @@ public void stringContent() {
headerMap.put("key1", "value1");
headerMap.put("key2", "value2");

StoreResponse sp = new StoreResponse(200, new ArrayList<>(headerMap.entrySet()), getUTF8BytesOrNull(content));
StoreResponse sp = new StoreResponse(200,headerMap, getUTF8BytesOrNull(content));
Copy link
Contributor

Choose a reason for hiding this comment

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

code style space after comma

Suggested change
StoreResponse sp = new StoreResponse(200,headerMap, getUTF8BytesOrNull(content));
StoreResponse sp = new StoreResponse(200, headerMap, getUTF8BytesOrNull(content));

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

}
}
else if (response.getResponseHeaders() != null) {
response.getResponseHeaders().put(HttpConstants.HttpHeaders.REQUEST_CHARGE, Double.toString(totalRequestCharge));
Copy link
Contributor

Choose a reason for hiding this comment

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

Rntbd generated response headerMap is ImmutableMap.
now that the intermediate copied version is removed are we modifying the rntbd header map directly? if so this may not work.

Could you please check.

toBooleanEntry(BackendHeaders.OFFER_REPLACE_PENDING, token)
);
private Map<String, String> collectEntries(final RntbdContext context, final UUID activityId) {
Map<String, String> responseHeaders = new HashMap<>(this.computeCount() + 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember I tested this a few months back and I found out that guava ImmutableMap construction is more performant than HashMap construction.
in my old perf testing replacing ImmutableMap with HashMap resulted in perf drop.

Could you please do a fully e2e perf testing to compare the perf difference of this PR?

openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-java that referenced this pull request Jun 2, 2021
AKS: Review request for Microsoft.ContainerService to add version stable/2021-05-01 (Azure#14147)

* Adds base for updating Microsoft.ContainerService from version stable/2021-03-01 to version 2021-05-01

* Updates readme

* Updates API version in new specs and examples

* add APIServerAccessProfile.enablePrivateClusterPublicFQDN in 2021-05-01 (Azure#14149)

* add APIServerAccessProfile.enablePrivateClusterPublicFQDN in 2021-05-01 api

* ref example

Co-authored-by: Li Ma <[email protected]>

* Add swagger for OutboundNetworkDependenciesEndpoints for AKS (Azure#14332)

* Add swagger for OutboundNetworkDependenciesEndpoints for AKS

* fix

* lint

* update operationId

* aks: add enableUltraSSD in v20210501 api-version (Azure#14354)

* update doc for agentpool max count from 100 to 1000 (Azure#14553)

Co-authored-by: Li Ma <[email protected]>

* add readme for new version (Azure#14611)

Co-authored-by: Li Ma <[email protected]>

* fix conflict (Azure#14614)

Co-authored-by: Li Ma <[email protected]>

Co-authored-by: Li Ma <[email protected]>
Co-authored-by: gossion <[email protected]>
Co-authored-by: Andy Zhang <[email protected]>
@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Feb 25, 2022
@ghost
Copy link

ghost commented Feb 25, 2022

Hi @kirankumarkolli. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@ghost ghost closed this Mar 4, 2022
@ghost
Copy link

ghost commented Mar 4, 2022

Hi @kirankumarkolli. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing "/reopen" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the "no-recent-activity" label; otherwise, this is likely to be closed again with the next cleanup pass.

@conniey conniey deleted the users/kirankk/store_response_headers branch March 17, 2022 19:15
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cosmos no-recent-activity There has been no recent activity on this issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants