Merge pull request #4846 from urbit/la/hark-perf

This commit is contained in:
L 2021-05-04 10:03:07 -05:00 committed by GitHub
commit cf742789bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,15 +124,15 @@
:: ::
++ poke-noun ++ poke-noun
|= non=* |= non=*
?> ?=(%rewatch-dms non) [~ state]
=/ graphs=(list resource) :: ?> ?=(%rewatch-dms non)
~(tap in get-keys:gra) :: =/ graphs=(list resource)
:- ~ :: ~(tap in get-keys:gra)
%_ state :: %_ state
watching :: watching
%- ~(gas in watching) :: %- ~(gas in watching)
(murn graphs |=(rid=resource ?:((should-watch:ha rid) `[rid ~] ~))) :: (murn graphs |=(rid=resource ?:((should-watch:ha rid) `[rid ~] ~)))
== :: ==
:: ::
++ hark-graph-hook-action ++ hark-graph-hook-action
|= =action:hook |= =action:hook
@ -195,13 +195,15 @@
:: ::
?(%remove-graph %archive-graph) ?(%remove-graph %archive-graph)
(remove-graph resource.q.update) (remove-graph resource.q.update)
:: ::
%remove-posts %remove-posts
(remove-posts resource.q.update indices.q.update) (remove-posts resource.q.update indices.q.update)
:: ::
%add-nodes %add-nodes
=* rid resource.q.update =* rid resource.q.update
(check-nodes ~(val by nodes.q.update) rid) =/ assoc=(unit association:metadata)
(peek-association:met %graph rid)
(check-nodes ~(val by nodes.q.update) rid assoc)
== ==
:: this is awful, but notification kind should always switch :: this is awful, but notification kind should always switch
:: on the index, so hopefully doesn't matter :: on the index, so hopefully doesn't matter
@ -255,9 +257,11 @@
(get-graph-mop:gra rid) (get-graph-mop:gra rid)
=/ node=(unit node:graph-store) =/ node=(unit node:graph-store)
(bind (peek:orm:graph-store graph) |=([@ =node:graph-store] node)) (bind (peek:orm:graph-store graph) |=([@ =node:graph-store] node))
=/ assoc=(unit association:metadata)
(peek-association:met %graph rid)
=^ cards state =^ cards state
(check-nodes (drop node) rid) (check-nodes (drop node) rid assoc)
?. (should-watch:ha rid) ?. (should-watch:ha rid assoc)
[cards state] [cards state]
:_ state(watching (~(put in watching) [rid ~])) :_ state(watching (~(put in watching) [rid ~]))
(weld cards (give:ha ~[/updates] %listen [rid ~])) (weld cards (give:ha ~[/updates] %listen [rid ~]))
@ -265,20 +269,18 @@
++ check-nodes ++ check-nodes
|= $: nodes=(list node:graph-store) |= $: nodes=(list node:graph-store)
rid=resource rid=resource
assoc=(unit association:metadata)
== ==
=/ group=(unit resource) ?~ assoc
(peek-group:met %graph rid) ~& no-assoc+rid
?~ group
~& no-group+rid
`state `state
=/ metadatum=(unit metadatum:metadata) =* group group.u.assoc
(peek-metadatum:met %graph rid) =* metadatum metadatum.u.assoc
?~ metadatum `state
=/ module=term =/ module=term
?: ?=(%empty -.config.u.metadatum) %$ ?: ?=(%empty -.config.metadatum) %$
?: ?=(%group -.config.u.metadatum) %$ ?: ?=(%group -.config.metadatum) %$
module.config.u.metadatum module.config.metadatum
abet:check:(abed:handle-update:ha rid nodes u.group module) abet:check:(abed:handle-update:ha rid nodes group module)
-- --
:: ::
++ on-peek on-peek:def ++ on-peek on-peek:def
@ -340,12 +342,11 @@
$(contents t.contents) $(contents t.contents)
:: ::
++ should-watch ++ should-watch
|= rid=resource |= [rid=resource assoc=(unit association:metadata)]
^- ? ^- ?
=/ group-rid=(unit resource) ?~ assoc
(peek-group:met %graph rid) %.n
?~ group-rid %.n ?| !(is-managed:grp group.u.assoc)
?| !(is-managed:grp u.group-rid)
&(watch-on-self =(our.bowl entity.rid)) &(watch-on-self =(our.bowl entity.rid))
== ==
:: ::
@ -364,7 +365,9 @@
update-core(rid r, updates upds, group grp, module mod) update-core(rid r, updates upds, group grp, module mod)
:: ::
++ get-conversion ++ get-conversion
(^get-conversion rid) :: LA: this tube should be cached in %hark-graph-hook state
:: instead of just trying to keep it warm, as the scry overhead is large
~+ (^get-conversion rid)
:: ::
++ abet ++ abet
^- (quip card _state) ^- (quip card _state)
@ -418,7 +421,8 @@
update-core update-core
=* pos p.post.node =* pos p.post.node
=+ !< notif-kind=(unit notif-kind:hook) =+ !< notif-kind=(unit notif-kind:hook)
(get-conversion !>([0 pos])) %- get-conversion
!>(`indexed-post:graph-store`[0 pos])
?~ notif-kind ?~ notif-kind
update-core update-core
=/ desc=@t =/ desc=@t