querysub 0.43.0 → 0.45.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.
@@ -1,5 +1,5 @@
1
1
  import { runInfinitePoll, runInfinitePollCallAtStart } from "socket-function/src/batching";
2
- import { isNode } from "socket-function/src/misc";
2
+ import { isNode, timeInMinute } from "socket-function/src/misc";
3
3
  import { logErrors } from "../errors";
4
4
  import debugbreak from "debugbreak";
5
5
  import { nodeDiscoveryShutdown } from "../-f-node-discovery/NodeDiscovery";
@@ -22,7 +22,7 @@ function logAll() {
22
22
  }
23
23
  }
24
24
 
25
- logErrors(runInfinitePollCallAtStart(1000 * 60, logAll));
25
+ logErrors(runInfinitePollCallAtStart(timeInMinute * 5, logAll));
26
26
 
27
27
  async function shutdown() {
28
28
  const { authorityStorage } = await import("../0-path-value-core/pathValueCore");
@@ -64,6 +64,10 @@ function getBufferUsage() {
64
64
  }
65
65
  }
66
66
 
67
+ registerDynamicResource("Heap", getUsedHeapSize);
68
+ registerDynamicResource("Buffers", getBufferUsage);
69
+ registerDynamicResource("All Memory", getHeapSize);
70
+
67
71
  function logResourcesNow() {
68
72
  let resourcesWithCounts = resources.map(resource => ({ ...resource, count: resource.getCount() }));
69
73
  resourcesWithCounts.sort((a, b) => b.count - a.count);
@@ -74,9 +78,6 @@ function logResourcesNow() {
74
78
  console.log(` ${resource.name}: ${formatNumber(resource.count)}`);
75
79
  }
76
80
  } else {
77
- logNodeStateStats("Heap", formatNumber)(getUsedHeapSize());
78
- logNodeStateStats("Buffers", formatNumber)(getBufferUsage());
79
- logNodeStateStats("All Memory", formatNumber)(getHeapSize());
80
81
  for (let resource of resourcesWithCounts) {
81
82
  if (resource.count === 0) continue;
82
83
  logNodeStateStats(resource.name, formatNumber)(resource.count);
@@ -7,20 +7,30 @@ import { registerPeriodic } from "./periodic";
7
7
  import { getOwnMachineId } from "../-a-auth/certs";
8
8
  import { SocketFunction } from "socket-function/SocketFunction";
9
9
  import { logDisk } from "./logs/diskLogger";
10
- import { registerNodeMetadata } from "../5-diagnostics/nodeMetadata";
11
- import { formatPercent } from "socket-function/src/formatting/format";
10
+ import { addStatPeriodic, addStatSumPeriodic, addTimeProfileDistribution, registerNodeMetadata } from "../5-diagnostics/nodeMetadata";
11
+ import { formatPercent, formatTime } from "socket-function/src/formatting/format";
12
12
 
13
13
  let lastProfile: MeasureProfile | undefined;
14
14
 
15
+ addStatPeriodic(
16
+ "% Profiled",
17
+ () => {
18
+ if (!lastProfile) return 0;
19
+ let entries = Object.values(lastProfile.entries);
20
+ if (entries.length === 0) return 0;
21
+ const timeProfiled = lastProfile.endTime - lastProfile.startTime;
22
+ let timeActive = entries.map(x => x.ownTime.sum).reduce((a, b) => a + b, 0);
23
+ return timeActive / timeProfiled;
24
+ },
25
+ formatPercent,
26
+ );
15
27
  registerNodeMetadata({
16
- columnName: "Est Recent % Usage",
28
+ columnName: "Top Profiled",
17
29
  getValue() {
18
30
  if (!lastProfile) return "";
19
31
  let entries = Object.values(lastProfile.entries);
20
32
  if (entries.length === 0) return "";
21
33
  const timeProfiled = lastProfile.endTime - lastProfile.startTime;
22
- let timeActive = entries.map(x => x.ownTime.sum).reduce((a, b) => a + b, 0);
23
- let frac = timeActive / timeProfiled;
24
34
  let rootSums = new Map<string, number>();
25
35
  for (let entry of entries) {
26
36
  let name = entry.name.split("|")[0];
@@ -28,9 +38,13 @@ registerNodeMetadata({
28
38
  rootSums.set(name, sum + entry.ownTime.sum);
29
39
  }
30
40
  let most = sort(Array.from(rootSums.entries()), x => -x[1])[0];
31
- return `${formatPercent(frac)} (${formatPercent(most[1] / timeProfiled)} ${endEllipsis(most[0], 26)})`;
41
+ return `${endEllipsis(most[0], 26)} = ${formatPercent(most[1] / timeProfiled)}`;
32
42
  },
33
43
  });
44
+ addTimeProfileDistribution("Network Calls", () => SocketFunction.harvestCallTimes());
45
+ addStatPeriodic("Pending Net Calls", () => SocketFunction.getPendingCallCount());
46
+ addStatSumPeriodic("Failed Net Calls", () => SocketFunction.harvestFailedCallCount());
47
+
34
48
  function endEllipsis(str: string, maxLength: number) {
35
49
  if (str.length <= maxLength) return str;
36
50
  return "..." + str.slice(-(maxLength - 3));
@@ -153,7 +153,7 @@ export class Input extends qreact.Component<InputProps> {
153
153
  this.lastChecked = e.currentTarget.checked;
154
154
  }
155
155
  let callback = props.onInput || props.onChange;
156
- callback?.(e);
156
+ callback?.(e as any);
157
157
  },
158
158
  onChange: e => {
159
159
  if (
package/src/zip.ts CHANGED
@@ -61,6 +61,7 @@ export class Zip {
61
61
  }
62
62
  }
63
63
 
64
+ @measureFnc
64
65
  public static gunzipSync(buffer: Buffer): Buffer {
65
66
  if (isNode()) {
66
67
  return Buffer.from(zlib.gunzipSync(buffer));