Mercurial > hg > graal-compiler
comparison src/share/vm/compiler/compileBroker.cpp @ 12324:510fbd28919c
8020151: PSR:PERF Large performance regressions when code cache is filled
Summary: Code cache sweeping based on method hotness; removed speculatively disconnect
Reviewed-by: kvn, iveresov
author | anoll |
---|---|
date | Fri, 27 Sep 2013 10:50:55 +0200 |
parents | 766fac3395d6 |
children | cefad50507d8 1e814e391ee8 |
comparison
equal
deleted
inserted
replaced
12323:c9ccd7b85f20 | 12324:510fbd28919c |
---|---|
632 // Get the next CompileTask from a CompileQueue | 632 // Get the next CompileTask from a CompileQueue |
633 CompileTask* CompileQueue::get() { | 633 CompileTask* CompileQueue::get() { |
634 NMethodSweeper::possibly_sweep(); | 634 NMethodSweeper::possibly_sweep(); |
635 | 635 |
636 MutexLocker locker(lock()); | 636 MutexLocker locker(lock()); |
637 // Wait for an available CompileTask. | 637 // If _first is NULL we have no more compile jobs. There are two reasons for |
638 // having no compile jobs: First, we compiled everything we wanted. Second, | |
639 // we ran out of code cache so compilation has been disabled. In the latter | |
640 // case we perform code cache sweeps to free memory such that we can re-enable | |
641 // compilation. | |
638 while (_first == NULL) { | 642 while (_first == NULL) { |
639 // There is no work to be done right now. Wait. | 643 if (UseCodeCacheFlushing && !CompileBroker::should_compile_new_jobs()) { |
640 if (UseCodeCacheFlushing && (!CompileBroker::should_compile_new_jobs() || CodeCache::needs_flushing())) { | 644 // Wait a certain amount of time to possibly do another sweep. |
641 // During the emergency sweeping periods, wake up and sweep occasionally | 645 // We must wait until stack scanning has happened so that we can |
642 bool timedout = lock()->wait(!Mutex::_no_safepoint_check_flag, NmethodSweepCheckInterval*1000); | 646 // transition a method's state from 'not_entrant' to 'zombie'. |
643 if (timedout) { | 647 long wait_time = NmethodSweepCheckInterval * 1000; |
648 if (FLAG_IS_DEFAULT(NmethodSweepCheckInterval)) { | |
649 // Only one thread at a time can do sweeping. Scale the | |
650 // wait time according to the number of compiler threads. | |
651 // As a result, the next sweep is likely to happen every 100ms | |
652 // with an arbitrary number of threads that do sweeping. | |
653 wait_time = 100 * CICompilerCount; | |
654 } | |
655 bool timeout = lock()->wait(!Mutex::_no_safepoint_check_flag, wait_time); | |
656 if (timeout) { | |
644 MutexUnlocker ul(lock()); | 657 MutexUnlocker ul(lock()); |
645 // When otherwise not busy, run nmethod sweeping | |
646 NMethodSweeper::possibly_sweep(); | 658 NMethodSweeper::possibly_sweep(); |
647 } | 659 } |
648 } else { | 660 } else { |
649 // During normal operation no need to wake up on timer | 661 // If there are no compilation tasks and we can compile new jobs |
662 // (i.e., there is enough free space in the code cache) there is | |
663 // no need to invoke the sweeper. As a result, the hotness of methods | |
664 // remains unchanged. This behavior is desired, since we want to keep | |
665 // the stable state, i.e., we do not want to evict methods from the | |
666 // code cache if it is unnecessary. | |
650 lock()->wait(); | 667 lock()->wait(); |
651 } | 668 } |
652 } | 669 } |
653 CompileTask* task = CompilationPolicy::policy()->select_task(this); | 670 CompileTask* task = CompilationPolicy::policy()->select_task(this); |
654 remove(task); | 671 remove(task); |
1225 if (method_code != NULL) { | 1242 if (method_code != NULL) { |
1226 if (compilation_is_complete(method, osr_bci, comp_level)) { | 1243 if (compilation_is_complete(method, osr_bci, comp_level)) { |
1227 return method_code; | 1244 return method_code; |
1228 } | 1245 } |
1229 } | 1246 } |
1230 if (method->is_not_compilable(comp_level)) return NULL; | 1247 if (method->is_not_compilable(comp_level)) { |
1231 | 1248 return NULL; |
1232 if (UseCodeCacheFlushing) { | 1249 } |
1233 nmethod* saved = CodeCache::reanimate_saved_code(method()); | |
1234 if (saved != NULL) { | |
1235 method->set_code(method, saved); | |
1236 return saved; | |
1237 } | |
1238 } | |
1239 | |
1240 } else { | 1250 } else { |
1241 // osr compilation | 1251 // osr compilation |
1242 #ifndef TIERED | 1252 #ifndef TIERED |
1243 // seems like an assert of dubious value | 1253 // seems like an assert of dubious value |
1244 assert(comp_level == CompLevel_highest_tier, | 1254 assert(comp_level == CompLevel_highest_tier, |
1583 HandleMark hm(thread); | 1593 HandleMark hm(thread); |
1584 | 1594 |
1585 if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) { | 1595 if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) { |
1586 // the code cache is really full | 1596 // the code cache is really full |
1587 handle_full_code_cache(); | 1597 handle_full_code_cache(); |
1588 } else if (UseCodeCacheFlushing && CodeCache::needs_flushing()) { | |
1589 // Attempt to start cleaning the code cache while there is still a little headroom | |
1590 NMethodSweeper::handle_full_code_cache(false); | |
1591 } | 1598 } |
1592 | 1599 |
1593 CompileTask* task = queue->get(); | 1600 CompileTask* task = queue->get(); |
1594 | 1601 |
1595 // Give compiler threads an extra quanta. They tend to be bursty and | 1602 // Give compiler threads an extra quanta. They tend to be bursty and |
1941 exit_globals(); // will delete tty | 1948 exit_globals(); // will delete tty |
1942 vm_direct_exit(CompileTheWorld ? 0 : 1); | 1949 vm_direct_exit(CompileTheWorld ? 0 : 1); |
1943 } | 1950 } |
1944 #endif | 1951 #endif |
1945 if (UseCodeCacheFlushing) { | 1952 if (UseCodeCacheFlushing) { |
1946 NMethodSweeper::handle_full_code_cache(true); | 1953 // Since code cache is full, immediately stop new compiles |
1954 if (CompileBroker::set_should_compile_new_jobs(CompileBroker::stop_compilation)) { | |
1955 NMethodSweeper::log_sweep("disable_compiler"); | |
1956 NMethodSweeper::possibly_sweep(); | |
1957 } | |
1947 } else { | 1958 } else { |
1948 UseCompiler = false; | 1959 UseCompiler = false; |
1949 AlwaysCompileLoopMethods = false; | 1960 AlwaysCompileLoopMethods = false; |
1950 } | 1961 } |
1951 } | 1962 } |