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

Don't make OsIpcSender Sync #115

Merged
merged 3 commits into from
Nov 8, 2016
Merged

Conversation

antrik
Copy link
Contributor

@antrik antrik commented Nov 3, 2016

mpsc::Sender isn't Sync -- and the ipc-channel equivalent probably
shouldn't be either. Sharing references to senders is usually not a good
idea: they are rather meant to be cloned instead; and they implement
internal sharing to make this efficient and robust -- sharing references
to senders just adds an unnecessary extra layer of sharing on top.

For the inprocess back-end, implementing Sync was necessitating
use of an Arc<Mutex<>>, adding considerable overhead even when not
used -- so this change is an optimisation. It effectively reverts most
of the sender part of 30b2024 (the
receiver part was already backed out in
77469c2 ), except that it obviously
doesn't re-introduce the bogus explicit Sync claim.

For the macos and unix back-ends, the sender implementations were
inherently Sync; so we explicitly mark them !Sync now, to get a
consistent API.

Also bumping the ipc-channel version here, as this is a breaking
change.

(It affects Servo only in one place though, see servo/servo#14048 )

This also comes with a test case to verify that OsIpcSender indeed isn't Sync any more; and a CI change to activate it.

`mpsc::Sender` isn't `Sync` -- and the `ipc-channel` equivalent probably
shouldn't be either. Sharing references to senders is usually not a good
idea: they are rather meant to be cloned instead; and they implement
internal sharing to make this efficient and robust -- sharing references
to senders just adds an unnecessary extra layer of sharing on top.

For the `inprocess` back-end, implementing `Sync` was necessitating
use of an `Arc<Mutex<>>`, adding considerable overhead even when not
used -- so this change is an optimisation. It effectively reverts most
of the sender part of 30b2024 (the
receiver part was already backed out in
77469c2 ), except that it obviously
doesn't re-introduce the bogus explicit `Sync` claim.

For the `macos` and `unix` back-ends, the sender implementations were
inherently `Sync`; so we explicitly mark them `!Sync` now, to get a
consistent API.

Also bumping the `ipc-channel` version here, as this is a breaking
change.
Unfortunately this requires an "unstable" feature to be enabled, because
it relies on specialization... Can't think of any other way to handle
this.
@antrik
Copy link
Contributor Author

antrik commented Nov 3, 2016

I'm wondering whether maybe it would be better to squash these commits; or some of them at least?...

@pcwalton
Copy link
Contributor

pcwalton commented Nov 3, 2016

Have you tried https://github.com/laumann/compiletest-rs? That strikes me as the simplest way to make sure OsIpcSender is !Sync.

@antrik
Copy link
Contributor Author

antrik commented Nov 7, 2016

@pcwalton with lots of tears and sweat, I managed to get it working with compiletest-rs: master...antrik:nosync_sender-compiletest

However, compiletest-rs actually requires unstable as well -- so I do not really consider it a win. In fact I don't like compiletest-rs very much: it's virtually undocumented (thus the tears and sweat); it has annoying quirks (LD_LIBRARY_PATH needs to be set explicitly, which is normally not necessary with cargo nowadays); and the indirection -- with separate test files in a separate directory executed by a separate test runner -- is not very elegant IMHO. I'd much rather keep my original approach...

@pcwalton
Copy link
Contributor

pcwalton commented Nov 7, 2016

@bors-servo: r+

@bors-servo
Copy link
Contributor

📌 Commit ad19e55 has been approved by pcwalton

@bors-servo
Copy link
Contributor

⌛ Testing commit ad19e55 with merge b2a8908...

bors-servo pushed a commit that referenced this pull request Nov 7, 2016
Don't make `OsIpcSender` `Sync`

`mpsc::Sender` isn't `Sync` -- and the `ipc-channel` equivalent probably
shouldn't be either. Sharing references to senders is usually not a good
idea: they are rather meant to be cloned instead; and they implement
internal sharing to make this efficient and robust -- sharing references
to senders just adds an unnecessary extra layer of sharing on top.

For the `inprocess` back-end, implementing `Sync` was necessitating
use of an `Arc<Mutex<>>`, adding considerable overhead even when not
used -- so this change is an optimisation. It effectively reverts most
of the sender part of 30b2024 (the
receiver part was already backed out in
77469c2 ), except that it obviously
doesn't re-introduce the bogus explicit `Sync` claim.

For the `macos` and `unix` back-ends, the sender implementations were
inherently `Sync`; so we explicitly mark them `!Sync` now, to get a
consistent API.

Also bumping the `ipc-channel` version here, as this is a breaking
change.

(It affects Servo only in one place though, see servo/servo#14048 )

This also comes with a test case to verify that `OsIpcSender` indeed isn't `Sync` any more; and a CI change to activate it.
@bors-servo
Copy link
Contributor

💔 Test failed - status-appveyor

@frewsxcv
Copy link
Contributor

frewsxcv commented Nov 8, 2016

@bors-servo retry

@bors-servo
Copy link
Contributor

⌛ Testing commit ad19e55 with merge e6ea839...

bors-servo pushed a commit that referenced this pull request Nov 8, 2016
Don't make `OsIpcSender` `Sync`

`mpsc::Sender` isn't `Sync` -- and the `ipc-channel` equivalent probably
shouldn't be either. Sharing references to senders is usually not a good
idea: they are rather meant to be cloned instead; and they implement
internal sharing to make this efficient and robust -- sharing references
to senders just adds an unnecessary extra layer of sharing on top.

For the `inprocess` back-end, implementing `Sync` was necessitating
use of an `Arc<Mutex<>>`, adding considerable overhead even when not
used -- so this change is an optimisation. It effectively reverts most
of the sender part of 30b2024 (the
receiver part was already backed out in
77469c2 ), except that it obviously
doesn't re-introduce the bogus explicit `Sync` claim.

For the `macos` and `unix` back-ends, the sender implementations were
inherently `Sync`; so we explicitly mark them `!Sync` now, to get a
consistent API.

Also bumping the `ipc-channel` version here, as this is a breaking
change.

(It affects Servo only in one place though, see servo/servo#14048 )

This also comes with a test case to verify that `OsIpcSender` indeed isn't `Sync` any more; and a CI change to activate it.
@bors-servo
Copy link
Contributor

☀️ Test successful - status-appveyor, status-travis

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.

4 participants