| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 29c8411 commit 6bd2420
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ | |||
| 7 | 7 | #include "node_buffer.h" | |
| 8 | 8 | #include "node_options-inl.h" | |
| 9 | 9 | #include "node_perf.h" | |
| 10 | + #include "node_snapshot_builder.h" | ||
| 10 | 11 | #include "util-inl.h" | |
| 11 | 12 | #include "async_wrap-inl.h" | |
| 12 | 13 | ||
@@ -146,6 +147,20 @@ class WorkerThreadData { | |||
| 146 | 147 | SetIsolateCreateParamsForNode(¶ms); | |
| 147 | 148 | params.array_buffer_allocator_shared = allocator; | |
| 148 | 149 | ||
| 150 | + bool use_node_snapshot = true; | ||
| 151 | + if (w_->per_isolate_opts_) { | ||
| 152 | + use_node_snapshot = w_->per_isolate_opts_->node_snapshot; | ||
| 153 | + } else { | ||
| 154 | + // IsolateData is created after the Isolate is created so we'll | ||
| 155 | + // inherit the option from the parent here. | ||
| 156 | + use_node_snapshot = per_process::cli_options->per_isolate->node_snapshot; | ||
| 157 | + } | ||
| 158 | + const SnapshotData* snapshot_data = | ||
| 159 | + use_node_snapshot ? SnapshotBuilder::GetEmbeddedSnapshotData() | ||
| 160 | + : nullptr; | ||
| 161 | + if (snapshot_data != nullptr) { | ||
| 162 | + SnapshotBuilder::InitializeIsolateParams(snapshot_data, ¶ms); | ||
| 163 | + } | ||
| 149 | 164 | w->UpdateResourceConstraints(¶ms.constraints); | |
| 150 | 165 | ||
| 151 | 166 | Isolate* isolate = Isolate::Allocate(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,11 @@ if (!process.env.HAS_STARTED_WORKER) { | |||
| 10 | 10 | resourceLimits: { | |
| 11 | 11 | maxYoungGenerationSizeMb: 0, | |
| 12 | 12 | maxOldGenerationSizeMb: 0 | |
| 13 | - } | ||
| 13 | + }, | ||
| 14 | + // With node snapshot the OOM can occur during the deserialization of | ||
| 15 | + // the context, so disable it since we want the OOM to occur during | ||
| 16 | + // the creation of the message port. | ||
| 17 | + execArgv: [ ...process.execArgv, '--no-node-snapshot'] | ||
| 14 | 18 | }; | |
| 15 | 19 | ||
| 16 | 20 | const worker = new Worker(__filename, opts); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments