sass/dart-sass

Use worker threads to implement render()

开放

#868 创建于 2019年10月30日

 (7 条评论) (8 个反应) (0 位负责人)Dart (376 个派生)batch import
JavaScriptenhancementhelp wanted

仓库指标

星标
 (4,192 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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.

贡献者指南