Skip to content

Commit eef3030

Browse files
joyeecheungRafaelGSS
authored andcommitted
src: remove cached data tag from snapshot metadata
This only served as a preemptive check, but serializing this in the snapshot would make it unreproducible on different hardware. In the current cached data version tag, the V8 version can already be checked as part of the existing Node.js version check. The V8 flags aren't necessarily important for snapshot/code cache mismatches (only a small subset are), and the CPU features currently don't matter, so doing an exact match is stricter than necessary. Removing the check to help making the snapshot more reproducible on different hardware. PR-URL: #54122 Refs: nodejs/build#3043 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 1e01bdc commit eef3030

File tree

4 files changed

+7
-26
lines changed

4 files changed

+7
-26
lines changed

src/env.cc

-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ std::ostream& operator<<(std::ostream& output, const SnapshotMetadata& i) {
320320
<< " \"" << i.node_version << "\", // node_version\n"
321321
<< " \"" << i.node_arch << "\", // node_arch\n"
322322
<< " \"" << i.node_platform << "\", // node_platform\n"
323-
<< " " << i.v8_cache_version_tag << ", // v8_cache_version_tag\n"
324323
<< " " << i.flags << ", // flags\n"
325324
<< "}";
326325
return output;

src/env.h

-2
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,6 @@ struct SnapshotMetadata {
549549
std::string node_version;
550550
std::string node_arch;
551551
std::string node_platform;
552-
// Result of v8::ScriptCompiler::CachedDataVersionTag().
553-
uint32_t v8_cache_version_tag;
554552
SnapshotFlags flags;
555553
};
556554

src/node_snapshotable.cc

-23
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ using v8::Isolate;
4343
using v8::Local;
4444
using v8::Object;
4545
using v8::ObjectTemplate;
46-
using v8::ScriptCompiler;
4746
using v8::SnapshotCreator;
4847
using v8::StartupData;
4948
using v8::String;
@@ -542,7 +541,6 @@ SnapshotMetadata SnapshotDeserializer::Read() {
542541
result.node_version = ReadString();
543542
result.node_arch = ReadString();
544543
result.node_platform = ReadString();
545-
result.v8_cache_version_tag = ReadArithmetic<uint32_t>();
546544
result.flags = static_cast<SnapshotFlags>(ReadArithmetic<uint32_t>());
547545

548546
if (is_debug) {
@@ -570,9 +568,6 @@ size_t SnapshotSerializer::Write(const SnapshotMetadata& data) {
570568
written_total += WriteString(data.node_arch);
571569
Debug("Write Node.js platform %s\n", data.node_platform);
572570
written_total += WriteString(data.node_platform);
573-
Debug("Write V8 cached data version tag %" PRIx32 "\n",
574-
data.v8_cache_version_tag);
575-
written_total += WriteArithmetic<uint32_t>(data.v8_cache_version_tag);
576571
Debug("Write snapshot flags %" PRIx32 "\n",
577572
static_cast<uint32_t>(data.flags));
578573
written_total += WriteArithmetic<uint32_t>(static_cast<uint32_t>(data.flags));
@@ -697,23 +692,6 @@ bool SnapshotData::Check() const {
697692
return false;
698693
}
699694

700-
if (metadata.type == SnapshotMetadata::Type::kFullyCustomized &&
701-
!WithoutCodeCache(metadata.flags)) {
702-
uint32_t current_cache_version = v8::ScriptCompiler::CachedDataVersionTag();
703-
if (metadata.v8_cache_version_tag != current_cache_version) {
704-
// For now we only do this check for the customized snapshots - we know
705-
// that the flags we use in the default snapshot are limited and safe
706-
// enough so we can relax the constraints for it.
707-
fprintf(stderr,
708-
"Failed to load the startup snapshot because it was built with "
709-
"a different version of V8 or with different V8 configurations.\n"
710-
"Expected tag %" PRIx32 ", read %" PRIx32 "\n",
711-
current_cache_version,
712-
metadata.v8_cache_version_tag);
713-
return false;
714-
}
715-
}
716-
717695
// TODO(joyeecheung): check incompatible Node.js flags.
718696
return true;
719697
}
@@ -1180,7 +1158,6 @@ ExitCode SnapshotBuilder::CreateSnapshot(SnapshotData* out,
11801158
per_process::metadata.versions.node,
11811159
per_process::metadata.arch,
11821160
per_process::metadata.platform,
1183-
v8::ScriptCompiler::CachedDataVersionTag(),
11841161
config->flags};
11851162

11861163
// We cannot resurrect the handles from the snapshot, so make sure that

test/parallel/parallel.status

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ test-fs-read-stream-concurrent-reads: PASS, FLAKY
1919
# https://github.com/nodejs/node/issues/52630
2020
test-error-serdes: PASS, FLAKY
2121

22+
# Until V8 provides a better way to check for flag mismatch without
23+
# making the code cache/snapshot unreproducible, disable the test
24+
# for a preemptive check now. It should idealy fail more gracefully
25+
# with a better checking mechanism.
26+
# https://github.com/nodejs/build/issues/3043
27+
test-snapshot-incompatible: SKIP
28+
2229
[$system==win32]
2330

2431
# Windows on x86

0 commit comments

Comments
 (0)