|
3 | 3 | import asyncio
|
4 | 4 | import gc
|
5 | 5 | import pickle
|
6 |
| -from collections import defaultdict |
7 | 6 | from collections.abc import Iterator
|
8 | 7 |
|
9 | 8 | import pytest
|
@@ -1352,189 +1351,3 @@ def test_transfer_incoming_metrics(ws):
|
1352 | 1351 | assert ws.transfer_incoming_bytes == 0
|
1353 | 1352 | assert ws.transfer_incoming_count == 0
|
1354 | 1353 | assert ws.transfer_incoming_count_total == 4
|
1355 |
| - |
1356 |
| - |
1357 |
| -def test_throttling_does_not_affect_first_transfer(ws): |
1358 |
| - ws.transfer_incoming_count_limit = 100 |
1359 |
| - ws.transfer_incoming_bytes_limit = 100 |
1360 |
| - ws.transfer_incoming_bytes_throttle_threshold = 1 |
1361 |
| - ws2 = "127.0.0.1:2" |
1362 |
| - ws.handle_stimulus( |
1363 |
| - ComputeTaskEvent.dummy( |
1364 |
| - "c", |
1365 |
| - who_has={"a": [ws2]}, |
1366 |
| - nbytes={"a": 200}, |
1367 |
| - stimulus_id="s1", |
1368 |
| - ) |
1369 |
| - ) |
1370 |
| - assert ws.tasks["a"].state == "flight" |
1371 |
| - |
1372 |
| - |
1373 |
| -def test_throttle_incoming_transfers_on_count_limit(ws): |
1374 |
| - ws.transfer_incoming_count_limit = 1 |
1375 |
| - ws.transfer_incoming_bytes_limit = 100_000 |
1376 |
| - ws.transfer_incoming_bytes_throttle_threshold = 1 |
1377 |
| - ws2 = "127.0.0.1:2" |
1378 |
| - ws3 = "127.0.0.1:3" |
1379 |
| - who_has = {"a": [ws2], "b": [ws3]} |
1380 |
| - ws.handle_stimulus( |
1381 |
| - ComputeTaskEvent.dummy( |
1382 |
| - "c", |
1383 |
| - who_has=who_has, |
1384 |
| - nbytes={"a": 100, "b": 100}, |
1385 |
| - stimulus_id="s1", |
1386 |
| - ) |
1387 |
| - ) |
1388 |
| - tasks_by_state = defaultdict(list) |
1389 |
| - for ts in ws.tasks.values(): |
1390 |
| - tasks_by_state[ts.state].append(ts) |
1391 |
| - assert len(tasks_by_state["flight"]) == 1 |
1392 |
| - assert len(tasks_by_state["fetch"]) == 1 |
1393 |
| - assert ws.transfer_incoming_bytes == 100 |
1394 |
| - |
1395 |
| - in_flight_task = tasks_by_state["flight"][0] |
1396 |
| - ws.handle_stimulus( |
1397 |
| - GatherDepSuccessEvent( |
1398 |
| - worker=who_has[in_flight_task.key][0], |
1399 |
| - data={in_flight_task.key: 123}, |
1400 |
| - total_nbytes=100, |
1401 |
| - stimulus_id="s2", |
1402 |
| - ) |
1403 |
| - ) |
1404 |
| - assert tasks_by_state["flight"][0].state == "memory" |
1405 |
| - assert tasks_by_state["fetch"][0].state == "flight" |
1406 |
| - assert ws.transfer_incoming_bytes == 100 |
1407 |
| - |
1408 |
| - |
1409 |
| -def test_throttling_incoming_transfer_on_transfer_bytes_same_worker(ws): |
1410 |
| - ws.transfer_incoming_count_limit = 100 |
1411 |
| - ws.transfer_incoming_bytes_limit = 250 |
1412 |
| - ws.transfer_incoming_bytes_throttle_threshold = 1 |
1413 |
| - ws2 = "127.0.0.1:2" |
1414 |
| - ws.handle_stimulus( |
1415 |
| - ComputeTaskEvent.dummy( |
1416 |
| - "d", |
1417 |
| - who_has={"a": [ws2], "b": [ws2], "c": [ws2]}, |
1418 |
| - nbytes={"a": 100, "b": 100, "c": 100}, |
1419 |
| - stimulus_id="s1", |
1420 |
| - ) |
1421 |
| - ) |
1422 |
| - tasks_by_state = defaultdict(list) |
1423 |
| - for ts in ws.tasks.values(): |
1424 |
| - tasks_by_state[ts.state].append(ts) |
1425 |
| - assert ws.transfer_incoming_bytes == 200 |
1426 |
| - assert len(tasks_by_state["flight"]) == 2 |
1427 |
| - assert len(tasks_by_state["fetch"]) == 1 |
1428 |
| - |
1429 |
| - ws.handle_stimulus( |
1430 |
| - GatherDepSuccessEvent( |
1431 |
| - worker=ws2, |
1432 |
| - data={ts.key: 123 for ts in tasks_by_state["flight"]}, |
1433 |
| - total_nbytes=200, |
1434 |
| - stimulus_id="s2", |
1435 |
| - ) |
1436 |
| - ) |
1437 |
| - assert all(ts.state == "memory" for ts in tasks_by_state["flight"]) |
1438 |
| - assert all(ts.state == "flight" for ts in tasks_by_state["fetch"]) |
1439 |
| - |
1440 |
| - |
1441 |
| -def test_throttling_incoming_transfer_on_transfer_bytes_different_workers(ws): |
1442 |
| - ws.transfer_incoming_count_limit = 100 |
1443 |
| - ws.transfer_incoming_bytes_limit = 150 |
1444 |
| - ws.transfer_incoming_bytes_throttle_threshold = 1 |
1445 |
| - ws2 = "127.0.0.1:2" |
1446 |
| - ws3 = "127.0.0.1:3" |
1447 |
| - who_has = {"a": [ws2], "b": [ws3]} |
1448 |
| - ws.handle_stimulus( |
1449 |
| - ComputeTaskEvent.dummy( |
1450 |
| - "c", |
1451 |
| - who_has=who_has, |
1452 |
| - nbytes={"a": 100, "b": 100}, |
1453 |
| - stimulus_id="s1", |
1454 |
| - ) |
1455 |
| - ) |
1456 |
| - tasks_by_state = defaultdict(list) |
1457 |
| - for ts in ws.tasks.values(): |
1458 |
| - tasks_by_state[ts.state].append(ts) |
1459 |
| - assert ws.transfer_incoming_bytes == 100 |
1460 |
| - assert len(tasks_by_state["flight"]) == 1 |
1461 |
| - assert len(tasks_by_state["fetch"]) == 1 |
1462 |
| - |
1463 |
| - in_flight_task = tasks_by_state["flight"][0] |
1464 |
| - ws.handle_stimulus( |
1465 |
| - GatherDepSuccessEvent( |
1466 |
| - worker=who_has[in_flight_task.key][0], |
1467 |
| - data={in_flight_task.key: 123}, |
1468 |
| - total_nbytes=100, |
1469 |
| - stimulus_id="s2", |
1470 |
| - ) |
1471 |
| - ) |
1472 |
| - assert tasks_by_state["flight"][0].state == "memory" |
1473 |
| - assert tasks_by_state["fetch"][0].state == "flight" |
1474 |
| - |
1475 |
| - |
1476 |
| -def test_do_not_throttle_connections_while_below_threshold(ws): |
1477 |
| - ws.transfer_incoming_count_limit = 1 |
1478 |
| - ws.transfer_incoming_bytes_limit = 200 |
1479 |
| - ws.transfer_incoming_bytes_throttle_threshold = 50 |
1480 |
| - ws2 = "127.0.0.1:2" |
1481 |
| - ws3 = "127.0.0.1:3" |
1482 |
| - ws4 = "127.0.0.1:4" |
1483 |
| - ws.handle_stimulus( |
1484 |
| - ComputeTaskEvent.dummy( |
1485 |
| - "b", |
1486 |
| - who_has={"a": [ws2]}, |
1487 |
| - nbytes={"a": 1}, |
1488 |
| - stimulus_id="s1", |
1489 |
| - ) |
1490 |
| - ) |
1491 |
| - assert ws.tasks["a"].state == "flight" |
1492 |
| - |
1493 |
| - ws.handle_stimulus( |
1494 |
| - ComputeTaskEvent.dummy( |
1495 |
| - "d", |
1496 |
| - who_has={"c": [ws3]}, |
1497 |
| - nbytes={"c": 1}, |
1498 |
| - stimulus_id="s2", |
1499 |
| - ) |
1500 |
| - ) |
1501 |
| - assert ws.tasks["c"].state == "flight" |
1502 |
| - |
1503 |
| - ws.handle_stimulus( |
1504 |
| - ComputeTaskEvent.dummy( |
1505 |
| - "f", |
1506 |
| - who_has={"e": [ws4]}, |
1507 |
| - nbytes={"e": 100}, |
1508 |
| - stimulus_id="s3", |
1509 |
| - ) |
1510 |
| - ) |
1511 |
| - assert ws.tasks["e"].state == "flight" |
1512 |
| - assert ws.transfer_incoming_bytes == 102 |
1513 |
| - |
1514 |
| - |
1515 |
| -def test_throttle_on_transfer_bytes_regardless_of_threshold(ws): |
1516 |
| - ws.transfer_incoming_count_limit = 1 |
1517 |
| - ws.transfer_incoming_bytes_limit = 100 |
1518 |
| - ws.transfer_incoming_bytes_throttle_threshold = 50 |
1519 |
| - ws2 = "127.0.0.1:2" |
1520 |
| - ws3 = "127.0.0.1:3" |
1521 |
| - ws.handle_stimulus( |
1522 |
| - ComputeTaskEvent.dummy( |
1523 |
| - "b", |
1524 |
| - who_has={"a": [ws2]}, |
1525 |
| - nbytes={"a": 1}, |
1526 |
| - stimulus_id="s1", |
1527 |
| - ) |
1528 |
| - ) |
1529 |
| - assert ws.tasks["a"].state == "flight" |
1530 |
| - |
1531 |
| - ws.handle_stimulus( |
1532 |
| - ComputeTaskEvent.dummy( |
1533 |
| - "d", |
1534 |
| - who_has={"c": [ws3]}, |
1535 |
| - nbytes={"c": 100}, |
1536 |
| - stimulus_id="s2", |
1537 |
| - ) |
1538 |
| - ) |
1539 |
| - assert ws.tasks["c"].state == "fetch" |
1540 |
| - assert ws.transfer_incoming_bytes == 1 |
0 commit comments