Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c6dda1e authored by Steve Elliott's avatar Steve Elliott
Browse files

[kairos] Optimize depth tracking

Flag: EXEMPT unused
Test: atest kairos-tests
Change-Id: I156022f5d877da49a98b76f574c386f798c0cdae
parent 0822d034
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -281,7 +281,6 @@ internal class DepthTracker {
                            },
                    )
                }
                downstreamSet.clear()
            }
        }
        reset()
+18 −9
Original line number Diff line number Diff line
@@ -145,7 +145,14 @@ internal class MuxDeferredNode<W, K, V>(
                val conn = branchNode.upstream
                severed.add(conn)
                conn.removeDownstream(downstream = branchNode.schedulable)
                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)
                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
+16 −2
Original line number Diff line number Diff line
@@ -109,7 +109,14 @@ internal class MuxPromptNode<W, K, V>(
                val conn: NodeConnection<V> = branchNode.upstream
                severed.add(conn)
                conn.removeDownstream(downstream = branchNode.schedulable)
                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)
                if (conn.depthTracker.snapshotIsDirect) {
                    depthTracker.removeDirectUpstream(conn.depthTracker.snapshotDirectDepth)
                } else {
                    depthTracker.removeIndirectUpstream(conn.depthTracker.snapshotIndirectDepth)
                    depthTracker.updateIndirectRoots(
                        removals = conn.depthTracker.snapshotIndirectRoots
                    )
                }
            }

            // add new