Commit 27bf280
authored
⚡️ Speed up function
The optimization achieves a 12% speedup by applying two key changes:
**1. Function Call Inlining (Primary Optimization)**
The main performance gain comes from inlining the `get_lineage_for_input_property` function logic directly into the main loop of `get_input_data_lineage_excluding_auto_batch_casting`. This eliminates ~2,342 function calls (as shown in the profiler), reducing the overhead from 79.6% to 31.6% of total time spent in the `identify_lineage` call.
The inlined logic checks `input_definition.is_compound_input()` directly in the loop and handles both compound and simple inputs inline, avoiding the function call overhead entirely for the common case of simple batch-oriented inputs.
**2. Dictionary Implementation Change**
In `verify_lineages`, replaced `defaultdict(list)` with a plain dictionary using explicit key existence checks. This reduces the overhead of defaultdict's factory function calls and provides more predictable performance characteristics, especially beneficial when processing large numbers of lineages.
**Performance Impact by Test Type:**
- **Large-scale tests** (500+ properties): ~17-18% improvement due to reduced per-iteration overhead
- **Basic tests** (few properties): ~14-22% improvement from eliminating function call overhead
- **Compound inputs**: ~7-20% improvement, with better gains for simpler compound structures
- **Edge cases** (empty/scalar): Minimal impact as expected, since less computation occurs
The optimization maintains identical behavior and error handling while significantly reducing the computational overhead in the hot path where most properties are processed.get_input_data_lineage_excluding_auto_batch_casting by 13% in PR #1504 (feature/try-to-beat-the-limitation-of-ee-in-terms-of-singular-elements-pushed-into-batch-inputs)1 parent 9e7765a commit 27bf280
File tree
1 file changed
+23
-9
lines changed- inference/core/workflows/execution_engine/v1/compiler
1 file changed
+23
-9
lines changedLines changed: 23 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1633 | 1633 | | |
1634 | 1634 | | |
1635 | 1635 | | |
1636 | | - | |
1637 | | - | |
1638 | | - | |
1639 | | - | |
1640 | | - | |
1641 | | - | |
1642 | | - | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
1643 | 1653 | | |
1644 | 1654 | | |
1645 | 1655 | | |
| |||
1729 | 1739 | | |
1730 | 1740 | | |
1731 | 1741 | | |
1732 | | - | |
| 1742 | + | |
1733 | 1743 | | |
1734 | | - | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
1735 | 1749 | | |
1736 | 1750 | | |
1737 | 1751 | | |
| |||
0 commit comments