Commit 2f1cd7c
committed
perf: Add MergeOrdered IR node with proper sim interleaving hooks
Addresses #2768
Replace the sliced!-based merge_ordered implementation with a dedicated
HydroNode::MergeOrdered IR node that has distinct codegen for production
and simulation.
Production codegen:
- Emits union() DFIR operator (both inputs pulled in same stratum)
Simulation codegen (two modes):
- Bounded/tick: MergeOrderedHook (inline) buffers both batches and
generates a valid interleaving via boolean coin flips, preserving
per-input order. Explores C(a+b, a) states instead of (a+b)!.
- Unbounded/top-level: TopLevelMergeOrderedHook releases one element
at a time from the front of either input queue, allowing feedback
cycles to deliver elements between releases.
API changes:
- Removed NoTick bound from merge_ordered — works on any Location and
Boundedness now. When bounded, the nondet is still explored in sim.
- State space reduced from 26 to 6 instances in the existing test
(2 elements per input: C(4,2) = 6 valid interleavings).
Tests added:
- sim_merge_ordered: ordering preservation assertion (invalid
interleavings like [2,1,3,4] are never produced)
- sim_merge_ordered_one_empty: pass-through when one input is empty
- sim_merge_ordered_cycle_back: feedback cycle where a cycled-back
element arrives before elements on the other input
- sim_merge_ordered_delayed: delayed element on one input
- deploy_merge_ordered_delayed: production localhost test with timing1 parent 5aa4324 commit 2f1cd7c
5 files changed
Lines changed: 793 additions & 19 deletions
File tree
- hydro_lang/src
- compile/ir
- live_collections/stream
- sim
- viz
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
442 | 453 | | |
443 | 454 | | |
444 | 455 | | |
| |||
596 | 607 | | |
597 | 608 | | |
598 | 609 | | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
599 | 632 | | |
600 | 633 | | |
601 | 634 | | |
| |||
2036 | 2069 | | |
2037 | 2070 | | |
2038 | 2071 | | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
2039 | 2078 | | |
2040 | 2079 | | |
2041 | 2080 | | |
| |||
2312 | 2351 | | |
2313 | 2352 | | |
2314 | 2353 | | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
2315 | 2359 | | |
2316 | 2360 | | |
2317 | 2361 | | |
| |||
2464 | 2508 | | |
2465 | 2509 | | |
2466 | 2510 | | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
2467 | 2520 | | |
2468 | 2521 | | |
2469 | 2522 | | |
| |||
3180 | 3233 | | |
3181 | 3234 | | |
3182 | 3235 | | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
| 3258 | + | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
3183 | 3265 | | |
3184 | 3266 | | |
3185 | 3267 | | |
| |||
4247 | 4329 | | |
4248 | 4330 | | |
4249 | 4331 | | |
| 4332 | + | |
4250 | 4333 | | |
4251 | 4334 | | |
4252 | 4335 | | |
| |||
4324 | 4407 | | |
4325 | 4408 | | |
4326 | 4409 | | |
| 4410 | + | |
4327 | 4411 | | |
4328 | 4412 | | |
4329 | 4413 | | |
| |||
4378 | 4462 | | |
4379 | 4463 | | |
4380 | 4464 | | |
| 4465 | + | |
4381 | 4466 | | |
4382 | 4467 | | |
4383 | 4468 | | |
| |||
4436 | 4521 | | |
4437 | 4522 | | |
4438 | 4523 | | |
| 4524 | + | |
| 4525 | + | |
| 4526 | + | |
4439 | 4527 | | |
4440 | 4528 | | |
4441 | 4529 | | |
| |||
4526 | 4614 | | |
4527 | 4615 | | |
4528 | 4616 | | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
4529 | 4624 | | |
4530 | 4625 | | |
4531 | 4626 | | |
| |||
0 commit comments