Commit 7bb6031
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, for the
error path only. classify_application is unchanged.
- EcTyping.gen_select_op: the OK selection uses select_op; the failure
list is a lazy closure forced only by tyerror_noop when building the
UnappliedOp / UnknownVarOrOp error. select_pv likewise decides with a
single unification and defers its own failure classification.
Diagnostics are byte-identical (candidate order preserved). Keccak
require back to baseline; tests/op-application-errors.ec passes; unit
(84/84) and stdlib (128/128) green.1 parent e07ffa0 commit 7bb6031
3 files changed
Lines changed: 85 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
327 | | - | |
328 | | - | |
| 327 | + | |
| 328 | + | |
329 | 329 | | |
330 | | - | |
| 330 | + | |
331 | 331 | | |
332 | | - | |
| 332 | + | |
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
343 | 349 | | |
344 | 350 | | |
345 | 351 | | |
| |||
374 | 380 | | |
375 | 381 | | |
376 | 382 | | |
377 | | - | |
| 383 | + | |
378 | 384 | | |
379 | 385 | | |
380 | | - | |
381 | | - | |
382 | 386 | | |
383 | 387 | | |
384 | 388 | | |
| |||
417 | 421 | | |
418 | 422 | | |
419 | 423 | | |
| 424 | + | |
| 425 | + | |
420 | 426 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
| 427 | + | |
432 | 428 | | |
433 | 429 | | |
434 | 430 | | |
435 | 431 | | |
436 | 432 | | |
437 | 433 | | |
438 | | - | |
| 434 | + | |
439 | 435 | | |
440 | | - | |
| 436 | + | |
441 | 437 | | |
442 | 438 | | |
443 | | - | |
| 439 | + | |
444 | 440 | | |
445 | 441 | | |
446 | 442 | | |
| |||
460 | 456 | | |
461 | 457 | | |
462 | 458 | | |
463 | | - | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
464 | 468 | | |
465 | 469 | | |
466 | 470 | | |
| |||
475 | 479 | | |
476 | 480 | | |
477 | 481 | | |
478 | | - | |
479 | | - | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
480 | 485 | | |
481 | | - | |
| 486 | + | |
482 | 487 | | |
483 | 488 | | |
484 | 489 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
345 | | - | |
| 345 | + | |
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
437 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
438 | 454 | | |
439 | 455 | | |
440 | 456 | | |
441 | 457 | | |
442 | 458 | | |
443 | 459 | | |
444 | 460 | | |
445 | | - | |
446 | | - | |
447 | | - | |
| 461 | + | |
448 | 462 | | |
449 | 463 | | |
450 | 464 | | |
| |||
453 | 467 | | |
454 | 468 | | |
455 | 469 | | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
| 470 | + | |
467 | 471 | | |
468 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
469 | 476 | | |
470 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
471 | 488 | | |
472 | 489 | | |
473 | 490 | | |
| |||
482 | 499 | | |
483 | 500 | | |
484 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 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 | + | |
74 | 69 | | |
75 | 70 | | |
76 | 71 | | |
77 | 72 | | |
78 | 73 | | |
79 | 74 | | |
80 | 75 | | |
81 | | - | |
| 76 | + | |
0 commit comments