Skip to content

Lite Thread Worker

AaronLee edited this page May 16, 2018 · 7 revisions

What did we do?

Goals

We want to use multithreads which capable of executing js and has node ability in node.js.

We want to use Web Worker API.

We want to share data or code which is not tied to thread context between those threads to keep worker thread lightweight.

Introduction

We propose this project to achieve our goals and implement it as soon as possible, so maybe it seems like a prototype.

We have fixed most of the bugs and it works well in our system currently.

There are some differences between the code here and the code we use in our system.

We haven't merge node snapshot to lite thread worker here, which will speed up the boot of the thread worker.

Additional details in Thread Worker in Node.js

How to try it?

OS: linux-64bit (We will support macOS later)

Arch: x64, arm (We will support x86 and arm64 later)

fetch the code

git clone https://github.com/alibaba/AliOS-nodejs.git

git checkout --track origin/dev_lite_thread_worker

configure & compile

gcc: 4.9 or higher

./configure --dest-cpu=x64

make -j n or make

How to use lite thread worker

We use the api which is almost the same with Web Worker API.

We just use "ThreadWorker" instead of "Worker" currently because we haven't found a proper name.

You can find basic usage here: test/thread-worker

Additional details in API.

Test

In node

python tools/test.py --mode=release thread-worker

In v8

We implement worker in d8 and it has a fake message loop there.

cd deps/v8

make x64.release.check