Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cli compilations in parallel dart isolates #2078

Merged
merged 9 commits into from
Sep 9, 2023
Merged

Run cli compilations in parallel dart isolates #2078

merged 9 commits into from
Sep 9, 2023

Conversation

ntkme
Copy link
Contributor

@ntkme ntkme commented Sep 2, 2023

This PR enables parallel complications in isolates when running the pure dart version of sass cli.

$ sass --version
1.66.1
$ time sass bootstrap/scss:css
sass bootstrap/scss:css  0.39s user 0.06s system 99% cpu 0.450 total
$ sass --version
1.66.2-dev
$ time sass bootstrap/scss:css
sass bootstrap/scss:css  0.44s user 0.08s system 145% cpu 0.353 total

The goal of this PR is to improve the performance of https://github.com/rails/dartsass-rails, which invokes the cli directly.

@ntkme ntkme marked this pull request as ready for review September 5, 2023 02:29
@nex3 nex3 self-requested a review September 5, 2023 20:15
lib/src/executable/concurrent.dart Outdated Show resolved Hide resolved
lib/src/executable/concurrent.dart Outdated Show resolved Hide resolved
lib/src/executable/concurrent.dart Outdated Show resolved Hide resolved
lib/src/executable/concurrent/js.dart Outdated Show resolved Hide resolved
lib/src/executable/concurrent/js.dart Outdated Show resolved Hide resolved
lib/src/executable/concurrent/vm.dart Outdated Show resolved Hide resolved
lib/src/executable/watch.dart Outdated Show resolved Hide resolved
lib/src/executable/watch.dart Outdated Show resolved Hide resolved
lib/src/executable/watch.dart Outdated Show resolved Hide resolved
test/cli/shared/update.dart Show resolved Hide resolved
@ntkme ntkme requested a review from nex3 September 7, 2023 02:29
@nex3
Copy link
Contributor

nex3 commented Sep 8, 2023

@ntkme The test failure here suggests that we may need to print all messages in the main isolate to ensure they don't end up stepping on one another.

@ntkme
Copy link
Contributor Author

ntkme commented Sep 8, 2023

@nex3 I think the issue is that the internal implementation of print uses writeln, which actually write the line and newline character in two separate calls. I think by adding the newline character to the buffer and then use write instead of writeln, it should be able to avoid this issue.

@ntkme
Copy link
Contributor Author

ntkme commented Sep 8, 2023

@nex3 I put up small hack that overrides print for dart vm. Obviously it's not the most elegant solution but supposedly should work. I think a cleaner solution would be to add newline directly to all StringBuffers, and then replace all print with stdout.write.

Copy link
Contributor

@nex3 nex3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind filing an issue against the Dart SDK about print() not being thread-safe? It seems like the best way to fix that is probably in the SDK itself.

lib/src/io/vm.dart Outdated Show resolved Hide resolved
lib/src/io/vm.dart Outdated Show resolved Hide resolved
@ntkme
Copy link
Contributor Author

ntkme commented Sep 9, 2023

Would you mind filing an issue against the Dart SDK about print() not being thread-safe? It seems like the best way to fix that is probably in the SDK itself.

dart-lang/sdk#53471

@nex3 nex3 merged commit 77e208c into sass:main Sep 9, 2023
45 checks passed
@ntkme ntkme deleted the dart-cli-isolate branch September 9, 2023 01:29
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.

None yet

2 participants