Commit a1e8b6b
committed
typing: defer failed-application classification (perf)
Operator selection reported every rejected candidate through
EcUnify.classify_application, which peels the argument list one type at a
time, head-normalising via `ty_hnorm (ty_subst (Tuni.subst (UniEnv.assubst
ue)) _)` at each step. UniEnv.assubst is subst_of_uf, materialising the
whole unifier by folding over UF.domain (every univar in the unienv), so
each candidate cost O(arity * |unienv|) instead of the O(arity)
incremental union-find of the previous single unification.
Overload resolution rejects candidates constantly on the *success* path
(any application of an overloaded name tries and drops the non-matching
instances), so this classification ran pervasively even though the
diagnostics it produces are only ever consumed when an application fails
outright and an error is raised. On a large formosa-keccak module this
turned a ~8s require into ~54s.
Defer the classification:
- EcUnify: select_outcome's KO now carries a `... Lazy.t`. select_op
decides OK/KO with the cheap single `unify top texpected` and drops KO
without ever forcing it; select_op_failures forces the thunks and is
meant for the error path only. classify_application is unchanged.
- EcTyping.gen_select_op: the OK selection uses select_op; the failure
list becomes a lazy closure (program-variable failures, which cost one
unification, stay eager). tyerror_noop forces it only when building the
UnappliedOp / UnknownVarOrOp error.
Diagnostics are byte-identical (candidate order preserved). Keccak
require back to 8.4s; tests/op-application-errors.ec passes; unit
(84/84) and stdlib (128/128) green.1 parent e07ffa0 commit a1e8b6b
3 files changed
Lines changed: 82 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
381 | | - | |
382 | 380 | | |
383 | 381 | | |
384 | 382 | | |
| |||
417 | 415 | | |
418 | 416 | | |
419 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
420 | 422 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
| 423 | + | |
432 | 424 | | |
433 | 425 | | |
434 | 426 | | |
435 | 427 | | |
436 | 428 | | |
437 | 429 | | |
438 | | - | |
| 430 | + | |
439 | 431 | | |
440 | 432 | | |
441 | 433 | | |
442 | 434 | | |
443 | | - | |
| 435 | + | |
444 | 436 | | |
445 | 437 | | |
446 | 438 | | |
| |||
460 | 452 | | |
461 | 453 | | |
462 | 454 | | |
463 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
464 | 467 | | |
465 | 468 | | |
466 | 469 | | |
| |||
475 | 478 | | |
476 | 479 | | |
477 | 480 | | |
478 | | - | |
479 | | - | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
480 | 484 | | |
481 | | - | |
| 485 | + | |
482 | 486 | | |
483 | 487 | | |
484 | 488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
345 | | - | |
346 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
347 | 349 | | |
348 | 350 | | |
349 | 351 | | |
| |||
434 | 436 | | |
435 | 437 | | |
436 | 438 | | |
437 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
438 | 459 | | |
439 | 460 | | |
440 | 461 | | |
441 | 462 | | |
442 | 463 | | |
443 | 464 | | |
444 | 465 | | |
445 | | - | |
446 | | - | |
447 | | - | |
| 466 | + | |
448 | 467 | | |
449 | 468 | | |
450 | 469 | | |
| |||
453 | 472 | | |
454 | 473 | | |
455 | 474 | | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
| 475 | + | |
467 | 476 | | |
468 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
469 | 481 | | |
470 | | - | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
471 | 493 | | |
472 | 494 | | |
473 | 495 | | |
| |||
482 | 504 | | |
483 | 505 | | |
484 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 53 | | |
59 | 54 | | |
60 | 55 | | |
| |||
70 | 65 | | |
71 | 66 | | |
72 | 67 | | |
73 | | - | |
| 68 | + | |
| 69 | + | |
74 | 70 | | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
78 | 74 | | |
79 | 75 | | |
80 | 76 | | |
81 | | - | |
| 77 | + | |
0 commit comments