Skip to content

Readme Updates -2 - #5

Merged
Sumit Sarabhai (sumitmsft) merged 1 commit into
mainfrom
sumitsar/ReadmeUpdates
Feb 11, 2025
Merged

Sumit Sarabhai (sumitmsft) merged 1 commit into
mainfrom
sumitsar/ReadmeUpdates

Conversation

@sumitmsft

Copy link
Copy Markdown
Contributor

Added some cosmetic changes

Gaurav Sharma (bewithgaurav) added a commit that referenced this pull request Nov 10, 2025
- Add ColumnProcessor typedef and ColumnProcessors namespace with specialized handlers
- Build columnProcessors[] array once per batch (switch executed per column, not per cell)
- Fast path: Direct function call for common types (INT, VARCHAR, etc.)
- Slow path: Fallback switch for complex types (DECIMAL, DATETIME, GUID)
- Eliminates 99.99% of switch evaluations (20 vs 200,000 for 10K rows × 20 cols)
- All processor functions use direct Python C API (PyList_SET_ITEM, PyLong_FromLong, etc.)
- Expected improvement: 60% reduction in CPU cycles per cell, better branch prediction
- This completes the optimization sequence - file now matches ddbc_bindings_profiled_optimized.cpp line-by-line
Gaurav Sharma (bewithgaurav) added a commit that referenced this pull request Nov 10, 2025
- Created typedef ColumnProcessor for function pointer type
- Added ColumnProcessors namespace with specialized inline processors:
  * ProcessInteger, ProcessSmallInt, ProcessBigInt, ProcessTinyInt, ProcessBit
  * ProcessReal, ProcessDouble
  * ProcessChar, ProcessWChar, ProcessBinary (handle LOBs, NULL, zero-length)
- Added ColumnInfoExt struct to pass metadata efficiently
- Build columnProcessors array once during cache_column_metadata
- Fast path: Direct function call via columnProcessors[col-1] (no switch)
- Slow path: Fallback switch for complex types (DECIMAL, DATETIME, GUID)
- Eliminates switch evaluation from O(rows × columns) to O(columns)
- All processors use direct Python C API from OPT #1 and OPT #2
Gaurav Sharma (bewithgaurav) added a commit that referenced this pull request Nov 10, 2025
Eliminates switch statement overhead from hot loop by pre-computing
function pointer dispatch table once per batch instead of per cell.

Problem:
- Previous code evaluated switch statement 100,000 times for 1,000 rows × 10 cols
- Each switch evaluation costs 5-12 CPU cycles
- Total overhead: 500K-1.2M cycles per batch

Solution:
- Extract 10 processor functions for common types (INT, VARCHAR, etc.)
- Build function pointer array once per batch (10 switch evaluations)
- Hot loop uses direct function calls (~1 cycle each)
- Complex types (Decimal, DateTime, Guid) use fallback switch

Implementation:
- Created ColumnProcessor typedef for function pointer signature
- Added ColumnInfoExt struct with metadata needed by processors
- Implemented 10 inline processor functions in ColumnProcessors namespace:
  * ProcessInteger, ProcessSmallInt, ProcessBigInt, ProcessTinyInt, ProcessBit
  * ProcessReal, ProcessDouble
  * ProcessChar, ProcessWChar, ProcessBinary
- Build processor array after OPT #3 metadata prefetch
- Modified hot loop to use function pointers with fallback for complex types

Performance Impact:
- Reduces dispatch overhead by 70-80%
- 100,000 switch evaluations → 10 setup switches + 100,000 direct calls
- Estimated savings: ~450K-1.1M cycles per 1,000-row batch

Builds successfully on macOS Universal2 (arm64 + x86_64)
Gaurav Sharma (bewithgaurav) added a commit that referenced this pull request Nov 12, 2025
- Moved typedef ColumnProcessor, struct ColumnInfoExt, and all 10 inline processor functions from ddbc_bindings.cpp to ddbc_bindings.h
- Added new 'INTERNAL: Performance Optimization Helpers' section in header
- Added forward declarations for ColumnBuffers struct and FetchLobColumnData function
- Enables true cross-compilation-unit inlining for performance optimization
- Follows C++ best practices for inline function placement

Addresses review comments #4, #5, #6 from subrata-ms
Gaurav Sharma (bewithgaurav) added a commit that referenced this pull request Nov 12, 2025
…der file

- Moved DateTimeOffset struct definition to header (required by ColumnBuffers)
- Moved ColumnBuffers struct definition to header (required by inline functions)
- Moved typedef ColumnProcessor, struct ColumnInfoExt, and all 10 inline processor functions to header
- Added new 'INTERNAL: Performance Optimization Helpers' section in header
- Added forward declaration for FetchLobColumnData function
- Enables true cross-compilation-unit inlining for performance optimization
- Follows C++ best practices for inline function placement

Addresses review comments #4, #5, #6 from subrata-ms
Build verified successful (universal2 binary for macOS arm64 + x86_64)
gargsaumya added a commit that referenced this pull request Apr 15, 2026
New tests:
- test_executemany_large_batch_mixed_types: 10k rows, mixed types via executemany
- test_null_heavy_large_result_set: 50k rows with 6/8 cols NULL, verify None propagation
- test_cursor_reuse_high_iteration: single cursor reused 5000 times, memory leak check
- test_fetchone_loop_vs_fetchall_parity: 100k row bit-identical comparison of both fetch paths
- test_concurrent_read_write_no_corruption: 5 writers + 5 readers on shared table for 10s

Bug fixes:
- test_concurrent_fetch_data_integrity_no_corruption: verification block was inside
  thread.join() loop instead of after it (race condition + premature fail)
- test_pool_exhaustion_recovery: pool max_size was silently overridden by run_parallel();
  added pool_max_size param to MultiThreadedQueryRunner; fixed multi-statement query
- test numbering: docstring sequence skipped #4 (renumbered #5-#7 -> #4-#6)

Also registers 'slow' mark in pytest.ini to suppress PytestUnknownMarkWarning
gargsaumya added a commit that referenced this pull request Apr 15, 2026
New tests:
- test_executemany_large_batch_mixed_types: 10k rows, mixed types via executemany
- test_null_heavy_large_result_set: 50k rows with 6/8 cols NULL, verify None propagation
- test_cursor_reuse_high_iteration: single cursor reused 5000 times, memory leak check
- test_fetchone_loop_vs_fetchall_parity: 100k row bit-identical comparison of both fetch paths
- test_concurrent_read_write_no_corruption: 5 writers + 5 readers on shared table for 10s

Bug fixes:
- test_concurrent_fetch_data_integrity_no_corruption: verification block was inside
  thread.join() loop instead of after it (race condition + premature fail)
- test_pool_exhaustion_recovery: pool max_size was silently overridden by run_parallel();
  added pool_max_size param to MultiThreadedQueryRunner; fixed multi-statement query
- test numbering: docstring sequence skipped #4 (renumbered #5-#7 -> #4-#6)

Also registers 'slow' mark in pytest.ini to suppress PytestUnknownMarkWarning
gargsaumya added a commit that referenced this pull request Apr 23, 2026
…sts (#523)

New tests:
- test_executemany_large_batch_mixed_types: 10k rows, mixed types via
executemany
- test_null_heavy_large_result_set: 50k rows with 6/8 cols NULL, verify
None propagation
- test_cursor_reuse_high_iteration: single cursor reused 5000 times,
memory leak check
- test_fetchone_loop_vs_fetchall_parity: 100k row bit-identical
comparison of both fetch paths
- test_concurrent_read_write_no_corruption: 5 writers + 5 readers on
shared table for 10s

Bug fixes:
- test_concurrent_fetch_data_integrity_no_corruption: verification block
was inside thread.join() loop instead of after it (race condition +
premature fail)
- test_pool_exhaustion_recovery: pool max_size was silently overridden
by run_parallel(); added pool_max_size param to
MultiThreadedQueryRunner; fixed multi-statement query
- test numbering: docstring sequence skipped #4 (renumbered #5-#7 ->
#4-#6)

Also registers 'slow' mark in pytest.ini to suppress
PytestUnknownMarkWarning

### Work Item / Issue Reference  
<!-- 
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below 
For external contributors: Insert Github Issue number below
Only one reference is required - either GitHub issue OR ADO Work Item.
-->

<!-- mssql-python maintainers: ADO Work Item -->
> AB#<WORK_ITEM_ID>

<!-- External contributors: GitHub Issue -->
> GitHub Issue: #<ISSUE_NUMBER>

-------------------------------------------------------------------
### Summary   
<!-- Insert your summary of changes below. Minimum 10 characters
required. -->
This pull request adds several new high-scale stress tests and improves
the configurability and coverage of both single-threaded and
multi-threaded stress testing. The main updates include three new
single-threaded stress tests for executemany with mixed types,
NULL-heavy result sets, and high-iteration cursor re-use, plus a
fetchone vs fetchall parity test. Multi-threaded stress tests now
support explicit pool size configuration and improved pool exhaustion
testing. Test documentation and marker registration have also been
updated.

**Single-threaded stress test enhancements:**

* Added `test_executemany_large_batch_mixed_types` to stress-test
`executemany()` with 10,000 mixed-type rows, verifying parameter
serialization and correctness.
* Added `test_null_heavy_large_result_set` to fetch 50,000 rows with 6/8
columns as NULL, ensuring correct NULL handling at scale.
* Added `test_cursor_reuse_high_iteration` to re-use a single cursor for
5,000 execute/fetch cycles, checking for memory leaks and state reset.
* Added `test_fetchone_loop_vs_fetchall_parity` to verify bit-identical
results between fetchone() and fetchall() for 100,000 rows.
* Updated test docstrings and numbering for clarity and completeness.
[[1]](diffhunk://#diff-443e544600e5ca6d41ed9581de5c97b50cac49ad4b912fa9c96373883fa5badcR10-R14)
[[2]](diffhunk://#diff-443e544600e5ca6d41ed9581de5c97b50cac49ad4b912fa9c96373883fa5badcL265-R270)
[[3]](diffhunk://#diff-443e544600e5ca6d41ed9581de5c97b50cac49ad4b912fa9c96373883fa5badcL359-R364)
[[4]](diffhunk://#diff-443e544600e5ca6d41ed9581de5c97b50cac49ad4b912fa9c96373883fa5badcL461-R466)

**Multi-threaded stress test improvements:**

* The `MultiThreadedQueryRunner` now accepts a `pool_max_size`
parameter, allowing explicit control of the connection pool size in
tests.
[[1]](diffhunk://#diff-c682540720fa9ea7be607c26d2b18c03c94e122f9eed7bc4501348aad24c937aR116-R123)
[[2]](diffhunk://#diff-c682540720fa9ea7be607c26d2b18c03c94e122f9eed7bc4501348aad24c937aL250-R254)
* The pool exhaustion test (`test_pool_exhaustion_recovery`) now uses
the explicit pool size parameter and improved query logic for more
accurate stress simulation and reporting.
[[1]](diffhunk://#diff-c682540720fa9ea7be607c26d2b18c03c94e122f9eed7bc4501348aad24c937aL729-R741)
[[2]](diffhunk://#diff-c682540720fa9ea7be607c26d2b18c03c94e122f9eed7bc4501348aad24c937aL752-R755)
* Test documentation updated to clarify coverage of pool exhaustion and
concurrent mixed read/write.

**Test marker and config updates:**

* Registered a new `slow` pytest marker for extra-slow tests,
complementing the existing `stress` marker.

These changes expand test coverage for edge-case and high-load
scenarios, improve test documentation, and make stress tests more
configurable and robust.

<!-- 
### PR Title Guide

> For feature requests
FEAT: (short-description)

> For non-feature requests like test case updates, config updates ,
dependency updates etc
CHORE: (short-description) 

> For Fix requests
FIX: (short-description)

> For doc update requests 
DOC: (short-description)

> For Formatting, indentation, or styling update
STYLE: (short-description)

> For Refactor, without any feature changes
REFACTOR: (short-description)

> For release related changes, without any feature changes
RELEASE: #<RELEASE_VERSION> (short-description) 

### Contribution Guidelines

External contributors:
- Create a GitHub issue first:
https://github.com/microsoft/mssql-python/issues/new
- Link the GitHub issue in the "GitHub Issue" section above
- Follow the PR title format and provide a meaningful summary

mssql-python maintainers:
- Create an ADO Work Item following internal processes
- Link the ADO Work Item in the "ADO Work Item" section above  
- Follow the PR title format and provide a meaningful summary
-->
Jahnvi Thakkar (jahnvi480) added a commit that referenced this pull request Sep 4, 2026
…rchestrator

Replace build-conda-packages.ps1 + build-conda-packages.sh with one cross-platform Python orchestrator (OneBranchPipelines/scripts/build_conda_packages.py) and collapse both conda-build-validate step templates to invoke it; eliminates the duplicated PowerShell/bash logic and the cmd /c exit-0 hack. Also folds in three-lens review findings: #1 assert_pe_machine.py requires a vendored mssql-auth DLL on win-arm64 (loader throws at connect if absent); #3 audit_bundled_binaries.py scans the whole payload for vendored crypto .so, not just /libs/linux/; #4 build_conda_packages.py clears bld/ and LINKS and pins mssql-python==version in the verify env; #5 conda-build-pipeline.yml documents that the win-arm64 python set (3.12-3.14) is a deliberately fixed matrix. Tests: add win-arm64 missing-auth-DLL (test_030) and vendored-crypto-outside-libs-linux (test_029) failure cases.
Jahnvi Thakkar (jahnvi480) added a commit that referenced this pull request Sep 4, 2026
…rchestrator

Replace build-conda-packages.ps1 + build-conda-packages.sh with one cross-platform Python orchestrator (OneBranchPipelines/scripts/build_conda_packages.py) and collapse both conda-build-validate step templates to invoke it; eliminates the duplicated PowerShell/bash logic and the cmd /c exit-0 hack. Also folds in three-lens review findings: #1 assert_pe_machine.py requires a vendored mssql-auth DLL on win-arm64 (loader throws at connect if absent); #3 audit_bundled_binaries.py scans the whole payload for vendored crypto .so, not just /libs/linux/; #4 build_conda_packages.py clears bld/ and LINKS and pins mssql-python==version in the verify env; #5 conda-build-pipeline.yml documents that the win-arm64 python set (3.12-3.14) is a deliberately fixed matrix. Tests: add win-arm64 missing-auth-DLL (test_030) and vendored-crypto-outside-libs-linux (test_029) failure cases.
Jahnvi Thakkar (jahnvi480) added a commit that referenced this pull request Sep 4, 2026
…wired conda_resolve_check (#4)

#5 (conda-publish-step.yml): condaChannel/condaLabel were compile-time template-interpolated into the token-bearing inline PowerShell, so a value containing a quote would break the script text before any guard runs (a runtime guard cannot help a compile-time substitution). Surfaced them via the step env block and read them at RUNTIME as env:CONDA_CHANNEL / env:CONDA_LABEL throughout the script body (9 uses); the displayName keeps template interpolation (not script text). Injection-proof (operator-only inputs); YAML + PS AST parse clean. #4: removed eng/scripts/conda_resolve_check.py + tests/test_032_conda_resolve_check.py + their conda-audit.yml references. The release-time channel-drift re-solve gate was built + unit-tested but WIRED INTO NOTHING (no pipeline invokes it; ValidateConda has no conda/mamba), so its 'blocks the publish' docstring was aspirational -- it gated nothing. Removing it drops zero runtime protection and clears the dead-code comment cluster; a tracked issue will reintroduce it wired + validated together. Remaining conda-audit tests: 65 pass.
Jahnvi Thakkar (jahnvi480) added a commit that referenced this pull request Sep 7, 2026
…t odbc-wheel match

PR #744 review #4: assert_macho_arch.py reads the Mach-O cputype slice(s) out of every vendored .dylib/.so and asserts the osx-64/osx-arm64 arch is present. osx-arm64 is cross-built on Intel where its runtime import is skipped, so this static pass is its only arch+presence check. Wired into audit_packages() next to the win-arm64 PE assert; test_035 mirrors test_030.

PR #744 review #5: iter_payload_members now raises ValueError on an unrecognized extension (fail-closed like read_index) instead of silently yielding an empty iterator; test_029 covers it.

PR #744 review #2: gather_wheels demands exactly one odbc-wheel-filter match instead of silently picking the first, so an arch-ambiguous filter cannot vendor the wrong-arch driver.
Jahnvi Thakkar (jahnvi480) added a commit that referenced this pull request Sep 7, 2026
…t odbc-wheel match

PR #744 review #4: assert_macho_arch.py reads the Mach-O cputype slice(s) out of every vendored .dylib/.so and asserts the osx-64/osx-arm64 arch is present. osx-arm64 is cross-built on Intel where its runtime import is skipped, so this static pass is its only arch+presence check. Wired into audit_packages() next to the win-arm64 PE assert; test_035 mirrors test_030.

PR #744 review #5: iter_payload_members now raises ValueError on an unrecognized extension (fail-closed like read_index) instead of silently yielding an empty iterator; test_029 covers it.

PR #744 review #2: gather_wheels demands exactly one odbc-wheel-filter match instead of silently picking the first, so an arch-ambiguous filter cannot vendor the wrong-arch driver.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant