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

stream: sync writes don't need drain #29087

Closed
wants to merge 1 commit into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Aug 11, 2019

Minor fix and performance improvement. Synchronous writes do not require drain.

This can be a significant improvement especially for transform streams that do not perform any async work.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

NOTE TO SELF: Sync transform streams should have a no buffer option (i.e. hwm === 0).

@nodejs-github-bot nodejs-github-bot added the stream Issues and PRs related to the stream subsystem. label Aug 11, 2019
@ronag ronag force-pushed the stream-sync-write-drain branch 3 times, most recently from ea33898 to 3412764 Compare August 11, 2019 17:25
@Trott
Copy link
Member

Trott commented Aug 13, 2019

@nodejs/streams

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Good work! I agree that this is going to make things faster (however we will need benchmarks), but this is likely going to break users in many ways.

We can see this in the tests, where a bunch of nextTick had to be added. Do you think it would be possible to make this backward compatible?

@mcollina mcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Aug 14, 2019
@ronag
Copy link
Member Author

ronag commented Aug 14, 2019

@mcollina: I'm unsure how bad of a breaking change this actually is. The test "wrongly" assume that 'drain' will be emitted. I can't imagine much logic out in the wild that depends on that behaviour for anything but resume().

That being said. The only "fully" backwards compatible way I can think of is to do this as a hack for pipe(). Where this optimization is only applied when using pipe()? Or do you have any other ideas?

@mcollina
Copy link
Member

Then I think we should not implement this. We might decide to bring https://www.npmjs.com/package/syncthrough into core, as it solves the same problem in a non-breaking way.

@ronag
Copy link
Member Author

ronag commented Aug 15, 2019

@mcollina: Fair enough... feel free to close

@mcollina mcollina closed this Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major PRs that contain breaking changes and should be released in the next major version. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants