Skip to content

Speed up parser by making it synchronous - #676

Merged
lydell merged 2 commits into
masterfrom
sync-parser
Jul 19, 2026
Merged

Speed up parser by making it synchronous#676
lydell merged 2 commits into
masterfrom
sync-parser

Conversation

@lydell

@lydell lydell commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Reading files asynchronously is slower than reading them synchronously. Async mostly makes sense when you are writing a server that needs to respond to many different requests simultaneously. But that’s not our use case.

Inspired by elm-watch, this PR switches from fs.createReadStream to fs.readSync with a buffer that we reuse. This makes parsing go almost 2x faster.

This also means that we no longer need the graceful-fs dependency.

Read the diff without whitespace changes since a few functions lost indentation.

@lydell
lydell merged commit 245a623 into master Jul 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant