Changeset 263290 in webkit
- Timestamp:
- Jun 19, 2020, 3:13:47 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/jsc.cpp (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/Scripts/run-jsc-stress-tests (modified) (2 diffs)
-
Tools/Scripts/webkitruby/jsc-stress-test-writer-default.rb (modified) (1 diff)
-
Tools/Scripts/webkitruby/jsc-stress-test-writer-ruby.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r263283 r263290 1 2020-06-19 Saam Barati <sbarati@apple.com> 2 3 Have a memory monitor thread in jsc shell when running tests using --memory-limited 4 https://bugs.webkit.org/show_bug.cgi?id=213389 5 6 Reviewed by Mark Lam. 7 8 When testing on iOS, there are times high memory usage from a JSC test 9 will jetsam our entire test runner. This makes it so we don't get any test 10 results from that test run, which can make it difficult to track testing 11 results. 12 13 This patch introduces an optional memory monitoring thread to the JSC 14 shell. It's a best effort approach. If memory usage exceeds the passed 15 in threshold, we crash the process. Similar to how the timeout mechanism 16 works. On Cocoa platforms, we also perform this check in the low memory 17 warning handler. 18 19 Currently, we use this feature when running JSC stress tests in 20 "--memory-limited" mode. 21 22 * jsc.cpp: 23 (crashIfExceedingMemoryLimit): 24 (startMemoryMonitoringThreadIfNeeded): 25 (jscmain): 26 1 27 2020-06-19 Mark Lam <mark.lam@apple.com> 2 28 -
trunk/Source/JavaScriptCore/jsc.cpp
r263117 r263290 2497 2497 int jscmain(int argc, char** argv); 2498 2498 2499 #if OS(DARWIN) || OS(LINUX) 2500 static size_t memoryLimit; 2501 2502 static void crashIfExceedingMemoryLimit() 2503 { 2504 if (!memoryLimit) 2505 return; 2506 MemoryFootprint footprint = MemoryFootprint::now(); 2507 if (footprint.current > memoryLimit) { 2508 dataLogLn("Crashing because current footprint: ", footprint.current, " exceeds limit: ", memoryLimit); 2509 CRASH(); 2510 } 2511 } 2512 2513 static void startMemoryMonitoringThreadIfNeeded() 2514 { 2515 char* memoryLimitString = getenv("JSCTEST_memoryLimit"); 2516 if (!memoryLimitString) 2517 return; 2518 2519 if (sscanf(memoryLimitString, "%zu", &memoryLimit) != 1) { 2520 dataLogLn("WARNING: malformed JSCTEST_memoryLimit environment variable"); 2521 return; 2522 } 2523 2524 if (!memoryLimit) 2525 return; 2526 2527 Thread::create("jsc Memory Monitor", [=] { 2528 while (true) { 2529 sleep(Seconds::fromMilliseconds(5)); 2530 crashIfExceedingMemoryLimit(); 2531 } 2532 }); 2533 } 2534 #endif // OS(DARWIN) || OS(LINUX) 2535 2499 2536 static double s_desiredTimeout; 2500 2537 static double s_timeoutMultiplier = 1.0; … … 3254 3291 initializeTimeoutIfNeeded(); 3255 3292 3293 #if OS(DARWIN) || OS(LINUX) 3294 startMemoryMonitoringThreadIfNeeded(); 3295 #endif 3296 3256 3297 if (Options::useSuperSampler()) 3257 3298 enableSuperSampler(); … … 3277 3318 Box<Synchronous> memoryPressureSynchronousState = Box<Synchronous>::create(Synchronous::No); 3278 3319 memoryPressureHandler.setLowMemoryHandler([=] (Critical critical, Synchronous synchronous) { 3320 crashIfExceedingMemoryLimit(); 3321 3279 3322 // We set these racily with respect to reading them from the JS execution thread. 3280 3323 *memoryPressureCriticalState = critical; -
trunk/Tools/ChangeLog
r263275 r263290 1 2020-06-19 Saam Barati <sbarati@apple.com> 2 3 Have a memory monitor thread in jsc shell when running tests using --memory-limited 4 https://bugs.webkit.org/show_bug.cgi?id=213389 5 6 Reviewed by Mark Lam. 7 8 * Scripts/run-jsc-stress-tests: 9 * Scripts/webkitruby/jsc-stress-test-writer-default.rb: 10 * Scripts/webkitruby/jsc-stress-test-writer-ruby.rb: 11 1 12 2020-06-19 Chris Fleizach <cfleizach@apple.com> 2 13 -
trunk/Tools/Scripts/run-jsc-stress-tests
r263235 r263290 2092 2092 remoteScript += "export LD_LIBRARY_PATH=#{remoteHost.remoteDirectory}/#{$outputDir.basename}/#{$jscPath.dirname} && " 2093 2093 remoteScript += "export JSCTEST_timeout=#{Shellwords.shellescape(ENV['JSCTEST_timeout'])} && " 2094 remoteScript += "export JSCTEST_memoryLimit=#{Shellwords.shellescape(ENV['JSCTEST_memoryLimit'])} && " 2094 2095 remoteScript += "export TZ=#{Shellwords.shellescape(ENV['TZ'])} && " 2095 2096 $envVars.each { |var| remoteScript += "export " << var << "\n" } … … 2224 2225 end 2225 2226 2227 if !ENV["JSCTEST_memoryLimit"] && $memoryLimited 2228 ENV["JSCTEST_memoryLimit"] = (600 * 1024 * 1024).to_s 2229 end 2230 2226 2231 # Some tests fail if the time zone is not set to US/Pacific 2227 2232 # https://webkit.org/b/136363 -
trunk/Tools/Scripts/webkitruby/jsc-stress-test-writer-default.rb
r262991 r263290 257 257 script += "export DYLD_FRAMEWORK_PATH=$(cd #{$testingFrameworkPath.dirname}; pwd)\n" 258 258 script += "export JSCTEST_timeout=#{Shellwords.shellescape(ENV['JSCTEST_timeout'])}\n" 259 script += "export JSCTEST_memoryLimit=#{Shellwords.shellescape(ENV['JSCTEST_memoryLimit'])}\n" 259 260 $envVars.each { |var| script += "export " << var << "\n" } 260 261 script += "#{shellCommand} || exit 1" -
trunk/Tools/Scripts/webkitruby/jsc-stress-test-writer-ruby.rb
r262991 r263290 314 314 script += " ENV[\"DYLD_FRAMEWORK_PATH\"] = \"#{$testingFrameworkPath.dirname}\"\n" 315 315 script += " ENV[\"JSCTEST_timeout\"] = \"#{ENV['JSCTEST_timeout']}\"\n" 316 script += " ENV[\"JSCTEST_memoryLimit\"] = \"#{ENV['JSCTEST_memoryLimit']}\"\n" 316 317 317 318 script += " #{shellCommand}"
Note:
See TracChangeset
for help on using the changeset viewer.