Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Modernize LessCache and make its interface asynchronous#13

Closed
as-cii wants to merge 11 commits intomasterfrom
as-async
Closed

Modernize LessCache and make its interface asynchronous#13
as-cii wants to merge 11 commits intomasterfrom
as-async

Conversation

@as-cii
Copy link
Contributor

@as-cii as-cii commented Mar 13, 2017

This pull request rewrites LessCache in JavaScript and exposes a new Promise-based API that won't block the event loop when reading from or writing to the cache.

Please, note that we will still parse less files and read their imports synchronously: this is somewhat unfortunate, but adapting the ImportManager from less.js to allow us to determine imports is non-trivial and, even though some work has already been done in #11, for now it just feels simpler to access only the cache asynchronously and rely on #12 to minimize other I/O.

/cc: @nathansobo

@as-cii
Copy link
Contributor Author

as-cii commented Mar 14, 2017

After integrating this into Atom and thinking about it more, I have realized that making the interface asynchronous doesn't improve caching throughput significantly and, as a result, is not worth the added complexity.

There are other ways in which we can improve performance and that I will address in a couple of forthcoming pull requests:

  1. Provide a cache for file paths inside import paths. This will avoid 4 directory traversals for default themes, and 2 directory traversals for non-default ones.
  2. Cache the files' digest along with their contents. This will minimize all the CPU time spent for hashing file contents.
  3. Cache Package.getStylesheetPaths for bundled packages. This will minimize the I/O involved in scanning each package when we look for style sheets.

After the above improvements land, I think we should go on and start moving other I/O and CPU work into the snapshot, such as setting each package's config schema and loading their settings files. Then, we can address packages preloading and fix other low hanging fruits, like waiting synchronously on GitRepository.openSubmodules.

@as-cii as-cii closed this Mar 14, 2017
@as-cii as-cii deleted the as-async branch March 14, 2017 10:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments