@preventive/triage 1.0.0-alpha.59 → 1.0.0-alpha.60
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/package.json +1 -1
- package/server-managed/bundle-build.ts +10 -11
package/package.json
CHANGED
|
@@ -117,20 +117,19 @@ export interface BuildRequest {
|
|
|
117
117
|
const active = new Set<string>()
|
|
118
118
|
const MAX_ACTIVE_BUILDS = 1
|
|
119
119
|
|
|
120
|
-
// What a build's worker may take of the JS heap, in MiB:
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
120
|
+
// What a build's worker may take of the JS heap, in MiB: the memory the
|
|
121
|
+
// process may use, its container's limit else the machine's, less
|
|
122
|
+
// RESERVED_MIB, at least the 512 MiB a build always had. A large project's
|
|
123
|
+
// tree, as a React Native app's, laid out and scanned in memory, takes more
|
|
124
|
+
// than 2 GiB, as `stasis github-bundle` takes what Node's default heap gives
|
|
125
|
+
// it. What is reserved is the server's, and the worker's own beyond its heap:
|
|
126
|
+
// the bytes of the files it lays out, its bundle's JSON (512 MiB at most, the
|
|
127
|
+
// worker's MAX_SERIALIZED_BYTES) and that compressed. Past it, Node
|
|
128
128
|
// terminates the worker (build-memory), not the process.
|
|
129
|
-
const
|
|
130
|
-
const SERVER_RESERVE_MIB = 512
|
|
129
|
+
const RESERVED_MIB = 512
|
|
131
130
|
const MIN_BUILD_HEAP_MIB = 512
|
|
132
131
|
export function buildHeapLimitMib(memory = Math.min(process.constrainedMemory() || Infinity, totalmem())): number {
|
|
133
|
-
return Math.
|
|
132
|
+
return Math.max(MIN_BUILD_HEAP_MIB, Math.floor(memory / 1024 ** 2) - RESERVED_MIB)
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
export async function withBundleBuildLease<T>(db: BundleBuildLeaseStore, userId: string, signal: AbortSignal,
|