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

http: make http.OutgoingMessage inherit Stream.Writable #33870

Closed

Conversation

rexagod
Copy link
Member

@rexagod rexagod commented Jun 14, 2020

Fixes: #28971

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

@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Jun 14, 2020
@rexagod
Copy link
Member Author

rexagod commented Jun 14, 2020

After these changes, properties that are present:

  • Only on Writable.prototype:
[
  '_destroy',
  '_undestroy',
  '_write',
  '_writev',
  'setDefaultEncoding',
  'writableBuffer'
]
  • Only on OutgoingMessage.prototype:
[
  '_finish',        '_flush',
  '_flushOutput',   '_headerNames',
  '_headers',       '_implicitHeader',
  '_renderHeaders', '_send',
  '_storeHeader',   '_writeRaw',
  'addTrailers',    'connection',
  'flushHeaders',   'getHeader',
  'getHeaderNames', 'getHeaders',
  'hasHeader',      'headersSent',
  'removeHeader',   'setHeader',
  'setTimeout'
]
  • Common to both of their prototypes (and overridden by Outgoing.prototype):
[
  'constructor',
  'cork',
  'destroy',
  'destroyed',
  'end',
  'pipe',
  'uncork',
  'writable',
  'writableCorked',
  'writableEnded',
  'writableFinished',
  'writableHighWaterMark',
  'writableLength',
  'writableObjectMode',
  'write'
]

@rexagod
Copy link
Member Author

rexagod commented Jun 14, 2020

ping @mcollina @ronag

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

The reason we don't inherit Writable is due to performance reasons. It adds too much overhead.

I've been working on a way to get around that but it's not finished yet. #33515

@mcollina
Copy link
Member

Have you benchmarked this change? Last time I tried this it slowed things down and it was not really feasible.

@rexagod
Copy link
Member Author

rexagod commented Jun 15, 2020

I see. I tried benchmarking this for create-clientrequest.js and results show a negative improvement on performance. #33515 looks interesting, and I reckon it will allow us to successfully inherit and avoid performance degradation once it's done.

                                                           confidence improvement accuracy (*)   (**)  (***)
 http/create-clientrequest.js e=1 arg='options' url='idn'                 -1.99 %       ±5.13% ±6.84% ±8.92%
 http/create-clientrequest.js e=1 arg='options' url='long'                -2.35 %       ±3.10% ±4.13% ±5.38%
 http/create-clientrequest.js e=1 arg='options' url='wpt'                 -2.48 %       ±5.00% ±6.65% ±8.67%
 http/create-clientrequest.js e=1 arg='string' url='idn'                  -1.64 %       ±2.22% ±2.97% ±3.89%
 http/create-clientrequest.js e=1 arg='string' url='long'                 -1.15 %       ±1.47% ±1.96% ±2.56%
 http/create-clientrequest.js e=1 arg='string' url='wpt'                  -0.34 %       ±2.20% ±2.93% ±3.82%
 http/create-clientrequest.js e=1 arg='URL' url='idn'                     -1.03 %       ±2.03% ±2.70% ±3.52%
 http/create-clientrequest.js e=1 arg='URL' url='long'             **     -6.56 %       ±4.28% ±5.75% ±7.60%
 http/create-clientrequest.js e=1 arg='URL' url='wpt'                      1.99 %       ±3.57% ±4.77% ±6.27%

In the meantime, I'll find some more issues to dig in. Feel free to close this one. :)

@mcollina mcollina closed this Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http: OutgoingMessage instanceof Writable
4 participants