spider: add profiling hints so we can see how slow it is
/- spider
/+ libstrand=strand, default-agent, verb, server
=, strand=strand:libstrand
+~% %spider-top ..part ~
|%
+$ card card:agent:gall
+$ thread thread:spider
::
:: Trie operations
::
+~% %spider ..card ~
|%
++ get-yarn
|= [=trie =yarn]
=| =state
=<
%+ verb |
+ ~% %spider-agent ..bind-eyre ~
|_ =bowl:gall
+* this .
spider-core +>
--
::
++ on-poke
+ ~/ %on-poke
|= [=mark =vase]
^- (quip card _this)
?: ?=(%spider-kill mark)
[cards this]
::
++ on-watch
+ ~/ %on-watch
|= =path
^- (quip card _this)
=^ cards state
::
++ on-leave on-leave:def
++ on-peek
+ ~/ %on-peek
|= =path
^- (unit (unit cage))
?+ path (on-peek:def path)
==
::
++ on-agent
+ ~/ %on-agent
|= [=wire =sign:agent:gall]
^- (quip card _this)
=^ cards state
[cards this]
::
++ on-arvo
+ ~/ %on-arvo
|= [=wire =sign-arvo]
^- (quip card _this)
=^ cards state
(on-load on-save)
--
::
+~% %spider-helper ..get-yarn ~
|_ =bowl:gall
::
++ bind-eyre
:((cury cat 3) file '--' (scot %uv (sham eny.bowl)))
::
++ handle-http-request
+ ~/ %handle-http-request
|= [eyre-id=@ta =inbound-request:eyre]
^- (quip card _state)
?> authenticated.inbound-request
=/ =tid (new-thread-id thread)
=. serving.state
(~(put by serving.state) tid [eyre-id output-mark])
+ :: TODO: speed this up somehow. we spend about 15ms in this arm alone
+ ::
=+ .^
=tube:clay
%cc
`state
::
++ handle-sign
+ ~/ %handle-sign
|= [=tid =wire =sign-arvo]
=/ yarn (~(get by tid.state) tid)
?~ yarn
(take-input u.yarn ~ %agent wire sign)
::
++ handle-start-thread
+ ~/ %handle-start-thread
|= [parent-tid=(unit tid) use=(unit tid) file=term =vase]
^- (quip card ^state)
=/ parent-yarn=yarn
=/ pax=path
~| no-file-for-thread+file
(need (get-fit:clay [our q.byk da+now]:bowl %ted file))
- =/ =card
+ :_ state
+ :_ ~
:+ %pass /build/[new-tid]
[%arvo %c %warp our.bowl %home ~ %sing %a da+now.bowl pax]
- [[card ~] state]
::
++ handle-build
+ ~/ %handle-build
|= [=tid =sign-arvo]
^- (quip card ^state)
=/ =yarn (~(got by tid.state) tid)
(start-thread yarn p.maybe-thread)
::
++ start-thread
+ ~/ %start-thread
|= [=yarn =thread]
^- (quip card ^state)
=/ =vase vase:(~(got by starting.state) yarn)
(thread-fail u.yarn %cancelled ~)
::
++ take-input
+ ~/ %take-input
|= [=yarn input=(unit input:strand)]
^- (quip card ^state)
=/ m (strand ,vase)
