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

Fix external IO loop thead interaction and add function to Base.Experimental to facilitate it's use. Also add a test. #55529

Merged
merged 10 commits into from
Nov 7, 2024

Conversation

gbaraldi
Copy link
Member

While looking at #55525 I found that the implementation wasn't working correctly.
I added it to Base.Experimental so people don't need to handroll their own and am also testing a version of what the issue was hitting.

@vtjnash Is the wakeup of thread 0 for libuv only or do I need to wake both the IO thread and thread 0 always?

…imental to facilitate it's use. Also add a test.
@gbaraldi gbaraldi requested a review from vtjnash August 19, 2024 16:20
@gbaraldi gbaraldi requested a review from vtjnash August 30, 2024 13:30
test/threads.jl Outdated Show resolved Hide resolved
test/threads.jl Outdated

"""
proc = run(pipeline(`$(Base.julia_cmd()) -e $cmd`), wait=false)
sleep(10) # Is there a better way to do this?
Copy link
Member

Choose a reason for hiding this comment

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

Per previous discussion, this test needs to be rewritten to remove the sleep call before merging. The most common alternative is to set up a watchdog call such as t = Timer(60) do t; kill(proc); end; success(proc); close(t)

@gbaraldi
Copy link
Member Author

gbaraldi commented Nov 6, 2024

Bump!

@oscardssmith
Copy link
Member

Is there a reason we don't want a separate IO thread to be the default? It seems like a better design.

@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Nov 6, 2024
@JeffBezanson JeffBezanson added the io Involving the I/O subsystem: libuv, read, write, etc. label Nov 6, 2024
@@ -423,6 +445,8 @@ JL_DLLEXPORT jl_gcframe_t **jl_adopt_thread(void)
JL_GC_PROMISE_ROOTED(ct);
uv_random(NULL, NULL, &ct->rngState, sizeof(ct->rngState), 0, NULL);
jl_atomic_fetch_add(&jl_gc_disable_counter, -1);
ct->world_age = jl_get_world_counter(); // root_task sets world_age to 1
jl_init_task_lock(ct);
Copy link
Member

Choose a reason for hiding this comment

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

Is this really needed for all adopted threads? Could we lazy initialize it when somebody tries to wait for the task instead?

@vtjnash vtjnash merged commit 5848445 into master Nov 7, 2024
9 checks passed
@vtjnash vtjnash deleted the gb/io-loop-thread branch November 7, 2024 14:16
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants