querysub 0.406.0 → 0.408.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/audit-disk-values.js +7 -0
- package/bin/deploy-prefixes.js +7 -0
- package/package.json +5 -3
- package/src/-a-archives/archiveCache.ts +12 -9
- package/src/-a-auth/certs.ts +1 -1
- package/src/-c-identity/IdentityController.ts +9 -1
- package/src/-f-node-discovery/NodeDiscovery.ts +63 -10
- package/src/0-path-value-core/AuthorityLookup.ts +14 -4
- package/src/0-path-value-core/PathRouter.ts +247 -117
- package/src/0-path-value-core/PathRouterRouteOverride.ts +1 -1
- package/src/0-path-value-core/PathRouterServerAuthoritySpec.tsx +4 -2
- package/src/0-path-value-core/PathValueCommitter.ts +68 -31
- package/src/0-path-value-core/PathValueController.ts +77 -8
- package/src/0-path-value-core/PathWatcher.ts +46 -4
- package/src/0-path-value-core/ShardPrefixes.ts +6 -0
- package/src/0-path-value-core/ValidStateComputer.ts +20 -8
- package/src/0-path-value-core/hackedPackedPathParentFiltering.ts +18 -55
- package/src/0-path-value-core/pathValueArchives.ts +19 -8
- package/src/0-path-value-core/pathValueCore.ts +75 -27
- package/src/0-path-value-core/startupAuthority.ts +9 -9
- package/src/1-path-client/RemoteWatcher.ts +217 -178
- package/src/1-path-client/pathValueClientWatcher.ts +6 -11
- package/src/2-proxy/pathValueProxy.ts +2 -3
- package/src/3-path-functions/PathFunctionRunner.ts +3 -1
- package/src/3-path-functions/syncSchema.ts +6 -2
- package/src/4-deploy/deployGetFunctionsInner.ts +1 -1
- package/src/4-deploy/deployPrefixes.ts +14 -0
- package/src/4-deploy/edgeNodes.ts +1 -1
- package/src/4-querysub/Querysub.ts +17 -5
- package/src/4-querysub/QuerysubController.ts +21 -10
- package/src/4-querysub/predictionQueue.tsx +3 -0
- package/src/4-querysub/querysubPrediction.ts +27 -20
- package/src/5-diagnostics/nodeMetadata.ts +17 -0
- package/src/diagnostics/NodeConnectionsPage.tsx +167 -0
- package/src/diagnostics/NodeViewer.tsx +11 -15
- package/src/diagnostics/PathDistributionInfo.tsx +102 -0
- package/src/diagnostics/SyncTestPage.tsx +19 -8
- package/src/diagnostics/auditDiskValues.ts +221 -0
- package/src/diagnostics/auditDiskValuesEntry.ts +43 -0
- package/src/diagnostics/logs/IndexedLogs/LogViewer3.tsx +5 -1
- package/src/diagnostics/logs/TimeRangeSelector.tsx +3 -3
- package/src/diagnostics/logs/lifeCycleAnalysis/LifeCycleRenderer.tsx +2 -0
- package/src/diagnostics/managementPages.tsx +10 -1
- package/src/diagnostics/misc-pages/ArchiveViewer.tsx +3 -2
- package/src/diagnostics/pathAuditer.ts +21 -0
- package/src/path.ts +9 -2
- package/src/rangeMath.ts +41 -0
- package/tempnotes.txt +5 -58
- package/test.ts +13 -295
- package/src/diagnostics/benchmark.ts +0 -139
- package/src/diagnostics/runSaturationTest.ts +0 -416
- package/src/diagnostics/satSchema.ts +0 -64
- package/src/test/mongoSatTest.tsx +0 -55
- package/src/test/satTest.ts +0 -193
- package/src/test/test.tsx +0 -552
package/src/test/satTest.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import debugbreak from "debugbreak";
|
|
2
|
-
import { configRootDiscoveryLocation } from "../-f-node-discovery/NodeDiscovery";
|
|
3
|
-
import { ClientWatcher } from "../1-path-client/pathValueClientWatcher";
|
|
4
|
-
import { Querysub } from "../4-querysub/QuerysubController";
|
|
5
|
-
configRootDiscoveryLocation({ domain: "querysub.com", port: 5050 });
|
|
6
|
-
|
|
7
|
-
import { Benchmark } from "../diagnostics/benchmark";
|
|
8
|
-
import { createBenchmarkFunctions, sat_functions } from "../diagnostics/satSchema";
|
|
9
|
-
import { runSaturationTests, DriftValues, runSingleSaturationTest } from "../diagnostics/runSaturationTest";
|
|
10
|
-
import { PermissionsCheck } from "../4-querysub/permissions";
|
|
11
|
-
import { appendToPathStr, getPathIndex, getPathStr, getPathSuffix, rootPathStr, trimPathStrToDepth } from "../path";
|
|
12
|
-
import { runCodeWithDatabase } from "../2-proxy/pathDatabaseProxyBase";
|
|
13
|
-
import { createPathValueProxy } from "../2-proxy/pathValueProxy";
|
|
14
|
-
import { proxyWatcher } from "../2-proxy/PathValueProxyWatcher";
|
|
15
|
-
import { measureCode, measureFnc, measureWrap } from "socket-function/src/profiling/measure";
|
|
16
|
-
import { DEPTH_TO_DATA, DOMAIN_INDEX, MODULE_INDEX, overrideCurrentCall } from "../3-path-functions/PathFunctionRunner";
|
|
17
|
-
import { cache } from "socket-function/src/caching";
|
|
18
|
-
import { timeInHour, timeInMinute } from "socket-function/src/misc";
|
|
19
|
-
import { delay } from "socket-function/src/batching";
|
|
20
|
-
import { parseHeapSnapshot, processAndSummarizeHeapsnapshot, writeHeapSnapshot } from "../heapDumps";
|
|
21
|
-
import { formatNumber } from "socket-function/src/formatting/format";
|
|
22
|
-
import fs from "fs";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// A stress test with a single watcher
|
|
26
|
-
/*
|
|
27
|
-
(watchdog at 12/31/2023) Profiled 684ms (logged at 2023-12-31T07:05:41.871Z)
|
|
28
|
-
ClientWatcher().setWatches(async) 34.47% ( 236ms = 85 * 2.73ms + 114 * 33.2us )
|
|
29
|
-
findFunctionsToCall 16.12% ( 110ms = 85 * 1.3ms )
|
|
30
|
-
PathWatcher().watchPath 15.25% ( 104ms = 85 * 1.22ms + 114 * 8.68us )
|
|
31
|
-
watchLatest|getSingleReadNode 7.23% ( 49.5ms = 85 * 570us + 114 * 9.35us )
|
|
32
|
-
PathWatcher().triggerLatestWatcher 5.95% ( 40.7ms = 169 * 241us )
|
|
33
|
-
|
|
34
|
-
(watchdog at 12/31/2023) Profiled 1.21s (logged at 2023-12-31T07:23:31.501Z)
|
|
35
|
-
findFunctionsToCall 21.14% ( 256ms = 5 * 42.1ms + 19 * 2.39ms )
|
|
36
|
-
PathWatcher().triggerLatestWatcher 15.39% ( 186ms = 919 * 203us )
|
|
37
|
-
PathValueCommitter().commitValues 12.14% ( 147ms = 898 * 164us )
|
|
38
|
-
RemoteWatcher().watchLatest(async) 11.21% ( 136ms = 922 * 147us )
|
|
39
|
-
AuthorityPathValueStorage().ingestValues 6.22% ( 75.3ms = 52 * 696us + 869 * 45us )
|
|
40
|
-
*/
|
|
41
|
-
// The proxyWatcher is taking most of the time, specifically due to the fact that it does not natively
|
|
42
|
-
// support delta based functions.
|
|
43
|
-
|
|
44
|
-
async function stressTest() {
|
|
45
|
-
let targetRatePerSecond = 200;
|
|
46
|
-
let startTime = Date.now();
|
|
47
|
-
|
|
48
|
-
for (let i = 0; i < 300 * 300; i++) {
|
|
49
|
-
sat_functions.setValues([i]);
|
|
50
|
-
|
|
51
|
-
while (true) {
|
|
52
|
-
let rate = i / (Date.now() - startTime) * 1000;
|
|
53
|
-
if (rate < targetRatePerSecond) break;
|
|
54
|
-
await delay(16);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
stressTest().catch(e => console.error(e)).finally(() => process.exit());
|
|
60
|
-
|
|
61
|
-
async function timeTest() {
|
|
62
|
-
await Querysub.hostService("test");
|
|
63
|
-
|
|
64
|
-
await proxyWatcher.commitFunction({
|
|
65
|
-
watchFunction() {
|
|
66
|
-
const check = new PermissionsCheck({ callerMachineId: "", callerIP: "" });
|
|
67
|
-
let allowed = check.checkPermissions(getPathStr(["querysub.com", "PathFunctionRunner", "test", "Data", "test", "1"]));
|
|
68
|
-
console.log({ allowed });
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// ~1.62us, so... if we can optimize this code... that would be good...
|
|
73
|
-
// AND, it doesn't even emit any specific paths, so... we can probably cache it a lot...
|
|
74
|
-
let cache = new Map<string, { domainName: string; moduleId: string; pathPrefix: string; rootKey: string }>();
|
|
75
|
-
function splitParts(path: string): { domainName: string; moduleId: string; pathPrefix: string; rootKey: string } {
|
|
76
|
-
let pathPrefix = trimPathStrToDepth(path, DEPTH_TO_DATA);
|
|
77
|
-
let result = cache.get(pathPrefix);
|
|
78
|
-
if (!result) {
|
|
79
|
-
const domainName = getPathIndex(path, DOMAIN_INDEX) || "";
|
|
80
|
-
const moduleId = getPathIndex(path, MODULE_INDEX) || "";
|
|
81
|
-
let rootKey = getPathIndex(path, DEPTH_TO_DATA - 1) || "";
|
|
82
|
-
result = { domainName, moduleId, pathPrefix, rootKey };
|
|
83
|
-
cache.set(pathPrefix, result);
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const simulateCheckPermissions = measureWrap(function simulateCheckPermissions(path: string) {
|
|
89
|
-
return trimPathStrToDepth(path, DEPTH_TO_DATA);
|
|
90
|
-
|
|
91
|
-
// let obj = splitParts(path);
|
|
92
|
-
// if (!obj.domainName) return { permissionsPath: trimPathStrToDepth(path, DOMAIN_INDEX + 1), allowed: false };
|
|
93
|
-
// if (!obj.moduleId) return { permissionsPath: trimPathStrToDepth(path, MODULE_INDEX + 1), allowed: false };
|
|
94
|
-
// if (!obj.rootKey) return { permissionsPath: trimPathStrToDepth(path, DEPTH_TO_DATA), allowed: false };
|
|
95
|
-
|
|
96
|
-
// let pathInModule = getPathSuffix(path, DEPTH_TO_DATA - 1);
|
|
97
|
-
// if (!pathInModule) return { permissionsPath: path, allowed: false };
|
|
98
|
-
// if (pathInModule === rootPathStr) return { permissionsPath: path, allowed: false };
|
|
99
|
-
|
|
100
|
-
// return obj;
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
await measureCode(async function permissionsCheckTest() {
|
|
105
|
-
await proxyWatcher.commitFunction({
|
|
106
|
-
watchFunction() {
|
|
107
|
-
console.log(`Start perf test`);
|
|
108
|
-
|
|
109
|
-
const check = new PermissionsCheck({ callerMachineId: "", callerIP: "127.0.0.1" });
|
|
110
|
-
let paths: string[] = [];
|
|
111
|
-
for (let i = 0; i < 1000 * 100; i++) {
|
|
112
|
-
paths.push(getPathStr(["querysub.com", "PathFunctionRunner", "test", "Results", i.toString()]));
|
|
113
|
-
//paths.push(getPathStr(["querysub.com", "PathFunctionRunner", "test", "Data", i.toString()]));
|
|
114
|
-
}
|
|
115
|
-
for (let path of paths) {
|
|
116
|
-
check.checkPermissions(path);
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
//timeTest().catch(e => console.error(e)).finally(() => process.exit());
|
|
123
|
-
|
|
124
|
-
export async function main() {
|
|
125
|
-
// let values = new DriftValues({ count: 9, modulus: 50 * 50, driftFraction: 0.1 });
|
|
126
|
-
// for (let i = 0; i < 10; i++) {
|
|
127
|
-
// let calls = Array(100).fill(0).map(() =>
|
|
128
|
-
// Benchmark.waitForCallToFinish(sat_functions.setValues(values.getNextValues()))
|
|
129
|
-
// );
|
|
130
|
-
// await Promise.all(calls);
|
|
131
|
-
// }
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// await runSingleSaturationTest({
|
|
135
|
-
// duration: 5000,
|
|
136
|
-
// saturation: 100,
|
|
137
|
-
// writeSpec: new DriftValues({ count: 9, modulus: 50 * 50, driftFraction: 0.1 }),
|
|
138
|
-
// functions: createBenchmarkFunctions(),
|
|
139
|
-
// });
|
|
140
|
-
|
|
141
|
-
await runSaturationTests({
|
|
142
|
-
durationPer: 1000,
|
|
143
|
-
//writeSpec: new DriftValues({ count: 77, modulus: INDEX_EXTENT, driftFraction: 0.1 }),
|
|
144
|
-
//writeSpec: new DriftValues({ count: 10, modulus: INDEX_EXTENT, driftFraction: 0.1 }),
|
|
145
|
-
//writeSpec: new DriftValues({ count: 9, modulus: 50 * 50, driftFraction: 0.1 }),
|
|
146
|
-
writeSpec: new DriftValues({ count: 1, modulus: 50 * 50, driftFraction: 0.1 }),
|
|
147
|
-
functions: createBenchmarkFunctions(),
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
//main().catch(e => console.error(e)).finally(() => process.exit());
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
/* 1s test time, 0 watchers (more watchers is slower)
|
|
154
|
-
new DriftValues({ count: 9, modulus: 50 * 50, driftFraction: 0.1 })
|
|
155
|
-
Suggestions
|
|
156
|
-
Min latency 60.7/s latency = 16.5ms (24.68% saturation) (15 count)
|
|
157
|
-
*** Min latency 2X 259/s latency = 30.9ms (799.51% saturation) (264 count)
|
|
158
|
-
100ms latency 348/s latency = 91.6ms (3190.90% saturation) (352 count)
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
/* 1s test time
|
|
162
|
-
new DriftValues({ count: 1, modulus: 50 * 50, driftFraction: 0.1 })
|
|
163
|
-
Suggestions
|
|
164
|
-
Min latency 42.6/s latency = 23.4ms (25.45% saturation) (11 count)
|
|
165
|
-
*** Min latency 2X 303/s latency = 52.7ms (1596.21% saturation) (304 count)
|
|
166
|
-
100ms latency 368/s latency = 86.8ms (3191.19% saturation) (384 count)
|
|
167
|
-
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
/* Same test on MongoDB
|
|
171
|
-
1s test time
|
|
172
|
-
writeSpec: new DriftValues({ count: 1, modulus: 50 * 50, driftFraction: 0.1 }),
|
|
173
|
-
Suggestions
|
|
174
|
-
Min latency 214/s latency = 4.68ms (24.53% saturation) (53 count)
|
|
175
|
-
*** Min latency 2X 4467/s latency = 7.14ms (3190.04% saturation) (4485 count)
|
|
176
|
-
100ms latency 4768/s latency = 104ms (49459.71% saturation) (4983 count)
|
|
177
|
-
!!!! ERROR !!!!: 534 indexes were wrong, 1.80% of operations were missed
|
|
178
|
-
|
|
179
|
-
So mongo has about 1/4 the latency and 15X the throughput.
|
|
180
|
-
- Although, only 10X the throughput if we oversaturate our server and allow our latency to jump to 76.6ms.
|
|
181
|
-
WHICH, is fair, because the clientside predicts all the values, so the perceived latency will still usually be 0ms.
|
|
182
|
-
- ALSO, technically our perceived latency will be 0ms, at least for writes, due to client side prediction.
|
|
183
|
-
- ALSO, on any reasonable network the latency will be MUCH higher than 7ms, or 26ms, due to the network latency.
|
|
184
|
-
Except due to clientside prediction, Querysub will again, have 0ms perceived latency, so... our latency is
|
|
185
|
-
actually MUCH better.
|
|
186
|
-
- The throughput different is promising, considering how we use javascript (and worse, Proxies) for everything. Also,
|
|
187
|
-
we are bottlenecked on function evaluation, which technically evaluates arbitrary application functions, which makes
|
|
188
|
-
it significantly more powerful than what mongodb support.
|
|
189
|
-
- The overwhelming majority of our time is spent in function evaluation (~80%), which is quite isolated, so
|
|
190
|
-
optimization should be possible (ex, rewriting FunctionRunner to run in another language, to run
|
|
191
|
-
specially application optimized functions in that other language).
|
|
192
|
-
*/
|
|
193
|
-
|