Skip to content

avoid some allocations when opening a connection #3364

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ErikEJ
Copy link
Contributor

@ErikEJ ErikEJ commented May 20, 2025

fixes #3363

@Copilot Copilot AI review requested due to automatic review settings May 20, 2025 13:03
@ErikEJ ErikEJ requested a review from a team as a code owner May 20, 2025 13:03
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR reduces runtime allocations by pre-building arrays of Azure SQL endpoint strings and refactoring the IsEndpoint helper to use these arrays instead of concatenating prefixes on each check.

  • Introduces s_azureSqlServerOnDemandEndpoints for on-demand endpoints.
  • Changes IsEndpoint to accept a string[] of endpoints.
  • Updates calls in IsAzureSynapseOnDemandEndpoint and IsAzureSqlServerEndpoint to use the new arrays.
Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs:781

  • Add unit tests covering each value in s_azureSqlServerOnDemandEndpoints to verify that IsAzureSynapseOnDemandEndpoint correctly recognizes all intended on-demand endpoints.
internal static readonly string[] s_azureSqlServerOnDemandEndpoints = { ONDEMAND_PREFIX + AZURE_SQL,

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Great efficiency win. Just a couple of comments.

@ErikEJ
Copy link
Contributor Author

ErikEJ commented May 20, 2025

@paulmedynski Comments addressed

paulmedynski
paulmedynski previously approved these changes May 20, 2025
Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Looks great!

@ErikEJ
Copy link
Contributor Author

ErikEJ commented May 20, 2025

Thanks @vonzshik !

@paulmedynski Possible to get CI running?

@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link

codecov bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.39%. Comparing base (6d2473d) to head (3953e73).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3364      +/-   ##
==========================================
- Coverage   65.10%   61.39%   -3.72%     
==========================================
  Files         300      294       -6     
  Lines       65376    65071     -305     
==========================================
- Hits        42565    39949    -2616     
- Misses      22811    25122    +2311     
Flag Coverage Δ
addons ?
netcore 66.55% <100.00%> (-1.77%) ⬇️
netfx 59.66% <100.00%> (-6.68%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ErikEJ
Copy link
Contributor Author

ErikEJ commented May 20, 2025

@cheenamalhotra @paulmedynski PR updated

@cheenamalhotra
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

paulmedynski
paulmedynski previously approved these changes May 20, 2025
@Wraith2
Copy link
Contributor

Wraith2 commented May 20, 2025

@ErikEJ
Copy link
Contributor Author

ErikEJ commented May 21, 2025

@Wraith2 Thanks, tests (and bugs) fixed.
@edwardneal PR updated

@ErikEJ
Copy link
Contributor Author

ErikEJ commented May 21, 2025

@cheenamalhotra @paulmedynski Could you please help with CI?

@cheenamalhotra
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@cheenamalhotra cheenamalhotra added this to the 6.1-preview2 milestone May 21, 2025
@ErikEJ ErikEJ requested a review from paulmedynski May 21, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce IsAzureSynapseOnDemandEndpoint allocations
5 participants