Mike Kristoffersen
2010-09-16 11:03:18 UTC
Working on Bug 587414 that makes Geolocation work from the content
process, while the geolocators are in the chrome process an interesting
discussion have emerged.
This is about sending of messages vs. using the protocol constructor and
delete function to transmit information across a process boundary.
Now what I understand from the dialog going on in bug 587414, is that
when we always send the same event after the constructor then that event
should be implicit by the constructor and if the last message is always
the same then that should be implicit by the destructor (to reduce the
number of messages send).
So if I from the child process do:
SendP<myProtocol>Constructor(...)
SendStart(...)
<other messages>
SendStop(...)
Send__delete__(...)
Then I should merge the start with the Constructor and the stop with the
__delete__ message, so the communication becomes like:
SendP<myProtocol>Constructor(...)
<other messages>
Send__delete__(...)
I can understand the argumentation here, no need to send messages that
we don't have to.
Now in this specific case message Start and Stop might be repeated a
number of times at unknown intervals, because it depends on the content
of the pages that the user visits.
SendP<myProtocol>Constructor(...)
.
.
.
SendStart(...)
<other messages>
SendStop(...)
.
.
.
SendStart(...)
<other messages>
SendStop>(...)
.
.
.
SendStart(...)
<other messages>
SendStop>(...)
.
.
.
Send__delete__(...)
Now in a review I was asked to merge the "start" with the constructor
and the "stop" with the __delete__ as the first message is always start
and the last one is stop (a bit simplified here to illustrate the key point)
I don't have a problem with implementing that, but it made me think:
As I don't know when the last stop is, I would then have to assume that
every stop is the last one - giving the following:
SendP<myProtocol>Constructor(...)
<other messages>
Send__delete__(...)
.
.
.
SendP<myProtocol>Constructor(...)
<other messages>
Send__delete__(...)
.
.
.
SendP<myProtocol>Constructor(...)
<other messages>
Send__delete__(...)
Looking at the code it seems like constructing a protocol is much more
expensive than just sending a message - so in a case like this where we
have two objects communicating over time, is it then the best choice to
create the connection between them once, and use this connection to
communicate over time - or is it really better to (re-)create the
connection each time it is needed? - Is there a significant cost to
having a connection open all the time?
process, while the geolocators are in the chrome process an interesting
discussion have emerged.
This is about sending of messages vs. using the protocol constructor and
delete function to transmit information across a process boundary.
Now what I understand from the dialog going on in bug 587414, is that
when we always send the same event after the constructor then that event
should be implicit by the constructor and if the last message is always
the same then that should be implicit by the destructor (to reduce the
number of messages send).
So if I from the child process do:
SendP<myProtocol>Constructor(...)
SendStart(...)
<other messages>
SendStop(...)
Send__delete__(...)
Then I should merge the start with the Constructor and the stop with the
__delete__ message, so the communication becomes like:
SendP<myProtocol>Constructor(...)
<other messages>
Send__delete__(...)
I can understand the argumentation here, no need to send messages that
we don't have to.
Now in this specific case message Start and Stop might be repeated a
number of times at unknown intervals, because it depends on the content
of the pages that the user visits.
SendP<myProtocol>Constructor(...)
.
.
.
SendStart(...)
<other messages>
SendStop(...)
.
.
.
SendStart(...)
<other messages>
SendStop>(...)
.
.
.
SendStart(...)
<other messages>
SendStop>(...)
.
.
.
Send__delete__(...)
Now in a review I was asked to merge the "start" with the constructor
and the "stop" with the __delete__ as the first message is always start
and the last one is stop (a bit simplified here to illustrate the key point)
I don't have a problem with implementing that, but it made me think:
As I don't know when the last stop is, I would then have to assume that
every stop is the last one - giving the following:
SendP<myProtocol>Constructor(...)
<other messages>
Send__delete__(...)
.
.
.
SendP<myProtocol>Constructor(...)
<other messages>
Send__delete__(...)
.
.
.
SendP<myProtocol>Constructor(...)
<other messages>
Send__delete__(...)
Looking at the code it seems like constructing a protocol is much more
expensive than just sending a message - so in a case like this where we
have two objects communicating over time, is it then the best choice to
create the connection between them once, and use this connection to
communicate over time - or is it really better to (re-)create the
connection each time it is needed? - Is there a significant cost to
having a connection open all the time?