Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discussion: how to make use of copy-on-write feature on JerryScript #516

Open
yorkie opened this issue May 1, 2019 · 0 comments
Open

discussion: how to make use of copy-on-write feature on JerryScript #516

yorkie opened this issue May 1, 2019 · 0 comments

Comments

@yorkie
Copy link
Member

yorkie commented May 1, 2019

JerryScript only owns the only 1 heap in total for all JavaScript objects and byte codes as possible. Assuming that no new byte code is generated, even there is many JavaScript objects are changed at this heap, such that we can't get most use of the copy-on-write improvements when using child process.

Background at YodaOS

And at YodaOS, the child_process module is used by creating the application, it should basically use the absolute independent instance JerryScript instance. It takes more time to fork and more unnecessary memory for built-ins and by-default packages like @yoda/property, @yodaos/mediaplayer and @yodaos/application.

So I'm proposing a way to make more sharable parts between VMs on different processes.

Heap API

We can introduce a heap API which provides create, destroy and freeze functions.

  • create() is to create the heap, and then are usable for VM.
  • destroy() is to flag this heap is destroyed, the new objects are not possible to use that, and the old objects should be migrated to others at next GC.
  • freeze() is to flag this heap is read-only at this timepoint, it'll do:
    • the last GC, to make sure there is no unneeded objects are still existed,
    • compress the memory layout and make this heap is compact as possible.
    • flag this heap is not able to create new object, every object from this heap should be created at another available unfrozen heaps.

Within the Heap API, the Node.js seed should create the seed heap, and load some usual packages for applications, then just call freeze(), then the forked processes could make use of these objects by the copy-on-write feature. However we have to resolve the following problems:

  • How to use the heaps(frozen) at JerryScript.
  • How to implement the object creations from the frozen heap to other heaps.
  • Maybe there are more memory leaks could be occurred at frozen heaps?
  • Other problems?

@yodaos-project/js @algebrait Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant