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

worker: initial implementation #20876

Closed
wants to merge 26 commits into from
Closed

Commits on Jun 5, 2018

  1. src: cleanup per-isolate state on platform on isolate unregister

    Clean up once all references to an `Isolate*` are gone from the
    `NodePlatform`, rather than waiting for the `PerIsolatePlatformData`
    struct to be deleted since there may be cyclic references between
    that struct and the individual tasks.
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    f0ded20 View commit details
    Browse the repository at this point in the history
  2. src: remove unused fields isolate_

    Currently the following compiler warnings are generated:
    
    In file included from ../src/node_platform.cc:1:
    ../src/node_platform.h:83:16:
    warning: private field 'isolate_' is not used [-Wunused-private-field]
      v8::Isolate* isolate_;
                   ^
    1 warning generated.
    
    This commit removes these unused private member.
    danbev authored and addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    2bb055b View commit details
    Browse the repository at this point in the history
  3. src: simplify handle closing

    Remove one extra closing state and use a smart pointer for
    deleting `HandleWrap`s.
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    e7695cc View commit details
    Browse the repository at this point in the history
  4. src: make handle onclose property a Symbol

    This makes the property “more” hidden when exposing a `HandleWrap`
    as public API, e.g. for upcoming `MessagePort`s.
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    6d4931a View commit details
    Browse the repository at this point in the history
  5. worker: implement MessagePort and MessageChannel

    Implement `MessagePort` and `MessageChannel` along the lines of
    the DOM classes of the same names. `MessagePort`s initially
    support transferring only `ArrayBuffer`s.
    
    Thanks to Stephen Belanger for reviewing this change in its
    original form, to Benjamin Gruenbaum for reviewing the
    added tests in their original form, and to Olivia Hugger
    for reviewing the documentation in its original form.
    
    Refs: ayojs/ayo#98
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    315efb5 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f2e297b View commit details
    Browse the repository at this point in the history
  7. worker: support MessagePort passing in messages

    Support passing `MessagePort` instances through other `MessagePort`s,
    as expected by the `MessagePort` spec.
    
    Thanks to Stephen Belanger for reviewing this change in its original PR.
    
    Refs: ayojs/ayo#106
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    ef24c5c View commit details
    Browse the repository at this point in the history
  8. worker: add SharedArrayBuffer sharing

    Logic is added to the `MessagePort` mechanism that
    attaches hidden objects to those instances when they are transferred
    that track their lifetime and maintain a reference count, to make
    sure that memory is freed at the appropriate times.
    
    Thanks to Stephen Belanger for reviewing this change in its original PR.
    
    Refs: ayojs/ayo#106
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    a57c54f View commit details
    Browse the repository at this point in the history
  9. src: remove unused fields msg_ and env_

    Currently the following compiler warnings are generated:
    
    ../src/node_messaging.cc:74:16:
    warning: private field 'env_' is not used [-Wunused-private-field]
      Environment* env_;
                   ^
    ../src/node_messaging.cc:75:12:
    warning: private field 'msg_' is not used [-Wunused-private-field]
      Message* msg_;
               ^
    2 warnings generated.
    
    This commit removes these unused private members.
    danbev authored and addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    ca0edc1 View commit details
    Browse the repository at this point in the history
  10. src: add Env::profiler_idle_notifier_started()

    Refs: ayojs/ayo#93
    Reviewed-By: Anna Henningsen <[email protected]>
    Reviewed-By: Stephen Belanger <[email protected]>
    TimothyGu authored and addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    d2d9061 View commit details
    Browse the repository at this point in the history
  11. worker: initial implementation

    Implement multi-threading support for most of the API.
    
    Thanks to Stephen Belanger for reviewing this change in its
    original form, to Olivia Hugger for reviewing the
    documentation and some of the tests coming along with it,
    and to Alexey Orlenko and Timothy Gu for reviewing other
    parts of the tests.
    
    Refs: ayojs/ayo#110
    Refs: ayojs/ayo#114
    Refs: ayojs/ayo#117
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    0c7012e View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    396d785 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    65d4542 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    d0535eb View commit details
    Browse the repository at this point in the history
  15. test: add test against unsupported worker features

    Refs: ayojs/ayo#113
    Reviewed-By: Anna Henningsen <[email protected]>
    TimothyGu authored and addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    17e01a2 View commit details
    Browse the repository at this point in the history
  16. worker: restrict supported extensions

    Only allow `.js` and `.mjs` extensions to provide future-proofing
    for file type detection.
    
    Refs: ayojs/ayo#117
    Reviewed-By: Stephen Belanger <[email protected]>
    Reviewed-By: Olivia Hugger <[email protected]>
    Reviewed-By: Anna Henningsen <[email protected]>
    TimothyGu authored and addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    53b660b View commit details
    Browse the repository at this point in the history
  17. worker: enable stdio

    Provide `stdin`, `stdout` and `stderr` options for the `Worker`
    constructor, and make these available to the worker thread
    under their usual names.
    
    The default for `stdin` is an empty stream, the default for
    `stdout` and `stderr` is redirecting to the parent thread’s
    corresponding stdio streams.
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    004075b View commit details
    Browse the repository at this point in the history
  18. benchmark: port cluster/echo to worker

        $ ./node benchmark/cluster/echo.js
        cluster/echo.js n=100000 sendsPerBroadcast=1 payload="string" workers=1: 33,647.30473442063
        cluster/echo.js n=100000 sendsPerBroadcast=10 payload="string" workers=1: 12,927.907405288383
        cluster/echo.js n=100000 sendsPerBroadcast=1 payload="object" workers=1: 28,496.37373941151
        cluster/echo.js n=100000 sendsPerBroadcast=10 payload="object" workers=1: 8,975.53747186485
        $ ./node --experimental-worker benchmark/worker/echo.js
        worker/echo.js n=100000 sendsPerBroadcast=1 payload="string" workers=1: 88,044.32902365089
        worker/echo.js n=100000 sendsPerBroadcast=10 payload="string" workers=1: 39,873.33697018837
        worker/echo.js n=100000 sendsPerBroadcast=1 payload="object" workers=1: 64,451.29132425621
        worker/echo.js n=100000 sendsPerBroadcast=10 payload="object" workers=1: 22,325.635443739284
    
    Refs: ayojs/ayo#115
    Reviewed-By: Anna Henningsen <[email protected]>
    TimothyGu authored and addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    d44594d View commit details
    Browse the repository at this point in the history
  19. worker: improve error (de)serialization

    Rather than passing errors using some sort of string representation,
    do a best effort for faithful serialization/deserialization of
    uncaught exception objects.
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    fa53bd5 View commit details
    Browse the repository at this point in the history
  20. test,tools: enable running tests under workers

    Enable running tests inside workers by passing `--worker`
    to `tools/test.py`. A number of tests are marked as skipped,
    or have been slightly altered to fit the different environment.
    addaleax committed Jun 5, 2018
    Configuration menu
    Copy the full SHA
    79970f3 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    168d8a6 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    a12f76f View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    ab02dbc View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    2947dea View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    735227e View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    cbbddea View commit details
    Browse the repository at this point in the history