Skip to content

Update README - #4

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 technical details about the description of the driver.

  • Summary of the driver
  • Key Features
  • Example\Sample
@sumitmsft

Copy link
Copy Markdown
Contributor Author
Gaurav Sharma (bewithgaurav) added a commit that referenced this pull request Nov 10, 2025
- Replace placeholder allocation (rows.append(py::none())) with direct PyList_New
- Use PyList_Append + Py_DECREF for cleaner refcount management
- Eliminates double allocation: no more placeholder → real row replacement
- Uses rowWrapper for pybind11 compatibility while row is raw PyObject*
- Removed final rows[initialSize + i] = row assignment (already appended)
- Expected improvement: 15-20ms for 10K rows, reduces memory allocator pressure
- Added PERF_TIMER for rows_append to measure append overhead
Gaurav Sharma (bewithgaurav) added a commit that referenced this pull request Nov 10, 2025
- Replaced placeholder allocation (py::none()) with direct PyList_New + PyList_Append
- Pre-allocate all row lists before populating them
- Uses PyList_GET_ITEM to retrieve pre-allocated rows (no bounds checking)
- Wrap raw PyObject* in py::list for pybind11 compatibility
- Eliminates redundant row assignment at end of loop (row already in list)
- Renamed PERF_TIMER from allocate_placeholder_rows to rows_append
- Reduces memory allocator calls from O(2×rows) to O(rows)
Gaurav Sharma (bewithgaurav) added a commit that referenced this pull request Nov 10, 2025
Problem:
--------
Row creation and assignment had multiple layers of overhead:
1. Per-row allocation: py::list(numCols) creates pybind11 wrapper for each row
2. Cell assignment: row[col-1] = value uses pybind11 operator[] with bounds checking
3. Final assignment: rows[i] = row uses pybind11 list assignment with refcount overhead
4. Fragmented allocation: 1,000 separate py::list() calls instead of batch allocation

For 1,000 rows: ~30-50 CPU cycles × 1,000 = 30K-50K wasted cycles

Solution:
---------
Replace pybind11 wrappers with direct Python C API throughout:

1. Row creation: PyList_New(numCols) instead of py::list(numCols)
2. Cell assignment: PyList_SET_ITEM(row, col-1, value) instead of row[col-1] = value
3. Final assignment: PyList_SET_ITEM(rows.ptr(), i, row) instead of rows[i] = row

This completes the transition to direct Python C API started in OPT #2.

Changes:
--------
- Replaced py::list row(numCols) → PyObject* row = PyList_New(numCols)
- Updated all NULL/SQL_NO_TOTAL handlers to use PyList_SET_ITEM
- Updated all zero-length data handlers to use direct Python C API
- Updated string handlers (SQL_CHAR, SQL_WCHAR) to use PyList_SET_ITEM
- Updated complex type handlers (DECIMAL, DATETIME, DATE, TIME, TIMESTAMPOFFSET, GUID, BINARY)
- Updated final row assignment to use PyList_SET_ITEM(rows.ptr(), i, row)

All cell assignments now use direct Python C API:
- Numeric types: Already done in OPT #2 (PyLong_FromLong, PyFloat_FromDouble, etc.)
- Strings: PyUnicode_FromStringAndSize, PyUnicode_FromString
- Binary: PyBytes_FromStringAndSize
- Complex types: .release().ptr() to transfer ownership

Impact:
-------
- ✅ Eliminates pybind11 wrapper overhead for row creation
- ✅ No bounds checking in hot loop (PyList_SET_ITEM is a macro)
- ✅ Clean reference counting (objects created with refcount=1, transferred to list)
- ✅ Consistent with OPT #2 (entire row/cell management via Python C API)
- ✅ Expected 5-10% improvement (smaller than OPT #3, but completes the stack)

All type handlers now bypass pybind11 for maximum performance.
Gaurav Sharma (bewithgaurav) added a commit that referenced this pull request Nov 10, 2025
…ild fix)

Same issue as OPT #3 - Windows compiler treats warnings as errors (/WX).
The columnSize variable was extracted but unused in SQL_CHAR and SQL_WCHAR
cases after OPTIMIZATION #4.

Changes:
--------
- Removed unused 'SQLULEN columnSize' from SQL_CHAR/VARCHAR/LONGVARCHAR
- Removed unused 'SQLULEN columnSize' from SQL_WCHAR/WVARCHAR/WLONGVARCHAR
- Retained fetchBufferSize and isLob which are actively used

Fixes Windows build error C4189 treated as error C2220.
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