Title: [263290] trunk
- Revision
- 263290
- Author
- [email protected]
- Date
- 2020-06-19 15:13:47 -0700 (Fri, 19 Jun 2020)
Log Message
Have a memory monitor thread in jsc shell when running tests using --memory-limited
https://bugs.webkit.org/show_bug.cgi?id=213389
Reviewed by Mark Lam.
Source/_javascript_Core:
When testing on iOS, there are times high memory usage from a JSC test
will jetsam our entire test runner. This makes it so we don't get any test
results from that test run, which can make it difficult to track testing
results.
This patch introduces an optional memory monitoring thread to the JSC
shell. It's a best effort approach. If memory usage exceeds the passed
in threshold, we crash the process. Similar to how the timeout mechanism
works. On Cocoa platforms, we also perform this check in the low memory
warning handler.
Currently, we use this feature when running JSC stress tests in
"--memory-limited" mode.
* jsc.cpp:
(crashIfExceedingMemoryLimit):
(startMemoryMonitoringThreadIfNeeded):
(jscmain):
Tools:
* Scripts/run-jsc-stress-tests:
* Scripts/webkitruby/jsc-stress-test-writer-default.rb:
* Scripts/webkitruby/jsc-stress-test-writer-ruby.rb:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (263289 => 263290)
--- trunk/Source/_javascript_Core/ChangeLog 2020-06-19 21:43:17 UTC (rev 263289)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-06-19 22:13:47 UTC (rev 263290)
@@ -1,3 +1,29 @@
+2020-06-19 Saam Barati <[email protected]>
+
+ Have a memory monitor thread in jsc shell when running tests using --memory-limited
+ https://bugs.webkit.org/show_bug.cgi?id=213389
+
+ Reviewed by Mark Lam.
+
+ When testing on iOS, there are times high memory usage from a JSC test
+ will jetsam our entire test runner. This makes it so we don't get any test
+ results from that test run, which can make it difficult to track testing
+ results.
+
+ This patch introduces an optional memory monitoring thread to the JSC
+ shell. It's a best effort approach. If memory usage exceeds the passed
+ in threshold, we crash the process. Similar to how the timeout mechanism
+ works. On Cocoa platforms, we also perform this check in the low memory
+ warning handler.
+
+ Currently, we use this feature when running JSC stress tests in
+ "--memory-limited" mode.
+
+ * jsc.cpp:
+ (crashIfExceedingMemoryLimit):
+ (startMemoryMonitoringThreadIfNeeded):
+ (jscmain):
+
2020-06-19 Mark Lam <[email protected]>
Make $vm properties non-configurable, non-enumerable, and non-writable.
Modified: trunk/Source/_javascript_Core/jsc.cpp (263289 => 263290)
--- trunk/Source/_javascript_Core/jsc.cpp 2020-06-19 21:43:17 UTC (rev 263289)
+++ trunk/Source/_javascript_Core/jsc.cpp 2020-06-19 22:13:47 UTC (rev 263290)
@@ -2496,6 +2496,43 @@
int jscmain(int argc, char** argv);
+#if OS(DARWIN) || OS(LINUX)
+static size_t memoryLimit;
+
+static void crashIfExceedingMemoryLimit()
+{
+ if (!memoryLimit)
+ return;
+ MemoryFootprint footprint = MemoryFootprint::now();
+ if (footprint.current > memoryLimit) {
+ dataLogLn("Crashing because current footprint: ", footprint.current, " exceeds limit: ", memoryLimit);
+ CRASH();
+ }
+}
+
+static void startMemoryMonitoringThreadIfNeeded()
+{
+ char* memoryLimitString = getenv("JSCTEST_memoryLimit");
+ if (!memoryLimitString)
+ return;
+
+ if (sscanf(memoryLimitString, "%zu", &memoryLimit) != 1) {
+ dataLogLn("WARNING: malformed JSCTEST_memoryLimit environment variable");
+ return;
+ }
+
+ if (!memoryLimit)
+ return;
+
+ Thread::create("jsc Memory Monitor", [=] {
+ while (true) {
+ sleep(Seconds::fromMilliseconds(5));
+ crashIfExceedingMemoryLimit();
+ }
+ });
+}
+#endif // OS(DARWIN) || OS(LINUX)
+
static double s_desiredTimeout;
static double s_timeoutMultiplier = 1.0;
static Seconds s_timeoutDuration;
@@ -3253,6 +3290,10 @@
JSC::initializeThreading();
initializeTimeoutIfNeeded();
+#if OS(DARWIN) || OS(LINUX)
+ startMemoryMonitoringThreadIfNeeded();
+#endif
+
if (Options::useSuperSampler())
enableSuperSampler();
@@ -3276,6 +3317,8 @@
Box<Critical> memoryPressureCriticalState = Box<Critical>::create(Critical::No);
Box<Synchronous> memoryPressureSynchronousState = Box<Synchronous>::create(Synchronous::No);
memoryPressureHandler.setLowMemoryHandler([=] (Critical critical, Synchronous synchronous) {
+ crashIfExceedingMemoryLimit();
+
// We set these racily with respect to reading them from the JS execution thread.
*memoryPressureCriticalState = critical;
*memoryPressureSynchronousState = synchronous;
Modified: trunk/Tools/ChangeLog (263289 => 263290)
--- trunk/Tools/ChangeLog 2020-06-19 21:43:17 UTC (rev 263289)
+++ trunk/Tools/ChangeLog 2020-06-19 22:13:47 UTC (rev 263290)
@@ -1,3 +1,14 @@
+2020-06-19 Saam Barati <[email protected]>
+
+ Have a memory monitor thread in jsc shell when running tests using --memory-limited
+ https://bugs.webkit.org/show_bug.cgi?id=213389
+
+ Reviewed by Mark Lam.
+
+ * Scripts/run-jsc-stress-tests:
+ * Scripts/webkitruby/jsc-stress-test-writer-default.rb:
+ * Scripts/webkitruby/jsc-stress-test-writer-ruby.rb:
+
2020-06-19 Chris Fleizach <[email protected]>
AX: Make isolated tree enablement status dependent on client preference
Modified: trunk/Tools/Scripts/run-jsc-stress-tests (263289 => 263290)
--- trunk/Tools/Scripts/run-jsc-stress-tests 2020-06-19 21:43:17 UTC (rev 263289)
+++ trunk/Tools/Scripts/run-jsc-stress-tests 2020-06-19 22:13:47 UTC (rev 263290)
@@ -2091,6 +2091,7 @@
remoteScript += "export DYLD_FRAMEWORK_PATH=\\\"\\$(cd #{$testingFrameworkPath.dirname}; pwd)\\\" && "
remoteScript += "export LD_LIBRARY_PATH=#{remoteHost.remoteDirectory}/#{$outputDir.basename}/#{$jscPath.dirname} && "
remoteScript += "export JSCTEST_timeout=#{Shellwords.shellescape(ENV['JSCTEST_timeout'])} && "
+ remoteScript += "export JSCTEST_memoryLimit=#{Shellwords.shellescape(ENV['JSCTEST_memoryLimit'])} && "
remoteScript += "export TZ=#{Shellwords.shellescape(ENV['TZ'])} && "
$envVars.each { |var| remoteScript += "export " << var << "\n" }
remoteScript += "#{testRunnerCommand(remoteIndex)}\""
@@ -2223,6 +2224,10 @@
ENV["JSCTEST_timeout"] = (ENV["JSCTEST_timeout"].to_i.to_f * Math.sqrt($numChildProcesses)).to_i.to_s
end
+if !ENV["JSCTEST_memoryLimit"] && $memoryLimited
+ ENV["JSCTEST_memoryLimit"] = (600 * 1024 * 1024).to_s
+end
+
# Some tests fail if the time zone is not set to US/Pacific
# https://webkit.org/b/136363
# Set as done in run-_javascript_-tests
Modified: trunk/Tools/Scripts/webkitruby/jsc-stress-test-writer-default.rb (263289 => 263290)
--- trunk/Tools/Scripts/webkitruby/jsc-stress-test-writer-default.rb 2020-06-19 21:43:17 UTC (rev 263289)
+++ trunk/Tools/Scripts/webkitruby/jsc-stress-test-writer-default.rb 2020-06-19 22:13:47 UTC (rev 263290)
@@ -256,6 +256,7 @@
script += "export DYLD_FRAMEWORK_PATH=$(cd #{$testingFrameworkPath.dirname}; pwd)\n"
script += "export JSCTEST_timeout=#{Shellwords.shellescape(ENV['JSCTEST_timeout'])}\n"
+ script += "export JSCTEST_memoryLimit=#{Shellwords.shellescape(ENV['JSCTEST_memoryLimit'])}\n"
$envVars.each { |var| script += "export " << var << "\n" }
script += "#{shellCommand} || exit 1"
"echo #{Shellwords.shellescape(script)} > #{Shellwords.shellescape((Pathname.new("..") + @name).to_s)}"
Modified: trunk/Tools/Scripts/webkitruby/jsc-stress-test-writer-ruby.rb (263289 => 263290)
--- trunk/Tools/Scripts/webkitruby/jsc-stress-test-writer-ruby.rb 2020-06-19 21:43:17 UTC (rev 263289)
+++ trunk/Tools/Scripts/webkitruby/jsc-stress-test-writer-ruby.rb 2020-06-19 22:13:47 UTC (rev 263290)
@@ -313,6 +313,7 @@
script += "/.runner\") do\n"
script += " ENV[\"DYLD_FRAMEWORK_PATH\"] = \"#{$testingFrameworkPath.dirname}\"\n"
script += " ENV[\"JSCTEST_timeout\"] = \"#{ENV['JSCTEST_timeout']}\"\n"
+ script += " ENV[\"JSCTEST_memoryLimit\"] = \"#{ENV['JSCTEST_memoryLimit']}\"\n"
script += " #{shellCommand}"
script += " print out\n"
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes