Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upconstellation: Simplify the scheduler so it doesn't create a thread for each event #11279
Conversation
…or each event This can't land as-is, just wanted to make sure this idea is fine, and do a try run because I need to leave now.
This approach uses a secondary thread to manage the timeout + select. This is not ideal, but it can be vastly improved if something is done about rust-lang/rfcs#962. The other apparently cleaner option, having the returned value not being an ipc-sender, but a struct containing the sender and the Thread handle (which would allow unparking), wouldn't work across IPC.
…o tasks
highfive
commented
May 19, 2016
|
Heads up! This PR modifies the following files:
|
|
My completely untested implementation, for comparison: https://github.com/asajeffrey/servo/tree/scheduler-with-fewer-threads |
|
Some IRC discussion: http://logs.glob.uno/?c=mozilla%23servo&s=19+May+2016&e=19+May+2016#c433870 TL;DR (but really it's very short): I'm concerned that this code may deadlock, or at least block for an unbounded amount of time, due to a race condition. Fixing it (as far as we can see) requires spinning on an atomic, since there's no test-and-park primitive. |
|
My now-tested implementation: #11283. |
|
To be clear, I'm fine landing any of both approaches. I think this one would be a bit easier to migrate if rust-lang/rfcs#962 is implemented, but that's not a huge concern. On the other side, after reading the docs more carefully, I think the discussion we had on IRC was wrong. This can't make us sleep too much. The point @asajeffrey was making was that if we called From the docs:
(notice the "unless" bit). That would mean that the worst case for this is the unlikely case that we call This is not a problem for this implementation, since once the timeout is raised, we'll re-check times before checking that again, and block, so this becomes a no-op. In fact, I think this can't even be the case, since |
|
Ah, this makes life a lot easier, I'll try again with this semantics of park/unpark. |
highfive
commented
May 20, 2016
|
New code was committed to pull request. |
|
We decided to go for #11283. |
std: sync: Implement recv_timeout() This is an attempt to implement rust-lang/rfcs#962. I'm not sure about if a change like this would require an rfc or something like that, and this surely needs a lot more testing, but I wanted to take some eyes on it before following. cc @metajack @asajeffrey servo/servo#11279 servo/servo#11283 r? @aturon
std: sync: Implement recv_timeout() This is an attempt to implement rust-lang/rfcs#962. I'm not sure about if a change like this would require an rfc or something like that, and this surely needs a lot more testing, but I wanted to take some eyes on it before following. cc @metajack @asajeffrey servo/servo#11279 servo/servo#11283 r? @aturon
emilio commentedMay 19, 2016
•
edited by larsbergstrom
Thank you for contributing to Servo! Please replace each
[ ]by[X]when the step is complete, and replace__with appropriate data:./mach build -ddoes not report any errors./mach test-tidy --fasterdoes not report any errorsEither:
Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process.
This PR builds on top of #11272 (it couldn't be reopened because I pushed to the branch before doing it).
r? @asajeffrey
cc @metajack @pcwalton
Concretely:
@metajack: This uses an auxiliary thread to take care of timeouts. It's not optimal (optimal would be rust-lang/rfcs#962), but it's way better than anything we had, and the other option (passing the thread handle around and
unpark()the thread when appropiate) wouldn't work across IPC.This change is