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 upPut file descriptors in an Arc #77
Conversation
|
IRC chat: http://logs.glob.uno/?c=mozilla%23servo&s=23+May+2016&e=23+May+2016#c436462 Summary: I'm not sure how much this helps in the multi-process case, or even in the single-process case where |
|
We had |
metajack
commented
May 23, 2016
|
Why did @izgzhen turn it off? Or was it just an unintentional byproduct of his patch? |
izgzhen
commented
May 23, 2016
|
@metajack It is mostly like a intentional byproduct. Not all members of |
|
I'm ambivalent about this: on one hand, intuitively it seems wrong to add an extra layer of indirection for everyone, just because of a single user running into problems... (For the specific issue @izgzhen faced in servo/servo#11189 , it seems to me the solution would be for On the other hand, I see that the various One thing to consider though is that for the |
metajack
commented
May 24, 2016
|
I'd like @pcwalton's input on this. @Manishearth what do you think about the alternative that @antrik mentioned? If mpsc::Sender is an Arc under the hood, it seems like making IPCSender an Arc (except not doubling it for in-process) would be fairly consistent with that design. But I am not as familiar with the context here as others on the team. |
|
Thinking about it, |
| @@ -179,7 +180,7 @@ impl<T> IpcSender<T> where T: Serialize { | |||
|
|
|||
| pub fn to_opaque(self) -> OpaqueIpcSender { | |||
| OpaqueIpcSender { | |||
| os_sender: self.os_sender, | |||
| os_sender: self.os_sender.clone(), | |||
This comment has been minimized.
This comment has been minimized.
antrik
May 24, 2016
Contributor
Why do you need to clone here? Isn't self consumed anyway? Or am I missing something?...
This comment has been minimized.
This comment has been minimized.
d903268
to
f13eebb
|
@antrik does this look better to you? I'll look at the osx one later |
|
@Manishearth this is kinda funny: most of this change is actually about creating a dedicated FD type, and moving the Indeed my first thought (when I was originally thinking about it a while back) was to put it in an (Note: the title of the PR doesn't really fit any more.) |
|
heh. So should I move forward with this and Arcify the mac fds as well? |
|
Nitpick: I wonder whether it's appropriate to call it (Also, my intention was to use the explicit |
|
FileDescriptor works |
|
Actually, we don't need this change in macos, since mach seems to have it's own refcounting api. So this is ready to merge? |
|
I considered doing this, but I decided against it because of fears of too many allocations. I'm open to it if it actually fixes stuff, though. Do we know for sure that this fixes problems? |
|
We were already doing this for the resource channel in Servo; I'd like to do it uniformly everywhere. I think the small allocation of an int is shadowed by the IPC buffer and open file costs. |
|
Right now on my servo checkout some sites do hit the file descriptor limit (which is ~1000 currently for me) if you navigate for a bit |
|
@pcwalton well, it's rather clear that cloning of FDs needs to be avoided -- both because of the somewhat relevant overhead, and because of the fixed number of FDs per process on many systems causing serious problems. What's the best way to achieve that? It's a bit of a tradeoff: doing it at here will add some (very little) unnecessary overhead in cases that definitely won't clone the |
|
We used to have the perfectionist approach, but we only did it in a couple of places and the too many fds error still popped up. And again, I feel like we're worrying about a really tiny allocation in face of the cost of an IPC buffer. |
|
To my great surprise, this does actually add a (barely) measurable overhead to channel creation (+destruction): adding about 1% to the 4.5 µs these operations take on my system. That's not much in the grand scheme of things (it's some 100 processor clock cycles); yet this is in the same ballpark as a gratuitous FD clone + drop... I for one didn't expect that. (This is only creation, though -- I haven't tested how long actual cloning takes...) Note that this is an oldish system (from 2008 or so) running 32 bit Linux -- I wonder whether atomic operations are more efficient on newer systems? (Unfortunately, I don't have access to a more modern system for comparison anymore :-( ) |
|
Hm, interesting. Could you share your benchmarking code so I can try running it? Note that the primary goal here is to avoid running out of fds, not avoid the overhead of an fd clone. So this being as expensive as an fd clone isn't a big deal. |
|
@Manishearth yeah, was just doing that right now: #78 :-) I don't think this result significantly changes the situation; I mostly mentioned it because it surprised me... |
|
Mine goes from 11.4 microseconds to 11.7 microseconds. This is a pretty fast machine, not sure why this is happening. But the additional cost isn't much |
|
So, should we merge this? |
Put file descriptors in an Arc We used to do this manually in servo, but @izgzhen turned it off when consolidating the resource senders There really isn't much of a reason to not do this; and `mpsc::Sender` does this already (for a different reason) r? @antrik or @pcwalton cc @asajeffrey
|
@bors-servo retry force clean |
|
The build seemed to pass, but it didn't do anything |
|
@bors r=pcwalton clean |
|
@bors-servo r=pcwalton retry clean |
|
|
|
|
Put file descriptors in an Arc We used to do this manually in servo, but @izgzhen turned it off when consolidating the resource senders There really isn't much of a reason to not do this; and `mpsc::Sender` does this already (for a different reason) r? @antrik or @pcwalton cc @asajeffrey
|
@bors retry clean oy vey, Appveyor wasn't fully set up on this |
|
@bors-servo r=pcwalton |
|
|
|
|
@bors-servo retry force clean |
|
@bors-servo r- clean |
|
@bors-servo r=pcwalton |
|
|
|
@bors-servo r=pcwalton |
|
|
Put file descriptors in an Arc We used to do this manually in servo, but @izgzhen turned it off when consolidating the resource senders There really isn't much of a reason to not do this; and `mpsc::Sender` does this already (for a different reason) r? @antrik or @pcwalton cc @asajeffrey
|
|
Manishearth commentedMay 23, 2016
We used to do this manually in servo, but @izgzhen turned it off when consolidating the resource senders
There really isn't much of a reason to not do this; and
mpsc::Senderdoes this already (for a different reason)r? @antrik or @pcwalton
cc @asajeffrey