interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / growth / g1prep.om

781 lines · 11766 bytes Raw Blame History
1note growth/g1prep.om: windowed clones, downloads and stars, seed-check history.
2note Prefixes: fn gr*, global gg*, text tg*. Does not edit the counts journal. Reads it after fzsync.
3note Trending window default 604800 s (7*86400, WolframLanguageEvaluator). Score = visitor git fetches
4note plus visitor downloads plus net stars, all inside the window. Zero stays zero. Unknown is separate.
5text tgwin "window"
6text tgord "order"
7text tgtr "trending"
8text tgnw "new"
9text tgtrp "/trending"
10text tgtrj "/trending.json"
11text tgins "/insights"
12text tginj "/insights.json"
13text tggdir "growth/"
14text tgsdl "seeds.log"
15text tgfmt "--format=%aN"
16text tgdotj ".json"
17text tgact "\"action\":\""
18text tgts "\"ts\":"
19text tgtg "\"target\":\""
20text tgstar "star"
21text tgunst "unstar"
22text tgrad "rad:"
23const ggwdef ulong 604800
24const ggwmax ulong 315360000
25global ggwin ulong 1
26global ggnow ulong 1
27global ggw0 ulong 1
28global ggord ulong 1
29global ggcln ulong 256
30global ggdlw ulong 256
31global ggstw ulong 256
32global ggstu ulong 256
33global ggscr ulong 256
34global ggix ulong 256
35global gglst ulong 256
36global ggslc ulong 256
37global ggcon ulong 1
38global ggcnn ulong 1
39global ggctr ulong 1
40global ggcnm uchar 3072
41global ggcnl ulong 64
42global ggpen ulong 1
43global ggpmr ulong 1
44global ggsrn ulong 1
45global ggsep ulong 16
46global ggsec ulong 16
47global ggfts ulong 1
48global ggln uchar 128
49global ggll ulong 1
50note ggjtr: 1 when the journal did not fit one read (fxo), so window numbers are not measured
51global ggjtr ulong 1
52fn grwnum n ulong to ulong
53v = ulong 0
54if eq n 0
55ret 0
56end
57for i ulong n bound 12
58c = get fval i
59if or lt c 48 gt c 57
60ret 0
61end
62v = add mul v 10 ulong sub c 48
63end
64ret v
65end
66fn greq t view uchar * n ulong to bool
67if ne n len t
68ret false
69end
70for i ulong n bound 16
71if ne get fval i get t i
72ret false
73end
74end
75ret true
76end
77note grsetq: 0 ok (ggord 0 when order is absent), 400 when order or window is malformed
78fn grsetq to long
79put ggwin 0 ggwdef
80n = fqget tgwin
81if ge n 0
82if or eq n 0 gt n 9
83ret 400
84end
85w = grwnum ulong n
86if or eq w 0 gt w ggwmax
87ret 400
88end
89put ggwin 0 w
90end
91n = fqget tgord
92if lt n 0
93put ggord 0 0
94ret 0
95end
96if greq tgtr ulong n
97put ggord 0 1
98ret 0
99end
100if greq tgnw ulong n
101put ggord 0 2
102ret 0
103end
104ret 400
105end
106fn grclock to void
107put ggnow 0 div ulong realns 1000000000
108w = get ggwin 0
109if gt w get ggnow 0
110put ggw0 0 0
111else
112put ggw0 0 sub get ggnow 0 w
113end
114end
115fn grinw ep ulong to bool
116if lt ep get ggw0 0
117ret false
118end
119ret le ep get ggnow 0
120end
121fn greol p ulong n ulong to ulong
122j = p
123while lt j n bound 16777216
124if eq get fxo j 10
125ret j
126end
127j = add j 1
128end
129ret n
130end
131fn grpre p ulong t view uchar * to bool
132if gt add p len t get fxol 0
133ret false
134end
135for k ulong len t bound 32
136if ne get fxo add p k get t k
137ret false
138end
139end
140ret true
141end
142fn grfind a ulong e ulong t view uchar * to ulong
143if gt add a len t e
144ret e
145end
146last = sub e len t
147p = a
148while le p last bound 16777216
149if grpre p t
150ret p
151end
152p = add p 1
153end
154ret e
155end
156fn grrid i ulong a ulong n ulong to bool
157if ne get fail i n
158ret false
159end
160for k ulong n bound 64
161if ne fridbyte i k get fxo add a k
162ret false
163end
164end
165ret true
166end
167fn grrix a ulong n ulong to ulong
168if eq n 0
169ret 9999
170end
171for i ulong get fan 0 bound FAMAX
172if grrid i a n
173ret i
174end
175end
176ret 9999
177end
178fn grkind c uchar to ulong
179if eq c 103
180ret 0
181end
182if eq c 112
183ret 1
184end
185if eq c 97
186ret 2
187end
188if eq c 114
189ret 3
190end
191ret 9
192end
193fn graddk i ulong k ulong to void
194if eq k 0
195put ggcln i add get ggcln i 1
196end
197if or eq k 2 eq k 3
198put ggdlw i add get ggdlw i 1
199end
200end
201note the scans of a journal or log line in this file step one byte inside fxo[.., e): their bound is
202note the size of fxo. The lines are written by this server (20 digits, an id of 60 bytes at most), but a
203note small bound would make a line edited by hand a trap 4 (exit 104).
204fn grevent a ulong e ulong to void
205if lt sub e a 6
206ret
207end
208if ne get fxo a 101
209ret
210end
211if ne get fxo add a 1 32
212ret
213end
214k = grkind get fxo add a 2
215if gt k 3
216ret
217end
218if ne get fxo add a 3 32
219ret
220end
221p = add a 4
222q = p
223while lt q e bound 16777216
224c = get fxo q
225if or lt c 48 gt c 57
226break
227end
228q = add q 1
229end
230if eq q p
231ret
232end
233if ge q e
234ret
235end
236if ne get fxo q 32
237ret
238end
239ep = ulong 0
240j = p
241while lt j q bound 16777216
242ep = add mul ep 10 ulong sub get fxo j 48
243j = add j 1
244end
245if not grinw ep
246ret
247end
248r = add q 1
249if ge r e
250ret
251end
252i = grrix r sub e r
253if ge i 9999
254ret
255end
256graddk i k
257end
258note grlines: only the committed journal (up to fzjend); a torn last batch is not counted, as in counts.om
259fn grlines to void
260n = get fxol 0
261if gt n get fzjend 0
262n = get fzjend 0
263end
264p = ulong 0
265while lt p n bound 16777216
266e = greol p n
267grevent p e
268p = add e 1
269end
270end
271fn grclr to void
272for i ulong FAMAX
273put ggcln i 0
274put ggdlw i 0
275put ggstw i 0
276put ggstu i 0
277put ggscr i 0
278end
279end
280fn grscan to void
281grclr
282put ggjtr 0 0
283fzpath 3 0
284r = frdall
285if lt r 0
286ret
287end
288if and eq get fxotr 0 1 gt get fzjend 0 get fxol 0
289put ggjtr 0 1
290end
291grlines
292end
293note grwm: window counts of source s are measured (source read, whole journal read)
294fn grwm s ulong to bool
295if eq get fzsnc s 0
296ret false
297end
298ret eq get ggjtr 0 0
299end
300fn gract a ulong e ulong to ulong
301p = grfind a e tgact
302if ge p e
303ret 0
304end
305q = add p len tgact
306if grpre q tgunst
307ret 2
308end
309if grpre q tgstar
310ret 1
311end
312ret 0
313end
314fn grts a ulong e ulong to ulong
315p = grfind a e tgts
316if ge p e
317ret 0
318end
319q = add p len tgts
320v = ulong 0
321k = ulong 0
322while lt q e bound 16777216
323c = get fxo q
324if or lt c 48 gt c 57
325break
326end
327v = add mul v 10 ulong sub c 48
328q = add q 1
329k = add k 1
330end
331if eq k 0
332ret 0
333end
334ret v
335end
336fn grtgtr a ulong e ulong to ulong
337p = grfind a e tgtg
338if ge p e
339ret 9999
340end
341q = add p len tgtg
342if not grpre q tgrad
343ret 9999
344end
345q = add q len tgrad
346r = q
347while lt r e bound 16777216
348if eq get fxo r 34
349break
350end
351r = add r 1
352end
353if eq r q
354ret 9999
355end
356ret grrix q sub r q
357end
358fn grsev a ulong e ulong to void
359ts = grts a e
360if and ne ts 0 eq get ggfts 0 0
361put ggfts 0 ts
362end
363act = gract a e
364if eq act 0
365ret
366end
367if not grinw ts
368ret
369end
370i = grtgtr a e
371if ge i 9999
372ret
373end
374if eq act 1
375put ggstw i add get ggstw i 1
376end
377if eq act 2
378put ggstu i add get ggstu i 1
379end
380end
381fn grsoc to void
382put ggfts 0 0
383fpb
384if gt get gsddl 0 0
385put fpthl 0 0
386for i ulong get gsddl 0 bound 512
387fpc get gsdd i
388end
389end
390fpt tslog
391r = frdall
392if lt r 0
393ret
394end
395n = get fxol 0
396p = ulong 0
397while lt p n bound 16777216
398e = greol p n
399grsev p e
400p = add e 1
401end
402end
403fn grnet i ulong to ulong
404t = get ggstw i
405u = get ggstu i
406if gt t u
407ret sub t u
408end
409ret 0
410end
411note grscore: each part counts only when measured (grwm, gsok); an unmeasured part adds nothing
412fn grscore to void
413wc = grwm 0
414wd = grwm 2
415for i ulong get fan 0 bound FAMAX
416s = ulong 0
417if wc
418s = add s get ggcln i
419end
420if wd
421s = add s get ggdlw i
422end
423if eq get gsok 0 1
424s = add s grnet i
425end
426put ggscr i s
427end
428end
429fn grnlt a ulong b ulong to bool
430na = get fanl a
431nb = get fanl b
432n = na
433if gt n nb
434n = nb
435end
436for k ulong n bound 128
437ca = frnbyte a k
438cb = frnbyte b k
439if lt ca cb
440ret true
441end
442if gt ca cb
443ret false
444end
445end
446ret lt na nb
447end
448fn grtrn a ulong b ulong to bool
449sa = get ggscr a
450sb = get ggscr b
451if gt sa sb
452ret true
453end
454if lt sa sb
455ret false
456end
457ret grnlt a b
458end
459fn grnew a ulong b ulong to bool
460ta = get falct a
461tb = get falct b
462if gt ta tb
463ret true
464end
465if lt ta tb
466ret false
467end
468ret grnlt a b
469end
470fn grless a ulong b ulong to bool
471if eq get ggord 0 2
472ret grnew a b
473end
474ret grtrn a b
475end
476fn grswap j ulong to void
477t = get ggix j
478put ggix j get ggix sub j 1
479put ggix sub j 1 t
480end
481fn grsift i ulong to void
482j = i
483while gt j 0 bound FAMAX
484if grless get ggix j get ggix sub j 1
485grswap j
486j = sub j 1
487else
488ret
489end
490end
491end
492fn grsort to void
493n = get fan 0
494for i ulong n bound FAMAX
495put ggix i i
496end
497for i ulong n bound FAMAX
498grsift i
499end
500end
501fn grlc c uchar to void
502n = get ggll 0
503if lt n len ggln
504put ggln n c
505put ggll 0 add n 1
506end
507end
508fn grldec v ulong to void
509d = new uchar 20 0
510i = ulong 20
511x = v
512for it ulong 20
513i = sub i 1
514put d i uchar add rem x 10 48
515x = div x 10
516if eq x 0
517break
518end
519end
520for k ulong sub 20 i bound 20
521grlc get d add i k
522end
523end
524fn grmk to void
525fpb
526fpt tfdata
527fpt tggdir
528x = makedir fpth 0 get fpthl 0 448
529end
530fn grsdpath to void
531fpb
532fpt tfdata
533fpt tggdir
534fpt tgsdl
535end
536note grnote: append "s <time> <count> <rid>" when the count differs from the last line this process
537note wrote for the repo (the first check after a start always writes), so the series is change points
538fn grnote i ulong to void
539if ne get fzsdk i 1
540ret
541end
542t = get fzsdt i
543if or eq t 0 eq t get gglst i
544ret
545end
546if and ne get gglst i 0 eq get ggslc i get fzsd i
547ret
548end
549grmk
550grsdpath
551put ggll 0 0
552grlc 115
553grlc 32
554grldec t
555grlc 32
556grldec get fzsd i
557grlc 32
558for k ulong get fail i bound 64
559grlc fridbyte i k
560end
561grlc 10
562fd = fopen fpth 0 get fpthl 0 525377 384
563if lt fd 0
564ret
565end
566n = write int fd ggln 0 get ggll 0
567x = fclose int fd
568if eq n long get ggll 0
569put gglst i t
570put ggslc i get fzsd i
571end
572end
573fn grshft to void
574for k ulong 15
575put ggsep k get ggsep add k 1
576put ggsec k get ggsec add k 1
577end
578put ggsrn 0 15
579end
580fn grsdec a ulong e ulong to ulong
581v = ulong 0
582j = a
583if ge a e
584ret 0
585end
586while lt j e bound 16777216
587c = get fxo j
588if or lt c 48 gt c 57
589break
590end
591v = add mul v 10 ulong sub c 48
592j = add j 1
593end
594ret v
595end
596fn grsline a ulong e ulong i ulong to void
597if lt sub e a 4
598ret
599end
600if ne get fxo a 115
601ret
602end
603if ne get fxo add a 1 32
604ret
605end
606p = add a 2
607q = p
608while lt q e bound 16777216
609if eq get fxo q 32
610break
611end
612q = add q 1
613end
614ep = grsdec p q
615r = add q 1
616s = r
617while lt s e bound 16777216
618if eq get fxo s 32
619break
620end
621s = add s 1
622end
623ct = grsdec r s
624z = add s 1
625if not grrid i z sub e z
626ret
627end
628if ge get ggsrn 0 16
629grshft
630end
631k = get ggsrn 0
632put ggsep k ep
633put ggsec k ct
634put ggsrn 0 add k 1
635end
636fn grseries i ulong to void
637put ggsrn 0 0
638grsdpath
639r = frdall
640if lt r 0
641ret
642end
643n = get fxol 0
644p = ulong 0
645while lt p n bound 16777216
646e = greol p n
647grsline p e i
648p = add e 1
649end
650end
651fn gradd a ulong e ulong to void
652n = sub e a
653if eq n 0
654ret
655end
656if gt n 48
657n = ulong 48
658end
659if grseen n a
660ret
661end
662if ge get ggcnn 0 64
663put ggctr 0 1
664ret
665end
666i = get ggcnn 0
667o = mul i 48
668for k ulong n bound 48
669put ggcnm add o k get fxo add a k
670end
671put ggcnl i n
672put ggcnn 0 add i 1
673end
674fn gruniq to void
675put ggcnn 0 0
676put ggctr 0 0
677n = get fxol 0
678p = ulong 0
679while lt p n bound 16777216
680e = greol p n
681gradd p e
682p = add e 1
683end
684end
685fn grbneq i ulong k ulong a ulong to bool
686o = add mul i 48 k
687ret ne get ggcnm o get fxo add a k
688end
689fn grsame i ulong n ulong a ulong to bool
690for k ulong n bound 48
691if grbneq i k a
692ret false
693end
694end
695ret true
696end
697fn grseen n ulong a ulong to bool
698for i ulong get ggcnn 0 bound 64
699if eq get ggcnl i n
700if grsame i n a
701ret true
702end
703end
704end
705ret false
706end
707fn grlog i ulong ns ulong to bool
708fkgiti i
709fka tflog
710fka tgfmt
711fkopen
712if eq ns 1
713fkt tfrns
714fkt tfnid
715fkt tfrnsh
716else
717fkt tfrh
718end
719o = get fabo i
720for k ulong get fabl i bound 64
721fkc get fabr add o k
722end
723st = fexec 8000000000
724ret eq st 0
725end
726fn grcon i ulong to void
727put ggcon 0 9999
728put ggcnn 0 0
729if grlog i 0
730gruniq
731put ggcon 0 get ggcnn 0
732ret
733end
734if grlog i 1
735gruniq
736put ggcon 0 get ggcnn 0
737end
738end
739fn grpatch to void
740put ggpen 0 9999
741put ggpmr 0 9999
742if eq corefs 1 false
743ret
744end
745put ggpen 0 get gcun 0
746m = ulong 0
747for j ulong get gcun 0 bound 1024
748coidref get gcui j
749if coload 1
750if eq costate 3
751m = add m 1
752end
753end
754end
755put ggpmr 0 m
756end
757note grprep: trending and new do not run rad. One routing read is about 110 ms, so a read per public repo
758note on every node-database change would hold the one-request-at-a-time server for seconds. Each repo's
759note seeds are the last check this process made for it (repo home or insights), not measured when none.
760fn grprep to void
761fzsync 0
762fzsync 1
763fzsync 2
764grscan
765grsoc
766grscore
767end
768fn grone to void
769i = get fridx 0
770fzsync 0
771fzsync 1
772fzsync 2
773fzseeds i
774grnote i
775grscan
776grsoc
777grscore
778grcon i
779grpatch
780grseries i
781end