Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d5279be
PERF: reduce fetchall buffer over-allocation
jahnvi480 Nov 26, 2026
c2e355b
TEST: distinguish row overflow from cell overflow across platforms
jahnvi480 Nov 26, 2026
451be7f
Merge branch 'main' into jahnvi/issue-455-reduce-fetch-buffer-over-al…
jahnvi480 Nov 26, 2026
6c2a0ed
FIX: retain fetch buffers after cleanup failures
jahnvi480 Nov 26, 2026
713b428
FIX: skip Arrow cleanup test without optional pyarrow
jahnvi480 Nov 26, 2026
215e6cf
PERF: prototype reusable bounded-text fetch buffers
jahnvi480 Nov 26, 2026
7362ec4
Merge main and resolve fetch-buffer contract conflicts
jahnvi480 Nov 27, 2026
2068695
PERF: replace per-cell text reads with reusable bounded rowsets
jahnvi480 Nov 27, 2026
09c272d
FIX: preserve sparse UTF-8 rowsets and avoid growth after partial fet…
jahnvi480 Nov 27, 2026
9ad1449
TEST: cover reusable text rowset boundaries and rebind failures
jahnvi480 Nov 27, 2026
a8479d9
Merge main into reusable bounded-text fetch branch
jahnvi480 Nov 28, 2026
b2e2651
FIX: preserve fetchmany buffer limits with reusable rowsets
jahnvi480 Nov 28, 2026
a71be3d
TEST: restore reusable rowset binding contract assertions
jahnvi480 Nov 30, 2026
16c0fc0
FIX: stabilize LCOV rendering and Arrow budget regressions
jahnvi480 Dec 1, 2026
4e604a4
DOC: clarify bounded-rowset memory and throughput tradeoff
jahnvi480 Dec 1, 2026
4cdb5aa
PERF: reuse bounded-rowset conversion metadata
jahnvi480 Dec 1, 2026
715a812
PERF: restore sustained batching after small text fetch startup
jahnvi480 Dec 1, 2026
ffe6123
Merge branch 'main' into jahnvi/dynamic-string-fetch-buffers
jahnvi480 Dec 2, 2026
5790f79
Merge branch 'main' into jahnvi/dynamic-string-fetch-buffers
jahnvi480 Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,43 @@ strings do not require a character-by-character scan.
Wide-character retrieval of `VARCHAR(MAX)` values uses a non-consuming binary
length probe to size the conversion buffer, avoiding character loss at truncated
UTF-16 conversion boundaries while preserving embedded and trailing NULs.
The experimental bounded-text path uses complete, reusable rowsets for `fetchall()`
and `fetchmany()` when a text column is wider than 256 declared characters.
Each bound cell still reserves its complete declared width. Temporary memory
is reduced by binding fewer rows simultaneously and reusing those buffers,
not by allocating actual-length native cells.
Initial bound storage targets 1 MiB including indicators, with at least one
complete row and at most 100 rows. After the first full batch the row capacity
can grow once to the ordinary 8 MiB target and 1,000 rows. Partial batches do not
trigger growth, and `fetchmany()` never grows beyond its remaining requested rows.
Values are decoded directly into actual-length Python results, without a second
native copy or per-cell length probes. Every driver fetch retains
cancellation and diagnostic handling; rebinding preserves cleanup lifetimes.
Fixed-width and short-text result sets retain rowset batching. Wide-text result
sets save temporary storage at startup and for short results, not throughout
large sparse `fetchall()` results: sustained fetching grows to the normal 8 MiB
target rather than imposing a persistently higher driver-call count.
For `fetchmany()`, that target can still save storage compared with binding the
entire requested row count, but can require multiple driver fetches.
Conversion metadata and processor dispatch are prepared once per native
reusable-rowset call, including
across buffer growth. No per-cell density scan is needed.
The earlier fixed-small-rowset experiment used 0.98 MiB instead of 7.94 MiB for
5,000 rows with an integer ID and eight short values declared `VARCHAR(8000)`,
but increased fetch calls from 78 to 626. The growth policy intentionally gives
up that sustained memory reduction to restore useful batching.
Driver-call counts are not measured network round trips; they do not
establish production latency on the current revision. Profiling-enabled CI
reports are attribution evidence, and a "no signal" result does not rule out
smaller slowdowns. Repeated, matched, profiling-disabled measurements are needed
before claiming a throughput benefit or no regression.
The rowsets do not change the forward-only cursor type or recover truncated
multirow bindings with `SQLGetData`. A row larger than either budget remains
complete; Python results and allocator overhead are outside those targets.
`fetchmany()` retains the native 256 MiB caller-size guard based on the requested
row count and declared row width, even when reusable batches would be smaller.
Result sets containing LOB columns retain their existing streaming path.
The 256-character cutoff is provisional, not a tuned throughput threshold.
Explicit `setinputsizes()` SQL types and sizes still take precedence. An explicit
`VARCHAR` parameter can lose characters outside the database collation's code
page even when inserting into an `NVARCHAR` destination; use `SQL_WVARCHAR` when
Expand Down
33 changes: 33 additions & 0 deletions eng/scripts/normalize_python_lcov.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Move LCOV function starts off non-executable docstrings without changing hit counts."""

import argparse
from bisect import bisect_left
from pathlib import Path


def normalize_function_starts(report: str) -> str:
records = report.split("end_of_record")
if records[-1].strip():
raise ValueError("Incomplete LCOV record")
normalized = []
for record in records[:-1]:
lines = record.strip().splitlines()
executable = sorted(int(line[3:].split(",", 1)[0]) for line in lines if line.startswith("DA:"))
for index, line in enumerate(lines):
if not line.startswith("FN:"):
continue
start, end, name = line[3:].split(",", 2)
position = bisect_left(executable, int(start))
if position == len(executable) or executable[position] > int(end):
raise ValueError(f"Function {name!r} has no executable line in its LCOV range")
lines[index] = f"FN:{executable[position]},{end},{name}"
normalized.append("\n".join([*lines, "end_of_record"]))
return "\n".join(normalized) + "\n"


if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("report", type=Path)
args = parser.parse_args()
content = normalize_function_starts(args.report.read_text(encoding="utf-8"))
args.report.write_text(content, encoding="utf-8", newline="\n")
3 changes: 3 additions & 0 deletions generate_codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ python -m pytest -v "$@" \
# Convert Python coverage to LCOV format (restrict to repo only)
echo "[ACTION] Converting Python coverage to LCOV"
coverage lcov -o python-coverage.info --include="mssql_python/*"
# coverage.py 7.18 can place FN on a docstring with no DA entry. LCOV 2.4
# cannot categorize that location; use the first executable line in the range.
python eng/scripts/normalize_python_lcov.py python-coverage.info

echo "==================================="
echo "[STEP 3] Processing C++ coverage (Clang/LLVM)"
Expand Down
Loading
Loading