Skip to content

Commit

Permalink
[JIT] trigger code cache sweep periodly
Browse files Browse the repository at this point in the history
Summary:
Trigger code cache sweep periodly to recovert jit quickly

Test Plan: jittest case

Reviewed-by: yueshi.zwj, zhuoren.wz

Issue: dragonwell-project/dragonwell8#285

CR:
  • Loading branch information
kuaiwei committed Jan 20, 2022
1 parent 4d433ef commit 5ed8f2e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/share/vm/runtime/globals_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@
\
diagnostic(ccstr, ClassLoaderModuleFieldName, "moduleName", \
"For distinguishing the instances of class loader") \

\
product(intx, CodeSweeperTriggerTime, 0, \
"code sweeper trigger period time (in seconds, " \
"0 means disable periodly trigger)" ) \
\
//add new AJVM specific flags here


Expand Down
20 changes: 20 additions & 0 deletions src/share/vm/runtime/sweeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "runtime/orderAccess.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/sweeper.hpp"
#include "runtime/task.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/vm_operations.hpp"
#include "utilities/events.hpp"
Expand Down Expand Up @@ -674,3 +675,22 @@ void NMethodSweeper::print() {
_total_nof_c2_methods_reclaimed);
tty->print_cr(" Total size of flushed methods: " SIZE_FORMAT "kB", _total_flushed_size/K);
}

// support trigger code cache sweeper periodly
class SweepTask : public PeriodicTask {
public:
SweepTask() : PeriodicTask(CodeSweeperTriggerTime * 1000) {}
void task() {
VM_ForceSafepoint op;
VMThread::execute(&op);
}
};

void NMethodSweeper::periodly_sweep() {
if (!UseCodeCacheFlushing || CodeSweeperTriggerTime <= 0) {
return;
}

SweepTask *task = new SweepTask();
task->enroll();
}
1 change: 1 addition & 0 deletions src/share/vm/runtime/sweeper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class NMethodSweeper : public AllStatic {
static const Tickspan peak_sweep_time() { return _peak_sweep_time; }
static const Tickspan peak_sweep_fraction_time() { return _peak_sweep_fraction_time; }
static void log_sweep(const char* msg, const char* format = NULL, ...) ATTRIBUTE_PRINTF(2, 3);
static void periodly_sweep();

#ifdef ASSERT
static bool is_sweeping(nmethod* which) { return _current == which; }
Expand Down
2 changes: 2 additions & 0 deletions src/share/vm/runtime/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "runtime/sharedRuntime.hpp"
#include "runtime/statSampler.hpp"
#include "runtime/stubRoutines.hpp"
#include "runtime/sweeper.hpp"
#include "runtime/task.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/threadCritical.hpp"
Expand Down Expand Up @@ -4113,6 +4114,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
call_initializeJGroupClass(CHECK_0);
}
#endif
NMethodSweeper::periodly_sweep();

create_vm_timer.end();
#ifdef ASSERT
Expand Down

0 comments on commit 5ed8f2e

Please sign in to comment.