interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / apps / interplane-forge / nodes / srch.om

123 lines · 2741 bytes Raw Blame History
1note nodes/srch.om: global code search stops each git grep as soon as the page has the lines it can
2note still show. The page shows at most 100 hits in allow-list order, and git grep prints its hits in
3note path order, so once the output of the current repository holds 100 - (hits so far) complete
4note lines, the rest of that grep can never reach the page: the child is killed and its tree scan
5note ends there. The rendered bytes are those of reading the whole output (fexec), with one
6note difference: a git that would fail after printing those lines is shown, where fexec's status rule
7note would have dropped the repository. Each complete line of `git grep ... refs/heads/<b>` output is
8note "<ref>:<path>:<n>:<text>", which fcshit always counts as one hit.
9note git stays the search oracle: the argv is fgreparg's, exec'd by fchild (no shell, empty env).
10note Measured against the one-after-another search in docs/PERF.md; a first version that ran six greps
11note at once was slower on the two production cores and was dropped.
12global nsfull ulong 1
13note nsnl: newlines in fxo[a, b)
14fn nsnl a ulong b ulong to ulong
15c = ulong 0
16for k ulong sub b a bound 524288
17if eq get fxo add a k 10
18c = add c 1
19end
20end
21ret c
22end
23note nsdrain: fdrain, and also done (nsfull = 1) once fxo holds `need` complete lines
24fn nsdrain fd int dl long need ulong to bool
25put nsfull 0 0
26nl = ulong 0
27for it ulong 10000000
28left = sub dl long monons
29if le left 0
30ret false
31end
32w = waitio fd 1 left
33if lt w 0
34if ne w -4
35ret false
36end
37continue
38end
39if eq w 0
40continue
41end
42n = get fxol 0
43if ge n len fxo
44put fxotr 0 1
45r = read fd fjunk 0 4096
46if eq r 0
47ret true
48end
49if and lt r 0 and ne r -4 ne r -11
50ret false
51end
52continue
53end
54r = read fd fxo n sub len fxo n
55if eq r 0
56ret true
57end
58if lt r 0
59if and ne r -4 ne r -11
60ret false
61end
62continue
63end
64put fxol 0 add n ulong r
65nl = add nl nsnl n add n ulong r
66if ge nl need
67put nsfull 0 1
68ret true
69end
70end
71ret false
72end
73note nsrun: git grep for repository j into fxo, stopped after `need` lines; fexec's status rule,
74note except that a child stopped for having enough lines counts as success (0)
75fn nsrun j ulong need ulong to long
76put fxol 0 0
77put fxotr 0 0
78fgreparg j
79r = pipefds fpfd 0 8 524288
80if lt r 0
81ret -2
82end
83rfd = fpfdv 0
84wfd = fpfdv 1
85dl = add long monons 10000000000
86pid = fork
87if lt pid 0
88x = fclose rfd
89x = fclose wfd
90ret -2
91end
92if eq pid 0
93fchild wfd
94exit 127
95end
96x = fclose wfd
97ok = nsdrain rfd dl need
98x = fclose rfd
99full = eq get nsfull 0 1
100if or not ok full
101x = killpid int pid 9
102end
103st = freap int pid dl
104if not ok
105ret -1
106end
107if full
108ret 0
109end
110ret st
111end
112fn nscodesr to void
113for i ulong get fan 0 bound FAMAX
114h = get fhits 0
115if ge h 100
116break
117end
118st = nsrun i sub 100 h
119if eq st 0
120fcsrepo i
121end
122end
123end