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

fixes #23825; Busy wait on waitid, sleeping at regular intervals #23826

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

maleyva1
Copy link
Contributor

@maleyva1 maleyva1 commented Jul 12, 2024

Addresses #23825 by using the approaching described in #23743 (comment).

This takes the approach from Python's subprocess library which calls waitid in loop, while sleeping at regular intervals.

CC @alex65536

@maleyva1 maleyva1 changed the title Fixes #23825; Busy wait on waitid, sleeping at regular intervals fixes #23825; Busy wait on waitid, sleeping at regular intervals Jul 12, 2024
@Araq Araq merged commit 58b36bd into nim-lang:devel Jul 12, 2024
16 of 18 checks passed
@Araq
Copy link
Member

Araq commented Jul 12, 2024

Irrelevant CI failures.

Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 58b36bd

Hint: mm: orc; opt: speed; options: -d:release
173130 lines; 7.963s; 664.164MiB peakmem

@alex65536
Copy link
Contributor

alex65536 commented Jul 13, 2024

Good job 👍

But I think that there are a few minor issues:

  • I'm unsure whether using 1ms as an upper limit is a good idea, I would put the limit closer to 50ms, just as Python does. Though, I am really not sure what is the ideal solution here.
  • To calculate the remaining time, getTime() is used. But getTime() is not monotonic and is able to go backwards if either the user or the NTP daemon changes the system time. I think, getMonoTime() from monotimes would be better to compute timeouts.

@Araq
Copy link
Member

Araq commented Jul 13, 2024

You're correct.

@maleyva1
Copy link
Contributor Author

@alex65536 @Araq I made a PR (#23834) addressing these issues.

Araq pushed a commit that referenced this pull request Jul 15, 2024
Related to #23826. This address issues raised
[here](#23826 (comment))
by using a monotonic timestamp to calculate timeouts and increasing the
max sleep time to 50ms.
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.

3 participants