Skip to content

Commit 617dcb8

Browse files
Merge pull request #824 from pyathena-dev/fix/644-fleet-init-api-weight
Count initialization row validation as API-heavy fleet work
2 parents 42af6b7 + 1951ac1 commit 617dcb8

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎benchmarks/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ All hosts share the stack's scratch bucket and database: prepare once, and every
275275
Each host runs one worker, and each worker runs one orchestrator at a time, so trials on a host never overlap.
276276

277277
Athena executes queries from different hosts independently, but API request rates are account-wide.
278-
Cursor and DictCursor row retrieval calls GetQueryResults for every page, about 5 to 10 pages per second per query in the recorded runs; check the account's GetQueryResults rate in Service Quotas (100 calls per second in the tested account).
278+
Cursor and DictCursor row retrieval calls GetQueryResults for every page, including the initialization suite's row-count validation, about 5 to 10 pages per second per query in the recorded runs; check the account's GetQueryResults rate in Service Quotas (100 calls per second in the tested account).
279279
`jobs` marks these jobs as API-heavy with an estimated page count and the number of simultaneous paging queries, which is the concurrency level for the concurrent suite.
280280
`worker --api-slots` bounds the simultaneous paging queries across the fleet (10 by default): a job takes one slot per paging query, and a worker refuses to start if any job needs more slots than that.
281281
While an API-heavy job waits for slots, workers do not start later API-heavy jobs; other jobs run on every free host.

‎benchmarks/pyathena_bench/fleet.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@ def api_pages(case: Case, rows: int) -> int:
6868
case: Benchmark case.
6969
rows: Rows in the selected snapshot.
7070
71+
The initialization suite counts too: it validates the constructed result
72+
set by reading every row.
73+
7174
Returns:
7275
Page count summed over the trial's concurrent queries; 0 for cases that
7376
do not page through the API.
7477
"""
75-
if case.family not in API_FAMILIES or case.suite == "init":
78+
if case.family not in API_FAMILIES:
7679
return 0
77-
return -(-rows // case.arraysize) * case.concurrency
80+
# The first page of a SELECT result also carries the column labels.
81+
return -(-(rows + 1) // case.arraysize) * case.concurrency
7882

7983

8084
def expand_jobs(

‎benchmarks/tests/test_fleet.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,25 @@ def test_row_output_jobs_keep_one_arraysize_for_every_family(self):
147147
assert jobs[0]["args"][-2:] == ["--arraysize", "100"]
148148
assert not jobs[0]["api_heavy"]
149149

150+
def test_initialization_validation_of_row_cursors_is_api_heavy(self):
151+
jobs = expand_jobs(
152+
SETTINGS, ["init"], ["small"], ["flat"], Filters(family=["cursor", "arrow"])
153+
)
154+
heavy = {j["id"]: (j["api_heavy"], j["api_weight"]) for j in jobs}
155+
assert heavy["init-small-flat-cursor-direct-csv-rows-a1000"] == (True, 1)
156+
assert heavy["init-small-flat-arrow-direct-csv-native"] == (False, 0)
157+
158+
def test_page_estimate_includes_the_column_label_row(self):
159+
cursor = Filters(family=["cursor"], api=["direct"])
160+
jobs = expand_jobs(SETTINGS, ["init"], ["small"], ["flat"], cursor, split_pages=11)
161+
assert [j["id"] for j in jobs] == [
162+
f"init-small-flat-cursor-direct-csv-rows-a1000-r{repetition}"
163+
for repetition in range(1, 6)
164+
]
165+
assert {j["pages"] for j in jobs} == {11}
166+
unsplit = expand_jobs(SETTINGS, ["init"], ["small"], ["flat"], cursor, split_pages=12)
167+
assert [j["id"] for j in unsplit] == ["init-small-flat-cursor-direct-csv-rows-a1000"]
168+
150169
def test_concurrent_row_jobs_weigh_simultaneous_paging_queries(self):
151170
settings = Settings(scales={"small": 10000}, concurrency=[1, 10])
152171
jobs = expand_jobs(

0 commit comments

Comments
 (0)