Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@twose
Copy link
Contributor

@twose twose commented Jun 5, 2020

the previous implementation was uv_write + uv_cancel, it's too hack

If this pr is acceptable, I hope we can implement uv_try_write2 and it always returns UV_EAGAIN when send_handle != NULL on WIN

ping @bnoordhuis

@twose
Copy link
Contributor Author

twose commented Jun 10, 2020

This is just an optimization, it didn't break anything, it just decoupled the part of the system call from uv__write, I believe that it's more readable and performance now.
I am actively using the develop version of libuv so I hope to get some response, thank you

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Thanks, this is indeed a nice improvement.

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

@bnoordhuis
Copy link
Member

Libuv+Node.js CI again: https://ci.nodejs.org/view/libuv/job/libuv-in-node/137/

I'm pretty sure the failures in the previous run were caused by a flaky test and not this PR but better safe than sorry.

@stale
Copy link

stale bot commented Jul 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 7, 2020
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Looks great to me also, but build logs are gone, so I can't know what CI issue you saw.

@stale stale bot removed the stale label Jul 29, 2020
vtjnash pushed a commit to twose/libuv that referenced this pull request Aug 4, 2020
PR-URL: libuv#2874
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Jameson Nash <[email protected]>
@vtjnash
Copy link
Member

vtjnash commented Aug 4, 2020

@vtjnash
Copy link
Member

vtjnash commented Aug 4, 2020

Hm, that did surprisingly badly. Let's check that again: https://ci.nodejs.org/view/libuv/job/libuv-in-node/144/

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

CI has me concerned there's something wrong with this, though it's only failing one test

@twose
Copy link
Contributor Author

twose commented Aug 5, 2020

@vtjnash
I cannot find the error message for the test, can you point it out for me? I am not very familiar with it, thanks.

@vtjnash
Copy link
Member

vtjnash commented Aug 5, 2020

There wasn't an error message, just a lot of instances of this test failing:

not ok 2315 parallel/test-tls-env-extra-ca
  ---
  duration_ms: 120.21
  severity: fail
  exitcode: -15
  stack: |-
    timeout
  ...

@twose
Copy link
Contributor Author

twose commented Aug 7, 2020

Is this a nodejs test?
I don't know much about nodejs...
I need help @bnoordhuis
Please take a look at this if you have time...

@bnoordhuis
Copy link
Member

@twose Yes, it's a node.js test. It's almost certainly a flake but let's try it one more time. Can you rebase against v1.x? Thanks.

@twose
Copy link
Contributor Author

twose commented Aug 12, 2020

Recently some busy, sorry for being late, I've updated this :)

@vtjnash
Copy link
Member

vtjnash commented Aug 12, 2020

It failed quite a substantial number of times across many platforms (vs. no failures when I ran with the head of v1.x). I'm hoping nodejs CI isn't really that flaky, so I'm assuming it must be somehow related. Unfortunately, the old build logs are gone, so I'm not sure how to solve this. 😬

Attempted Nodejs+libuv CI: https://ci.nodejs.org/view/libuv/job/libuv-in-node/151/
Seems to be hitting a memory limit or memory corruption on a couple nodes now (so a different error than last week)?

@cjihrig
Copy link
Contributor

cjihrig commented Aug 12, 2020

The Node integration CI won't pass until nodejs/node#34751 or a similar change lands in Node.

@twose
Copy link
Contributor Author

twose commented Aug 24, 2020

Friendly reminder :)
Can we try again now?

@vtjnash
Copy link
Member

vtjnash commented Aug 25, 2020

@vtjnash
Copy link
Member

vtjnash commented Aug 25, 2020

Still appears to show a sharply increased failure rate of that test: https://ci.nodejs.org/view/libuv/job/libuv-in-node/163/

@twose
Copy link
Contributor Author

twose commented Aug 27, 2020

I reviewed the code again, but I still can not find any problems, the logic should be equivalent to the original.
and what is the meaning of "flaky"? I can not get it 😢 (maybe because of my poor English)

@puzpuzpuz
Copy link

and what is the meaning of "flaky"? I can not get it (maybe because of my poor English)

@twose a "flaky" test means a test that fails occasionally, under certain conditions, i.e. it does not always fail. Such tests are harmful, as they reduce the overall value of the test suite. Hopefully, the explanation is good enough.

@twose
Copy link
Contributor Author

twose commented Sep 9, 2020

@puzpuzpuz I really appreciate your help and I got it.

I rebased it again. Hoping someone can help push forward the progress...

@twose twose requested review from bnoordhuis and vtjnash September 28, 2020 10:00
@stale
Copy link

stale bot commented Oct 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 19, 2020
@stale stale bot removed the stale label Oct 20, 2020
@stale
Copy link

stale bot commented Nov 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 11, 2020
@twose
Copy link
Contributor Author

twose commented Nov 17, 2020

@bnoordhuis need your help 🤯

@stale stale bot removed the stale label Nov 17, 2020
@vtjnash
Copy link
Member

vtjnash commented Nov 17, 2020

I took a quick look, and it is indirectly related to this PR, though nodejs seems probably most at fault. It is timing related, and happens more often when the server is busy (e.g. running tests/parallel, then when it is idle). It's easy to reproduce under rr (record-and-replay). It seems perhaps related to #3006, as what I see is that nodejs calls uv_shutdown (in response to close_notify), then tries to do more uv_write calls, and forgets to ever call uv_close. It's also possibly thus related to nodejs/node#36111, as it hits precisely that issue also (the TLSWrap object gets UV_EOF, but knows it's already reported eof_ to the caller, and thus assumes the caller should have already schedule destroy and doesn't duplicate the notification)

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Since, after analysis, I think the CI failure appears to be a race condition that needs to be fixed in nodejs, I'm proposing merging this. It should have no external functional changes, but makes the code cleaner and should avoid many syscalls.

@stale
Copy link

stale bot commented Dec 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 8, 2020
@winterland1989
Copy link

Really want see this get merged in next release, could save lots of system call in some binding code.

@stale stale bot removed the stale label Feb 19, 2021
@stale
Copy link

stale bot commented Mar 20, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 20, 2021
@winterland1989
Copy link

Oh please don't, we desperately need this.

@stale stale bot removed the stale label Mar 20, 2021
@vtjnash
Copy link
Member

vtjnash commented Mar 20, 2021

I won't let stalebot steal this: I plan to include it in the next release.

@vtjnash vtjnash merged commit 23bebf0 into libuv:v1.x May 10, 2021
@twose twose deleted the uv_try_write branch May 12, 2021 02:38
@twose
Copy link
Contributor Author

twose commented May 12, 2021

Finally merged, thank you for all your assistance.

JeffroMF pushed a commit to JeffroMF/libuv that referenced this pull request May 16, 2022
This simplifies the code, for better clarify (and performance)!

PR-URL: libuv#2874
Reviewed-By: Jameson Nash <[email protected]>
liujinye-sys pushed a commit to open-vela/apps_system_libuv that referenced this pull request Jul 23, 2025
This simplifies the code, for better clarify (and performance)!

PR-URL: libuv/libuv#2874
Reviewed-By: Jameson Nash <[email protected]>
liujinye-sys pushed a commit to open-vela/apps_system_libuv that referenced this pull request Dec 16, 2025
This simplifies the code, for better clarify (and performance)!

PR-URL: libuv/libuv#2874
Reviewed-By: Jameson Nash <[email protected]>
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.

6 participants