diff options
author | 2025-02-22 14:55:55 -0500 | |
---|---|---|
committer | 2025-03-11 18:50:51 -0400 | |
commit | 1c6dda1eb6db3cb40495a581a67409a969e8af6a (patch) | |
tree | 42ecdc85fd1330d05174e7b405e8fb94619f8b29 | |
parent | 0822d0345d28fbe95c41b81b632bc4c70e1a4c4e (diff) |
[kairos] Optimize depth tracking
Flag: EXEMPT unused
Test: atest kairos-tests
Change-Id: I156022f5d877da49a98b76f574c386f798c0cdae
3 files changed, 34 insertions, 12 deletions
diff --git a/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Graph.kt b/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Graph.kt index b956e44e0618..90a92712bf81 100644 --- a/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Graph.kt +++ b/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/Graph.kt @@ -281,7 +281,6 @@ internal class DepthTracker { }, ) } - downstreamSet.clear() } } reset() diff --git a/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxDeferred.kt b/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxDeferred.kt index c11eb122597d..81f37022a868 100644 --- a/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxDeferred.kt +++ b/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxDeferred.kt @@ -145,7 +145,14 @@ internal class MuxDeferredNode<W, K, V>( val conn = branchNode.upstream severed.add(conn) conn.removeDownstream(downstream = branchNode.schedulable) - depthTracker.removeDirectUpstream(conn.depthTracker.snapshotDirectDepth) + if (conn.depthTracker.snapshotIsDirect) { + depthTracker.removeDirectUpstream(conn.depthTracker.snapshotDirectDepth) + } else { + depthTracker.removeIndirectUpstream(conn.depthTracker.snapshotIndirectDepth) + depthTracker.updateIndirectRoots( + removals = conn.depthTracker.snapshotIndirectRoots + ) + } } } @@ -156,7 +163,14 @@ internal class MuxDeferredNode<W, K, V>( val conn = branchNode.upstream severed.add(conn) conn.removeDownstream(downstream = branchNode.schedulable) - depthTracker.removeDirectUpstream(conn.depthTracker.snapshotDirectDepth) + if (conn.depthTracker.snapshotIsDirect) { + depthTracker.removeDirectUpstream(conn.depthTracker.snapshotDirectDepth) + } else { + depthTracker.removeIndirectUpstream(conn.depthTracker.snapshotIndirectDepth) + depthTracker.updateIndirectRoots( + removals = conn.depthTracker.snapshotIndirectRoots + ) + } } // add new @@ -343,13 +357,8 @@ private class MuxDeferredActivator<W, K, V>( val (patchesConn, needsEval) = getPatches(evalScope).activate(evalScope, downstream = muxNode.schedulable) ?: run { - // Turns out we can't connect to patches, so update our depth and - // propagate - if (muxNode.depthTracker.setIsIndirectRoot(false)) { - // TODO: schedules might not be necessary now that we're not - // parallel? - muxNode.depthTracker.schedule(evalScope.scheduler, muxNode) - } + // Turns out we can't connect to patches, so update our depth + muxNode.depthTracker.setIsIndirectRoot(false) return } muxNode.patches = patchesConn diff --git a/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxPrompt.kt b/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxPrompt.kt index cb2c6e51df66..faef6a21d4f3 100644 --- a/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxPrompt.kt +++ b/packages/SystemUI/utils/kairos/src/com/android/systemui/kairos/internal/MuxPrompt.kt @@ -109,7 +109,14 @@ internal class MuxPromptNode<W, K, V>( val conn: NodeConnection<V> = branchNode.upstream severed.add(conn) conn.removeDownstream(downstream = branchNode.schedulable) - depthTracker.removeDirectUpstream(conn.depthTracker.snapshotDirectDepth) + if (conn.depthTracker.snapshotIsDirect) { + depthTracker.removeDirectUpstream(conn.depthTracker.snapshotDirectDepth) + } else { + depthTracker.removeIndirectUpstream(conn.depthTracker.snapshotIndirectDepth) + depthTracker.updateIndirectRoots( + removals = conn.depthTracker.snapshotIndirectRoots + ) + } } } @@ -123,7 +130,14 @@ internal class MuxPromptNode<W, K, V>( val conn: NodeConnection<V> = oldBranch.upstream severed.add(conn) conn.removeDownstream(downstream = oldBranch.schedulable) - depthTracker.removeDirectUpstream(conn.depthTracker.snapshotDirectDepth) + if (conn.depthTracker.snapshotIsDirect) { + depthTracker.removeDirectUpstream(conn.depthTracker.snapshotDirectDepth) + } else { + depthTracker.removeIndirectUpstream(conn.depthTracker.snapshotIndirectDepth) + depthTracker.updateIndirectRoots( + removals = conn.depthTracker.snapshotIndirectRoots + ) + } } // add new |