Skip to content

fix: make stdin quit monitoring non-blocking#562

Open
MilesCranmerBot wants to merge 8 commits intoastroautomata:masterfrom
MilesCranmerBot:bot/stdin-nonblocking-upstream
Open

fix: make stdin quit monitoring non-blocking#562
MilesCranmerBot wants to merge 8 commits intoastroautomata:masterfrom
MilesCranmerBot:bot/stdin-nonblocking-upstream

Conversation

@MilesCranmerBot
Copy link
Copy Markdown
Contributor

Fixes intermittent hangs/freezes caused by stdin quit monitoring when stdin is a pipe/non-interactive (notably on Windows).

TDD: adds a fast unit reproducer using a FakeInputStream that simulates bytesavailable>0 with a blocking read, then fixes the monitor to use non-blocking reads + robust CRLF/partial-chunk parsing.

Related PySR issues: #832, #1101, #1092.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 12, 2026

Benchmark Results (Julia v1)

Time benchmarks
master f3cbb63... master / f3cbb63...
search/multithreading 23.5 ± 0.72 s 24.2 ± 1.2 s 0.969 ± 0.056
search/serial 54.9 ± 0.35 s 53.6 ± 1 s 1.02 ± 0.021
utils/best_of_sample 2.09 ± 0.77 μs 1.93 ± 0.65 μs 1.08 ± 0.54
utils/check_constraints_x10 16.8 ± 4.2 μs 16.8 ± 4.2 μs 0.998 ± 0.35
utils/compute_complexity_x10/Float64 2.16 ± 0.11 μs 2.17 ± 0.11 μs 0.996 ± 0.074
utils/compute_complexity_x10/Int64 2.11 ± 0.11 μs 2.09 ± 0.11 μs 1.01 ± 0.076
utils/compute_complexity_x10/nothing 1.65 ± 0.11 μs 1.65 ± 0.11 μs 1.01 ± 0.095
utils/insert_random_op_x10 5.89 ± 1.6 μs 5.9 ± 1.5 μs 0.999 ± 0.37
utils/next_generation_x100 0.498 ± 0.11 ms 0.492 ± 0.12 ms 1.01 ± 0.33
utils/optimize_constants_x10 0.0513 ± 0.0092 s 0.0503 ± 0.01 s 1.02 ± 0.27
utils/randomly_rotate_tree_x10 8.38 ± 0.97 μs 8.53 ± 0.97 μs 0.983 ± 0.16
time_to_load 2.9 ± 0.096 s 2.6 ± 0.097 s 1.11 ± 0.056
Memory benchmarks
master f3cbb63... master / f3cbb63...
search/multithreading 0.204 G allocs: 52.1 GB 0.205 G allocs: 53.3 GB 0.978
search/serial 0.206 G allocs: 53.9 GB 0.206 G allocs: 53.9 GB 1
utils/best_of_sample 0.038 k allocs: 3.25 kB 0.038 k allocs: 3.25 kB 1
utils/check_constraints_x10 0.034 k allocs: 0.875 kB 0.034 k allocs: 0.875 kB 1
utils/compute_complexity_x10/Float64 0 allocs: 0 B 0 allocs: 0 B
utils/compute_complexity_x10/Int64 0 allocs: 0 B 0 allocs: 0 B
utils/compute_complexity_x10/nothing 0 allocs: 0 B 0 allocs: 0 B
utils/insert_random_op_x10 0.044 k allocs: 1.81 kB 0.044 k allocs: 1.81 kB 1
utils/next_generation_x100 4.62 k allocs: 0.276 MB 4.62 k allocs: 0.276 MB 1
utils/optimize_constants_x10 22.5 k allocs: 22.9 MB 21.8 k allocs: 22.5 MB 1.02
utils/randomly_rotate_tree_x10 0.042 k allocs: 1.34 kB 0.042 k allocs: 1.34 kB 1
time_to_load 0.145 k allocs: 11 kB 0.149 k allocs: 11.2 kB 0.983

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.12%. Comparing base (2f8a7ac) to head (c8b442f).

Files with missing lines Patch % Lines
src/SearchUtils.jl 85.71% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #562      +/-   ##
==========================================
+ Coverage   95.02%   95.12%   +0.09%     
==========================================
  Files          42       42              
  Lines        3882     3900      +18     
==========================================
+ Hits         3689     3710      +21     
+ Misses        193      190       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@MilesCranmer MilesCranmer left a comment

Choose a reason for hiding this comment

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

Looks actually pretty good.

However one thing I would like is for a test that does not rely on fake streams but on the actual REPL.

I think we can do this with Linux expect tool. Or are there other options?

@MilesCranmerBot please investigate and add such a test.

I recommend doing some mutation testing as well - try introducing silent failures - does the test catch it? Or does the test always pass?

@MilesCranmer
Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

MilesCranmerBot and others added 3 commits February 13, 2026 00:27
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@MilesCranmerBot Can we do this with linux expect rather than hacking together a reimplementation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Swapped the REPL stdin nonblocking check over to a plain Linux expect script (so we’re not reimplementing an expect loop in Python).

  • Added: test/repl/test_repl_stdin_nonblocking.exp
  • CI: installs expect (ubuntu-latest + evaluation only) and runs the script
  • Removed: test/repl/test_repl_stdin_nonblocking.py

Pushed in f3cbb63.

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.

2 participants