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

Don't make `OsIpcSender` `Sync` #115

merged 3 commits into from Nov 8, 2016

Conversation

@antrik
Copy link
Contributor

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.

antrik added 2 commits Nov 1, 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.
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?...

@antrik antrik force-pushed the antrik:nosync_sender branch from 53263f3 to f46ed97 Nov 3, 2016
@antrik antrik force-pushed the antrik:nosync_sender branch from f46ed97 to ad19e55 Nov 3, 2016
@pcwalton
Copy link
Collaborator

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
Collaborator

pcwalton commented Nov 7, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2016

📌 Commit ad19e55 has been approved by pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2016

Testing commit ad19e55 with merge b2a8908...

bors-servo added 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

bors-servo commented Nov 7, 2016

💔 Test failed - status-appveyor

@frewsxcv
Copy link
Member

frewsxcv commented Nov 8, 2016

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Nov 8, 2016

Testing commit ad19e55 with merge e6ea839...

bors-servo added 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

bors-servo commented Nov 8, 2016

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

@bors-servo bors-servo merged commit ad19e55 into servo:master Nov 8, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.