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

Reduce synchronization lock contention in common code paths #41816

Merged
merged 6 commits into from
Sep 19, 2024

Conversation

alzimmermsft
Copy link
Member

Description

Prototype PR aiming to reduce synchronization and lock contention in common code paths.

new URL(String) requires a lookup to get the URLStreamHandler for the URL. This lookup uses a HashTable which has synchronized applied to its APIs. In highly threaded environments this can result in drastic contention. There is a similar API new URL(URL, String) which takes an existing URL and copies information from that to the new URL being parsed. If the existing URL already has a URLStreamHandler it circumvents the lookup. Prototype here is using a simple URL that only contains values that will be overridden by the new URL (host).

Collator.getInstance(Locale.ROOT) can result in a Collator instance that synchronized its compare method. This PR modifies the usage to be a ThreadLocal so there isn't contention when using the instance as it'll be local to the calling Thread. Additional investigation should be done if String.compareTo and String.CASE_INSENSITIVE_ORDER could be used instead of a ThreadLocal as those don't synchronized and don't require Thread-based variables.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@github-actions github-actions bot added Azure.Core azure-core Storage Storage Service (Queues, Blobs, Files) labels Sep 11, 2024
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@alzimmermsft
Copy link
Member Author

/azp run java - core

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@alzimmermsft alzimmermsft merged commit 49870b9 into Azure:main Sep 19, 2024
36 checks passed
@alzimmermsft alzimmermsft deleted the AzPerf_ReduceLockContention branch September 19, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core azure-core Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants