Commit 31c030c
committed
perf(plugin): scan past tagless wire leaders when deriving the tag floor
deriveTagLoadFloor scopes both hot-path tag scans (tagger initFromDb + the
compartment trigger's token scans) to tag_number >= floor. It derived the floor
from the leading wire message ids via getMinMessageTagNumberForRawId, which
matches ONLY a message's :p/:file tags — never its tool tags (those key on the
callId). After a compaction marker the wire head is frequently a run of tagless
messages: the synthetic m[0]/m[1] leaders plus tool-only assistant turns. The
old logic capped at the first 8 ID-BEARING probes and took their MIN, so a
tagless head exhausted the budget on NULLs → Infinity → floor 0 → the full
~100k-tag scan the floor exists to avoid. Live-observed as an oscillating ~66ms
compartmentTrigger that flipped to ~6ms only on passes whose head happened to
start with a tagged message.
Fix: keep probing PAST NULL leaders until 8 resolve (bounded by 64 probes so a
fully-tagless head still falls back to floor 0 rather than scanning the wire),
and widen the safety margin by 64 per leader skipped before the first hit — a
skipped tool-only leader's tool tags sit just below the first :p tag we land on,
so the wider margin keeps them inside the floor. The floor still only ever errs
LOW (loads a few extra tags, never drops a live-wire tag), so the §N§ wire bytes
and the trigger decision stay identical. Adds a one-line "tag floor: 0
(full-scan fallback)" health log so the fallback can't hide as silent latency.1 parent aae1ab2 commit 31c030c
3 files changed
Lines changed: 93 additions & 15 deletions
File tree
- packages/plugin/src
- features/magic-context
- hooks/magic-context
Lines changed: 45 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
928 | 928 | | |
929 | 929 | | |
930 | 930 | | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
937 | 943 | | |
| 944 | + | |
938 | 945 | | |
939 | 946 | | |
940 | 947 | | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
946 | 966 | | |
947 | 967 | | |
948 | 968 | | |
949 | 969 | | |
950 | 970 | | |
951 | 971 | | |
952 | 972 | | |
953 | | - | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
954 | 976 | | |
955 | 977 | | |
| 978 | + | |
| 979 | + | |
956 | 980 | | |
957 | | - | |
958 | | - | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
959 | 987 | | |
960 | 988 | | |
961 | | - | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
962 | 992 | | |
963 | 993 | | |
964 | 994 | | |
| |||
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
217 | 254 | | |
218 | 255 | | |
219 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1063 | 1063 | | |
1064 | 1064 | | |
1065 | 1065 | | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
1066 | 1077 | | |
1067 | 1078 | | |
1068 | 1079 | | |
| |||
0 commit comments