Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Trigger GC when idle #77

Merged
merged 1 commit into from
Jun 15, 2016
Merged

Conversation

kunalspathak
Copy link
Member

Checklist
  • tests and code linting passes
  • the commit message follows commit guidelines
Affected core subsystem(s)

deps,src

Description of change

Chakracore has JsIdle API that a host can trigger to perform memory cleanp tasks whenever it is idle. In order to achieve this added a scheduler that will schedule idle GC in prepare queue after 1 second the last script execution started. When there are no more scripts to execute, task in prepare queue would get executed which will trigger JsIdle. JsIdle returns tickCount until there will be more idle work to do. It can also return maximum tickCount that signifies that there is no idle work to perform. Based on the return value of this API, decide whether there is a need
to reschedule another JsIdle or not.

With this implementation chakrashim takes dependency on libuv.

@kunalspathak
Copy link
Member Author

CC: @nodejs/node-chakracore

@@ -84,6 +86,9 @@ class IsolateShim {
void DisableExecution();
bool IsExeuctionDisabled();
void EnableExecution();
static inline bool ShouldScheduleIdleGc() {
return v8::g_shouldScheduleIdleGc;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this mostly immutable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

@curtisman
Copy link

LGTM

Added a task in prepare queue that will  schedule `IdleGC` task
if there is no idleGc task currently scheduled or if there was some
javascript script execution happened.
`IdleGC` will basically call [JsIdle](https://github.com/Microsoft/ChakraCore/wiki/JsIdle) and if it didn't succeed, it
will schedule another `IdleGC` task after (nextTick - currentTick) ms.
If this task succeeded, we don't have to do anything and next time
prepareQueue task will be executed, it will decide if it should
re-schedule `IdleGC` or not.

Also include flag `--off_idlegc` to turn idleGC feature off.

PR-URL: nodejs#77
Reviewed-By: Curtis Man <[email protected]>
@kunalspathak kunalspathak merged commit 1ec0729 into nodejs:chakracore-master Jun 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants