Skip to content

Commit

Permalink
[0.71] Add checksum to ScriptStore cache (#11781)
Browse files Browse the repository at this point in the history
* Add a checksum to the script cache

* Change files

* Fix compilation for x86

* Fix x64 compilation

* Format code

* Update ScriptStoreTests for bigger working set.

* Cherry pick latest code from PR #11780

---------

Co-authored-by: Vladimir Morozov <vmorozov@microsoft.com>
  • Loading branch information
tudorms and vmoroz committed Jun 21, 2023
1 parent 2f07c96 commit fbe9982
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 106 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Add a checksum to the script cache",
"packageName": "react-native-windows",
"email": "tudor.mihai@microsoft.com",
"dependentChangeType": "patch"
}
10 changes: 7 additions & 3 deletions vnext/Desktop.UnitTests/ScriptStoreTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ TEST_CLASS (ScriptStoreIntegrationTest) {

constexpr size_t fileSize = 4 * 1024 * 1024;
std::vector<char> chars{};
chars.reserve(fileSize);
while (chars.size() < fileSize) {
chars.emplace_back(static_cast<char>('0' + chars.size() % 16));
}
Expand All @@ -55,8 +56,8 @@ TEST_CLASS (ScriptStoreIntegrationTest) {
auto startWorkingSet =
ProcessDiagnosticInfo::GetForCurrentProcess().MemoryUsage().GetReport().WorkingSetSizeInBytes();

auto prepd = preparedScriptStore->tryGetPreparedScript(scriptSignature, runtimeSignature, "prepareTag");
Assert::AreEqual(fileSize, prepd->size());
auto prepped = preparedScriptStore->tryGetPreparedScript(scriptSignature, runtimeSignature, "prepareTag");
Assert::AreEqual(fileSize, prepped->size());

auto endWorkingSet =
ProcessDiagnosticInfo::GetForCurrentProcess().MemoryUsage().GetReport().WorkingSetSizeInBytes();
Expand All @@ -65,7 +66,10 @@ TEST_CLASS (ScriptStoreIntegrationTest) {
// Without memory mapping: about 6.11 MB (fileSize + app overhead)
// With memory mapping: about 2.14 MB (view overhead + app overhead)
// Expected working set size should be lower than the actual file size, provided it is larger than the app overhead
Assert::IsTrue(endWorkingSet - startWorkingSet < fileSize);
//
// Update: PR #11781 adds hash evaluation for the whole file that requires reading all file data to memory.
// The working set is about 4.3 MB. It is about 10% above the file size.
Assert::IsTrue(endWorkingSet - startWorkingSet < fileSize * 1.1);
}
};
} // namespace Microsoft::JSI::Test
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"NETStandard.Library": "2.0.3"
}
},
"Microsoft.UI.Xaml": {
"type": "Direct",
"requested": "[2.7.0, )",
"resolved": "2.7.0",
"contentHash": "dB4im13tfmMgL/V3Ei+3kD2rUF+/lTxAmR4gjJ45l577eljHfdo/KUrxpq/3I1Vp6e5GCDG1evDaEGuDxypLMg=="
},
"MSTest.TestAdapter": {
"type": "Direct",
"requested": "[2.2.10, )",
Expand All @@ -44,11 +50,6 @@
"resolved": "13.0.1",
"contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A=="
},
"boost": {
"type": "Transitive",
"resolved": "1.76.0",
"contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA=="
},
"Microsoft.Net.Native.Compiler": {
"type": "Transitive",
"resolved": "2.2.7-rel-27913-00",
Expand All @@ -73,36 +74,21 @@
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
"resolved": "2.1.0",
"contentHash": "GmkKfoyerqmsHMn7OZj0AKpcBabD+GaafqphvX2Mw406IwiJRy1pKcKqdCfKJfYmkRyJ6+e+RaUylgdJoDa1jQ=="
"contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA=="
},
"Microsoft.NETCore.Targets": {
"type": "Transitive",
"resolved": "1.0.1",
"contentHash": "rkn+fKobF/cbWfnnfBOQHKVKIOpxMZBvlSHkqDWgBpwGDcLRduvs3D9OLGeV6GWGvVwNlVi2CBbTjuPmtHvyNw=="
},
"Microsoft.UI.Xaml": {
"type": "Transitive",
"resolved": "2.7.0",
"contentHash": "dB4im13tfmMgL/V3Ei+3kD2rUF+/lTxAmR4gjJ45l577eljHfdo/KUrxpq/3I1Vp6e5GCDG1evDaEGuDxypLMg=="
},
"Microsoft.Windows.SDK.BuildTools": {
"type": "Transitive",
"resolved": "10.0.22000.194",
"contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg=="
},
"NETStandard.Library": {
"type": "Transitive",
"resolved": "2.0.3",
"contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==",
"contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"ReactNative.Hermes.Windows": {
"type": "Transitive",
"resolved": "0.71.1",
"contentHash": "q38h/Gkw8d0pfUqIhRCd1j/XLhpQY4Hm7kSQthZUzetEST34acbR883/Eh+DKt4FVz9a0lh5kiAfP7piO768SA=="
},
"runtime.win10-arm.Microsoft.Net.Native.Compiler": {
"type": "Transitive",
"resolved": "2.2.7-rel-27913-00",
Expand Down Expand Up @@ -298,7 +284,6 @@
"folly": {
"type": "Project",
"dependencies": {
"boost": "[1.76.0, )",
"fmt": "[1.0.0, )"
}
},
Expand All @@ -307,11 +292,7 @@
"dependencies": {
"Common": "[1.0.0, )",
"Folly": "[1.0.0, )",
"Microsoft.UI.Xaml": "[2.7.0, )",
"Microsoft.Windows.SDK.BuildTools": "[10.0.22000.194, )",
"ReactCommon": "[1.0.0, )",
"ReactNative.Hermes.Windows": "[0.71.1, )",
"boost": "[1.76.0, )"
"ReactCommon": "[1.0.0, )"
}
},
"microsoft.reactnative.managed": {
Expand All @@ -324,8 +305,7 @@
"reactcommon": {
"type": "Project",
"dependencies": {
"Folly": "[1.0.0, )",
"boost": "[1.76.0, )"
"Folly": "[1.0.0, )"
}
}
},
Expand Down
40 changes: 10 additions & 30 deletions vnext/Microsoft.ReactNative.Managed.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"NETStandard.Library": "2.0.3"
}
},
"Microsoft.UI.Xaml": {
"type": "Direct",
"requested": "[2.7.0, )",
"resolved": "2.7.0",
"contentHash": "dB4im13tfmMgL/V3Ei+3kD2rUF+/lTxAmR4gjJ45l577eljHfdo/KUrxpq/3I1Vp6e5GCDG1evDaEGuDxypLMg=="
},
"MSTest.TestAdapter": {
"type": "Direct",
"requested": "[2.2.10, )",
Expand All @@ -44,11 +50,6 @@
"resolved": "13.0.1",
"contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A=="
},
"boost": {
"type": "Transitive",
"resolved": "1.76.0",
"contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA=="
},
"Microsoft.Net.Native.Compiler": {
"type": "Transitive",
"resolved": "2.2.7-rel-27913-00",
Expand All @@ -73,36 +74,21 @@
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
"resolved": "2.1.0",
"contentHash": "GmkKfoyerqmsHMn7OZj0AKpcBabD+GaafqphvX2Mw406IwiJRy1pKcKqdCfKJfYmkRyJ6+e+RaUylgdJoDa1jQ=="
"contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA=="
},
"Microsoft.NETCore.Targets": {
"type": "Transitive",
"resolved": "1.0.1",
"contentHash": "rkn+fKobF/cbWfnnfBOQHKVKIOpxMZBvlSHkqDWgBpwGDcLRduvs3D9OLGeV6GWGvVwNlVi2CBbTjuPmtHvyNw=="
},
"Microsoft.UI.Xaml": {
"type": "Transitive",
"resolved": "2.7.0",
"contentHash": "dB4im13tfmMgL/V3Ei+3kD2rUF+/lTxAmR4gjJ45l577eljHfdo/KUrxpq/3I1Vp6e5GCDG1evDaEGuDxypLMg=="
},
"Microsoft.Windows.SDK.BuildTools": {
"type": "Transitive",
"resolved": "10.0.22000.194",
"contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg=="
},
"NETStandard.Library": {
"type": "Transitive",
"resolved": "2.0.3",
"contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==",
"contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"ReactNative.Hermes.Windows": {
"type": "Transitive",
"resolved": "0.71.1",
"contentHash": "q38h/Gkw8d0pfUqIhRCd1j/XLhpQY4Hm7kSQthZUzetEST34acbR883/Eh+DKt4FVz9a0lh5kiAfP7piO768SA=="
},
"runtime.win10-arm.Microsoft.Net.Native.Compiler": {
"type": "Transitive",
"resolved": "2.2.7-rel-27913-00",
Expand Down Expand Up @@ -298,7 +284,6 @@
"folly": {
"type": "Project",
"dependencies": {
"boost": "[1.76.0, )",
"fmt": "[1.0.0, )"
}
},
Expand All @@ -307,11 +292,7 @@
"dependencies": {
"Common": "[1.0.0, )",
"Folly": "[1.0.0, )",
"Microsoft.UI.Xaml": "[2.7.0, )",
"Microsoft.Windows.SDK.BuildTools": "[10.0.22000.194, )",
"ReactCommon": "[1.0.0, )",
"ReactNative.Hermes.Windows": "[0.71.1, )",
"boost": "[1.76.0, )"
"ReactCommon": "[1.0.0, )"
}
},
"microsoft.reactnative.managed": {
Expand All @@ -324,8 +305,7 @@
"reactcommon": {
"type": "Project",
"dependencies": {
"Folly": "[1.0.0, )",
"boost": "[1.76.0, )"
"Folly": "[1.0.0, )"
}
}
},
Expand Down
34 changes: 4 additions & 30 deletions vnext/Microsoft.ReactNative.Managed/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
"Microsoft.SourceLink.Common": "1.0.0"
}
},
"boost": {
"type": "Transitive",
"resolved": "1.76.0",
"contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA=="
},
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "1.0.0",
Expand Down Expand Up @@ -58,36 +53,21 @@
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
"resolved": "2.1.0",
"contentHash": "GmkKfoyerqmsHMn7OZj0AKpcBabD+GaafqphvX2Mw406IwiJRy1pKcKqdCfKJfYmkRyJ6+e+RaUylgdJoDa1jQ=="
"contentHash": "ok+RPAtESz/9MUXeIEz6Lv5XAGQsaNmEYXMsgVALj4D7kqC8gveKWXWXbufLySR2fWrwZf8smyN5RmHu0e4BHA=="
},
"Microsoft.SourceLink.Common": {
"type": "Transitive",
"resolved": "1.0.0",
"contentHash": "G8DuQY8/DK5NN+3jm5wcMcd9QYD90UV7MiLmdljSJixi3U/vNaeBKmmXUqI4DJCOeWizIUEh4ALhSt58mR+5eg=="
},
"Microsoft.UI.Xaml": {
"type": "Transitive",
"resolved": "2.7.0",
"contentHash": "dB4im13tfmMgL/V3Ei+3kD2rUF+/lTxAmR4gjJ45l577eljHfdo/KUrxpq/3I1Vp6e5GCDG1evDaEGuDxypLMg=="
},
"Microsoft.Windows.SDK.BuildTools": {
"type": "Transitive",
"resolved": "10.0.22000.194",
"contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg=="
},
"NETStandard.Library": {
"type": "Transitive",
"resolved": "2.0.3",
"contentHash": "548M6mnBSJWxsIlkQHfbzoYxpiYFXZZSL00p4GHYv8PkiqFBnnT68mW5mGEsA/ch9fDO9GkPgkFQpWiXZN7mAQ==",
"contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"ReactNative.Hermes.Windows": {
"type": "Transitive",
"resolved": "0.71.1",
"contentHash": "q38h/Gkw8d0pfUqIhRCd1j/XLhpQY4Hm7kSQthZUzetEST34acbR883/Eh+DKt4FVz9a0lh5kiAfP7piO768SA=="
},
"runtime.win10-arm.Microsoft.Net.Native.Compiler": {
"type": "Transitive",
"resolved": "2.2.7-rel-27913-00",
Expand Down Expand Up @@ -164,7 +144,6 @@
"folly": {
"type": "Project",
"dependencies": {
"boost": "[1.76.0, )",
"fmt": "[1.0.0, )"
}
},
Expand All @@ -173,18 +152,13 @@
"dependencies": {
"Common": "[1.0.0, )",
"Folly": "[1.0.0, )",
"Microsoft.UI.Xaml": "[2.7.0, )",
"Microsoft.Windows.SDK.BuildTools": "[10.0.22000.194, )",
"ReactCommon": "[1.0.0, )",
"ReactNative.Hermes.Windows": "[0.71.1, )",
"boost": "[1.76.0, )"
"ReactCommon": "[1.0.0, )"
}
},
"reactcommon": {
"type": "Project",
"dependencies": {
"Folly": "[1.0.0, )",
"boost": "[1.76.0, )"
"Folly": "[1.0.0, )"
}
}
},
Expand Down

0 comments on commit fbe9982

Please sign in to comment.