Repository navigation
Commit a2e0cd7
committed
Try a cheap bounded walk before the full occur checks
Why:
Every variable link in unification runs `occur`, and the Tvar/Tconstr
cases also run `deep_occur`. `occur` builds an AVL set of visited
nodes along every path and `deep_occur` marks every node and walks the
type again to unmark it, although almost all of these walks see a
handful of nodes. On a 552 module React app they make 943k and 494k
calls, about 0.5 s of 14 s single domain CPU.
Both checks now first walk the type with no visited set and no marks,
giving up after 256 nodes (which also stops cycles and heavy sharing);
when the walk gives up, the unchanged full walk runs.
- `occur` in expression mode: a walk over the edges `occur_rec` follows
that finishes without meeting the variable proves `occur_rec` would
neither raise nor expand anything. Pattern mode, which looks types up,
always runs the full walk.
- `deep_occur`: the walk only answers "absent". It gives up on meeting
the variable and on a node an enclosing walk already marked, so the
marks left behind are the same as the full walk's.
Review: Can an answer, a diagnostic or an artifact change? No: each fast
walk either proves the full walk would do nothing more than it did, or
gives up and the full walk runs from scratch. The new fixtures pin the
errors, including one past the budget, and the corpus (5,398 artifacts
and 1,147 .cmt/.cmti) is byte identical to master.
Signed-off-by: Jono Prest <jjprest@gmail.com>1 parent d47adb3 commit a2e0cd7
8 files changed
Lines changed: 1026 additions & 3 deletions
File tree
- changes
- compiler/ml
- tests/build_tests/super_errors
- expected
- fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1392 | 1392 | | |
1393 | 1393 | | |
1394 | 1394 | | |
| 1395 | + | |
1395 | 1396 | | |
1396 | 1397 | | |
1397 | 1398 | | |
| |||
1425 | 1426 | | |
1426 | 1427 | | |
1427 | 1428 | | |
1428 | | - | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
1429 | 1461 | | |
1430 | 1462 | | |
1431 | 1463 | | |
| |||
1444 | 1476 | | |
1445 | 1477 | | |
1446 | 1478 | | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
1447 | 1485 | | |
1448 | 1486 | | |
1449 | 1487 | | |
| |||
1669 | 1707 | | |
1670 | 1708 | | |
1671 | 1709 | | |
1672 | | - | |
1673 | | - | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
1674 | 1730 | | |
1675 | 1731 | | |
1676 | 1732 | | |
| |||
1686 | 1742 | | |
1687 | 1743 | | |
1688 | 1744 | | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
1689 | 1749 | | |
1690 | 1750 | | |
1691 | 1751 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments