sass/dart-sass

Use worker threads to implement render()

Open

#868 aperta il 30 ott 2019

Vedi su GitHub
 (7 commenti) (8 reazioni) (0 assegnatari)Dart (376 fork)batch import
JavaScriptenhancementhelp wanted

Metriche repository

Star
 (4192 star)
Metriche merge PR
 (Merge medio 8g 8h) (18 PR mergiate in 30 g)

Descrizione

Currently, we implement the asynchronous render() method in Node.js in one of two ways:

  • By default, it's run through the AsyncEvaluator which is synchronized via code gen with the synchronous Evaluator. This is much slower than running synchronously, and imposes developer overhead by requiring synchronization.

  • If the user passes in a reference to the fibers package (which uses a C++ extension to add a coroutine-style asynchrony model to Node), we run the synchronous code path and use coroutines to call out to async helpers. This is as fast as running synchronously but requires the end user to opt in to a C++ compilation which may be difficult to compile.

Sass's business logic itself is fully synchronous, so we get no benefit from this asynchrony other than the ability to invoke asynchronous function and importer callbacks. I think we can avoid the downsides of both of these methods by running the whole Sass compiler in a worker thread and using Atomics.wait() to block that thread until the callback completes.

Guida contributor