Skip to content

Commit 7d592d4

Browse files
committed
Merge remote-tracking branch 'origin/fast/integration' into client-rel/cache-whole
2 parents 6a8ceb3 + 4e0b0e0 commit 7d592d4

15 files changed

Lines changed: 648 additions & 98 deletions

‎.github/workflows/release-bootstrap.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ jobs:
171171
[ -n "$WINRT_URL" ] && [ -n "$WINRT_SHA" ] || { echo "windows-x64 needs windows_runtime_url and windows_runtime_sha256"; exit 1; }
172172
curl -fsSL "$WINRT_URL" -o "$RUNNER_TEMP/winrt.tar.gz"
173173
echo "$WINRT_SHA $RUNNER_TEMP/winrt.tar.gz" | sha256sum -c -
174-
mkdir -p "$RUNNER_TEMP/winrt" && tar -xzf "$RUNNER_TEMP/winrt.tar.gz" -C "$RUNNER_TEMP/winrt"
174+
# (Git Bash tar takes "D:..." for a remote host: work relative to the folder)
175+
mkdir -p "$RUNNER_TEMP/winrt" && (cd "$RUNNER_TEMP" && tar -xzf winrt.tar.gz -C winrt)
175176
set -- --windows-runtime "$RUNNER_TEMP/winrt"
176177
fi
177178
"$py" build/bootstrap-tools/scripts/service-runtime.py "$@" --source-root "$GITHUB_WORKSPACE" --build "$GITHUB_WORKSPACE/build/bootstrap-js" --producer "$GITHUB_WORKSPACE/build/bootstrap-tools/scripts/service-release.py" --producer-sha256 e8b52fb537d587c2946c9e893e193a7e967fe9ebe0088390dd7b8eec15656058 --out "$GITHUB_WORKSPACE/build/bootstrap-service"

‎LAWS.bend‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11549,3 +11549,29 @@ law far_fact_shared:
1154911549
law far_fact_private:
1155011550
{FR.Fr.fact(FR.Fr.feed.demo.st(), M.SettingSet{"k", "v", 9n}, 8n) == Nil{} : List<&2, FR.Fact>}
1155111551
# ---- end F1 feed ----
11552+
11553+
# --- fast hub R1: per-frame reads that do not grow with the log (locks_idle_*) ---
11554+
# a lock never set, and a lock released, are idle (M.Locks.idle: read from
11555+
# the setting's text, not parsed)
11556+
law locks_idle_never_set:
11557+
{M.Locks.idle(M.State.empty(), "bend") == True{} : Bool}
11558+
11559+
law locks_idle_released:
11560+
{M.Locks.idle(M.State.replay([M.LockChanged{"bend", LCK.Lock.empty(), 1n}], M.State.empty()), "bend") == True{} : Bool}
11561+
11562+
# a lock that is held is not idle
11563+
law locks_idle_held_not:
11564+
{M.Locks.idle(M.State.replay([M.LockChanged{"bend", LCK.Lock.promote([LCK.LockParty{"t1", "thread", "t1", "", 1n, 0n}]), 1n}], M.State.empty()), "bend") == False{} : Bool}
11565+
11566+
# what Locks.after skips: an idle lock that the step does not touch answers
11567+
# Step.none() from Locks.after.one
11568+
law locks_after_idle_none:
11569+
{H.Locks.after.one(M.State.replay([M.LockChanged{"bend", LCK.Lock.empty(), 1n}], M.State.empty()), M.State.replay([M.LockChanged{"bend", LCK.Lock.empty(), 1n}], M.State.empty()), 5n, "bend") == H.Step.none() : H.Step}
11570+
# --- J2: the sign-in wait asked again only when the log moved ---
11571+
# (Hub.auth.beat: a settings lookup per thread at every beat was most of an
11572+
# idle JS hub's CPU)
11573+
law auth_beat_kept:
11574+
{MPCREDIT.Auth.kept("1 1", M.State.empty()) == True{} : Bool}
11575+
11576+
law auth_beat_asked:
11577+
{MPCREDIT.Auth.kept("7 1", M.State.empty()) == False{} : Bool}

‎PROOF.bend‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12185,12 +12185,12 @@ def Laws.mail_global_primary(): {==}
1218512185

1218612186
def Laws.mail_log_count_set(c, n):
1218712187
match c:
12188-
case MPCREDIT.Cfg{home, web, host, port, prompt, dirs, version, MPCREDIT.Net{tailnet, https, token, models, mtext, rt, br, pk, tm, machines, pv, MPLOG.Bn{dir, seen, work, far, live, broken, fl, tools, tch, cef, wire_n, pair}, managed, link, freecad, ks}, telemetry, views}:
12188+
case MPCREDIT.Cfg{home, web, host, port, prompt, dirs, version, MPCREDIT.Net{tailnet, https, token, models, mtext, rt, br, pk, tm, machines, pv, MPLOG.Bn{dir, seen, work, far, live, broken, fl, tools, tch, cef, wire_n, pair, auth}, managed, link, freecad, ks}, telemetry, views}:
1218912189
{==}
1219012190

1219112191
def Laws.mail_log_count_committed(c, fresh):
1219212192
match c:
12193-
case MPCREDIT.Cfg{home, web, host, port, prompt, dirs, version, MPCREDIT.Net{tailnet, https, token, models, mtext, rt, br, pk, tm, machines, pv, MPLOG.Bn{dir, seen, work, far, live, broken, fl, tools, tch, cef, wire_n, pair}, managed, link, freecad, ks}, telemetry, views}:
12193+
case MPCREDIT.Cfg{home, web, host, port, prompt, dirs, version, MPCREDIT.Net{tailnet, https, token, models, mtext, rt, br, pk, tm, machines, pv, MPLOG.Bn{dir, seen, work, far, live, broken, fl, tools, tch, cef, wire_n, pair, auth}, managed, link, freecad, ks}, telemetry, views}:
1219412194
{==}
1219512195

1219612196
# ---- native phone i18n ----
@@ -12770,3 +12770,11 @@ def Laws.far_feed_sliced_big(): {==}
1277012770
def Laws.far_fact_shared(): {==}
1277112771
def Laws.far_fact_private(): {==}
1277212772
# ---- end F1 feed ----
12773+
def Laws.locks_idle_never_set(): {==}
12774+
def Laws.locks_idle_released(): {==}
12775+
def Laws.locks_idle_held_not(): {==}
12776+
def Laws.locks_after_idle_none(): {==}
12777+
12778+
# --- J2: the sign-in wait asked again only when the log moved ---
12779+
def Laws.auth_beat_kept(): {==}
12780+
def Laws.auth_beat_asked(): {==}

‎src/core/hub.bend‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5481,12 +5481,35 @@ def Locks.after.one(+before: M.State, +s: M.State, +now: Nat, +name: String) ->
54815481
Step.cat(Step.cat(Step{cs, Bool.pick(List<&2, Out>, changed, [LockGuard{name, LK.Lock.owner(old), LK.Lock.owner(l)}], Nil{})}, Locks.wait.go(LK.Lock.waiters(l), s1, now, name, 1n, Step.none())),
54825482
Locks.grant(Bool.and(LK.Lock.ready(l), Bool.and(Bool.not(changed), Bool.not(LK.Lock.ready(old)))), LK.Lock.holder(l), s1, now, name))
54835483

5484+
# a step's changes hold a LockChanged of this lock (the only change that
5485+
# writes a lock's setting, M.Locks.fold)
5486+
def Locks.touched(cs: List<&2, M.Change>, +name: String, hit: Bool) -> Bool:
5487+
match cs hit:
5488+
case _ True{}:
5489+
True{}
5490+
case Nil{} False{}:
5491+
False{}
5492+
case M.LockChanged{n, _, _} <> t False{}:
5493+
Locks.touched(t, name, String.eq(n, name))
5494+
case _ <> t False{}:
5495+
Locks.touched(t, name, False{})
5496+
5497+
# a lock idle before the step and not changed by it can neither expire,
5498+
# promote nor grant: Locks.after.one answers Step.none() for it (law
5499+
# locks_after_idle_none), so it is not read
5500+
def Locks.after.skip(+idle: Bool, +before: M.State, +now: Nat, +name: String, +st: Step) -> Step:
5501+
match idle:
5502+
case True{}:
5503+
st
5504+
case False{}:
5505+
Step.cat(st, Locks.after.one(before, M.State.replay(Queue.changes(st), before), now, name))
5506+
54845507
def Locks.after.go(names: List<&2, String>, +before: M.State, +now: Nat, +st: Step) -> Step:
54855508
match names:
54865509
case Nil{}:
54875510
st
5488-
case name <> t:
5489-
Locks.after.go(t, before, now, Step.cat(st, Locks.after.one(before, M.State.replay(Queue.changes(st), before), now, name)))
5511+
case +name <> t:
5512+
Locks.after.go(t, before, now, Locks.after.skip(Bool.and(M.Locks.idle(before, name), Bool.not(Locks.touched(Queue.changes(st), name, False{}))), before, now, name, st))
54905513

54915514
def Locks.after(+s: M.State, +now: Nat, +st: Step) -> Step:
54925515
Locks.after.go(M.Locks.names(M.State.replay(Queue.changes(st), s)), s, now, st)

‎src/core/model.bend‎

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,52 @@ def Setting.keys(s: State) -> List<&2, String>:
12841284
case State{_, _, _, _, _, sg, _, _, _, _, _}:
12851285
Map.keys(&2, String, sg)
12861286

1287+
# The keys of a String map that start with pre, without walking the others.
1288+
# Base's Map is a crit-bit trie (Map.bit: char ci of a key takes bits
1289+
# 33·ci .. 33·ci+32), so every key under a node at bit p agrees on its first
1290+
# p/33 chars: once p ≥ 33·|pre|, any one of them says whether all start
1291+
# with pre. Order: as Map.keys.
1292+
def Pfx.first(m: Map<&2, String>) -> String:
1293+
match m:
1294+
case MTip{}:
1295+
""
1296+
case MLeaf{k, _}:
1297+
k
1298+
case MNode{_, MTip{}, hi}:
1299+
Pfx.first(hi)
1300+
case MNode{_, lo, _}:
1301+
Pfx.first(lo)
1302+
1303+
# whether some key under m may start with pre (bits: 33·|pre|)
1304+
def Pfx.may(+m: Map<&2, String>, +pre: String, +bits: Nat) -> Bool:
1305+
match m:
1306+
case MTip{}:
1307+
False{}
1308+
case MLeaf{k, _}:
1309+
String.starts_with(k, pre)
1310+
case MNode{p, _, _}:
1311+
Bool.or(Nat.is_lt(p, bits), String.starts_with(Pfx.first(m), pre))
1312+
1313+
def Pfx.go(m: Map<&2, String>, may: Bool, +pre: String, +bits: Nat, acc: List<&2, String>) -> List<&2, String>:
1314+
match m may:
1315+
case _ False{}:
1316+
acc
1317+
case MTip{} True{}:
1318+
acc
1319+
case MLeaf{k, _} True{}:
1320+
k <> acc
1321+
case MNode{_, +lo, +hi} True{}:
1322+
Pfx.go(lo, Pfx.may(lo, pre, bits), pre, bits, Pfx.go(hi, Pfx.may(hi, pre, bits), pre, bits, acc))
1323+
1324+
def Pfx.keys(+m: Map<&2, String>, +pre: String) -> List<&2, String>:
1325+
Pfx.go(m, Pfx.may(m, pre, Nat.mul(33n, String.length(pre))), pre, Nat.mul(33n, String.length(pre)), Nil{})
1326+
1327+
# the settings' keys that start with pre
1328+
def Setting.keys.pre(s: State, +pre: String) -> List<&2, String>:
1329+
match s:
1330+
case State{_, _, _, _, _, sg, _, _, _, _, _}:
1331+
Pfx.keys(sg, pre)
1332+
12871333
# The "restart.continue" setting: after a restart, a turn the restart cut
12881334
# short goes on by itself (on unless "off"; hub.bend's Carry)
12891335
def Carry.on(+s: State) -> Bool:
@@ -1652,6 +1698,20 @@ def Locks.names(s: State) -> List<&2, String>:
16521698
def Locks.get(s: State, +name: String) -> LK.NamedLock:
16531699
LK.Lock.read(Maybe.default(&2, J.Json, J.Json.parse(Setting.get(s, "lock." ++ name, "")), J.Null{}))
16541700

1701+
# the lock is free with no one waiting (never held, or released): what
1702+
# Locks.get reads as LK.Lock.empty(), told from its setting's text without
1703+
# parsing it. A real log keeps every lock name ever used (72), nearly all
1704+
# idle, and every step and every sidebar row read each one (laws
1705+
# locks_idle_*).
1706+
def Locks.idle.text() -> String:
1707+
J.Json.show(LK.Lock.json(LK.Lock.empty()))
1708+
1709+
def Locks.idle.k(+t: String) -> Bool:
1710+
Bool.or(String.is_empty(t), String.eq(t, Locks.idle.text()))
1711+
1712+
def Locks.idle(s: State, +name: String) -> Bool:
1713+
Locks.idle.k(Setting.get(s, "lock." ++ name, ""))
1714+
16551715
# deploy_main's state, one JSON line (core/ship.bend)
16561716
def Ship.fold.asked(+s: State, +by: String, +cover: String) -> State:
16571717
State.setting(s, "deploy.ship", SH.Ship.show(SH.Ship.asked(SH.Ship.read(Setting.get(s, "deploy.ship", "")), by, cover)))
@@ -3131,9 +3191,24 @@ def Work.rows.go(ks: List<&2, String>, +s: State, m: Map<&2, Nat>) -> Map<&2, Na
31313191
case +k <> t:
31323192
Work.rows.go(t, s, Work.rows.put(s, Work.rows.id(k, "bg."), Work.rows.put(s, Work.rows.id(k, "watch."), m)))
31333193

3134-
def Work.rows.map(+s: State) -> Map<&2, Nat>:
3194+
# every thread's rows by walking every setting (the specification of
3195+
# Work.rows.map; test/work_rows_test.bend holds them equal)
3196+
def Work.rows.map.all(+s: State) -> Map<&2, Nat>:
31353197
Work.rows.go(Setting.keys(s), s, Map.new(&2, Nat))
31363198

3199+
def Work.rows.ids(ks: List<&2, String>, +n: Nat, +s: State, m: Map<&2, Nat>) -> Map<&2, Nat>:
3200+
match ks:
3201+
case Nil{}:
3202+
m
3203+
case +k <> t:
3204+
Work.rows.ids(t, n, s, Work.rows.put(s, String.drop(k, n), m))
3205+
3206+
# Work.rows.map.all reading only the settings named "bg.*" and "watch.*"
3207+
# (Pfx.keys): the sidebar asks it every frame, and walking every setting
3208+
# (10k+ on a real log, each key sliced twice) grew each frame with history
3209+
def Work.rows.map(+s: State) -> Map<&2, Nat>:
3210+
Work.rows.ids(Setting.keys.pre(s, "watch."), 6n, s, Work.rows.ids(Setting.keys.pre(s, "bg."), 3n, s, Map.new(&2, Nat)))
3211+
31373212
def Work.kids.at.k(r: Map<&2, Nat> & Nat) -> Nat:
31383213
(_, n) = r
31393214
n

‎src/core/subs.bend‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,30 @@ def Subs.lock.row(+name: String, +l: LK.NamedLock, +th: String) -> SubRow:
531531
+held = String.eq(LK.Lock.owner(l), th)
532532
SubRow{name, True{}, "lock: " ++ name, "lock", Bool.pick(String, held, "held", "waiting"), Bool.pick(String, held, "Release when done", "position " ++ Nat.show(LK.Lock.position(l, th)) ++ " · held by " ++ LK.Lock.owner(l)), True{}, False{}, 0n, Nil{}}
533533

534+
def Subs.lock.has(+has: Bool, +name: String, +l: LK.NamedLock, +th: String) -> List<&2, SubRow>:
535+
match has:
536+
case True{}:
537+
[Subs.lock.row(name, l, th)]
538+
case False{}:
539+
Nil{}
540+
541+
def Subs.lock.of(+name: String, +l: LK.NamedLock, +th: String) -> List<&2, SubRow>:
542+
Subs.lock.has(LK.Lock.has(l, th), name, l, th)
543+
544+
# an idle lock (M.Locks.idle) has no holder or waiter, so no thread's row
545+
def Subs.lock.if(+idle: Bool, +st: M.State, +name: String, +th: String) -> List<&2, SubRow>:
546+
match idle:
547+
case True{}:
548+
Nil{}
549+
case False{}:
550+
Subs.lock.of(name, M.Locks.get(st, name), th)
551+
534552
def Subs.locks.go(names: List<&2, String>, +st: M.State, +th: String) -> List<&2, SubRow>:
535553
match names:
536554
case Nil{}:
537555
Nil{}
538556
case +name <> t:
539-
List.append(&2, SubRow, Bool.pick(List<&2, SubRow>, LK.Lock.has(M.Locks.get(st, name), th), [Subs.lock.row(name, M.Locks.get(st, name), th)], Nil{}), Subs.locks.go(t, st, th))
557+
List.append(&2, SubRow, Subs.lock.if(M.Locks.idle(st, name), st, name, th), Subs.locks.go(t, st, th))
540558

541559
# Successful/stopped finishes fold away; failures remain visible as attention.
542560
def Subs.finished(+word: String) -> Bool:

0 commit comments

Comments
 (0)