You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Anand Mazumdar <ma...@gmail.com> on 2016/01/14 00:06:57 UTC

Review Request 42273: Modified scheduler library to move the queue contents before `async`.

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/42273/
-----------------------------------------------------------

Review request for mesos and Vinod Kone.


Repository: mesos


Description
-------

This trivial fix invokes `std::move` on the `queue` object to not perform a copy before invoking the `async(..)` call.


Diffs
-----

  src/scheduler/scheduler.cpp a17872b46ec600e0fae6c43247ccb63f5ee55ac0 

Diff: https://reviews.apache.org/r/42273/diff/


Testing
-------

make check


Thanks,

Anand Mazumdar


Re: Review Request 42273: Modified scheduler library to move the queue contents before `async`.

Posted by Benjamin Bannier <be...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/42273/#review114440
-----------------------------------------------------------



src/scheduler/scheduler.cpp (line 261)
<https://reviews.apache.org/r/42273/#comment175286>

    In general there are no guarantees on whether it is safe to assign to a `move`'d from object, but currently this looks safe (`std::queue` uses a `std::deque` as underlying container which can be assigned to if `move`'d from, cf. http://stackoverflow.com/a/7028318/176922).
    
    I am just worried if it is a good idea to rely on that behavior, e.g., we might pull in another `queue` w/o realizing (`using std::queue` above), or just declare an alias `queue` somehow that uses a different underlying container (OK, that is *currently* not something we would do in mesos); we would probably not realize that we might break the implicit assumptions here.


- Benjamin Bannier


On Jan. 14, 2016, 12:06 a.m., Anand Mazumdar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42273/
> -----------------------------------------------------------
> 
> (Updated Jan. 14, 2016, 12:06 a.m.)
> 
> 
> Review request for mesos and Vinod Kone.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This trivial fix invokes `std::move` on the `queue` object to not perform a copy before invoking the `async(..)` call.
> 
> 
> Diffs
> -----
> 
>   src/scheduler/scheduler.cpp a17872b46ec600e0fae6c43247ccb63f5ee55ac0 
> 
> Diff: https://reviews.apache.org/r/42273/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Anand Mazumdar
> 
>


Re: Review Request 42273: Modified scheduler library to move the queue contents before `async`.

Posted by Anand Mazumdar <ma...@gmail.com>.

> On Jan. 14, 2016, 9:03 a.m., Benjamin Bannier wrote:
> > Was the decision to optimize here driven by profiling?
> > 
> > Given the proposed implementation I wonder if this was worth the risk. I can only see this being called for single element `queues` of `Events` which should not be too expensive to copy, especially given how little we worry about e.g., creating temporary `strings` elsewhere.

My main motivation for making the change was driven by the semantics of how the callback function processes the data here:

```
void received(queue<Event> events)
  {
    while (!events.empty()) {
      Event event = events.front();
      events.pop();

      switch (event.type()) {
      }
  }
```

Since, the callback function always has to invoke a `.pop()`. The argument `queue<Event> events` has to be passed on by value. So, we were effectively, copying the same object twice. 

Also, after performing the `move`, we were invoking the assignment operation that did not have a precondition associated with it for `std::queue` and hence seemed safe to make the change. But, the queue can at best have a few events (at max). In most cases being `== 1` as you pointed out, except for the cases where the callback function takes some time and we queued more events from the master in the interim. 

I am discarding this for now. We can always revisit this later.


- Anand


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/42273/#review114441
-----------------------------------------------------------


On Jan. 13, 2016, 11:06 p.m., Anand Mazumdar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42273/
> -----------------------------------------------------------
> 
> (Updated Jan. 13, 2016, 11:06 p.m.)
> 
> 
> Review request for mesos and Vinod Kone.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This trivial fix invokes `std::move` on the `queue` object to not perform a copy before invoking the `async(..)` call.
> 
> 
> Diffs
> -----
> 
>   src/scheduler/scheduler.cpp a17872b46ec600e0fae6c43247ccb63f5ee55ac0 
> 
> Diff: https://reviews.apache.org/r/42273/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Anand Mazumdar
> 
>


Re: Review Request 42273: Modified scheduler library to move the queue contents before `async`.

Posted by Benjamin Bannier <be...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/42273/#review114441
-----------------------------------------------------------


Was the decision to optimize here driven by profiling?

Given the proposed implementation I wonder if this was worth the risk. I can only see this being called for single element `queues` of `Events` which should not be too expensive to copy, especially given how little we worry about e.g., creating temporary `strings` elsewhere.

- Benjamin Bannier


On Jan. 14, 2016, 12:06 a.m., Anand Mazumdar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42273/
> -----------------------------------------------------------
> 
> (Updated Jan. 14, 2016, 12:06 a.m.)
> 
> 
> Review request for mesos and Vinod Kone.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This trivial fix invokes `std::move` on the `queue` object to not perform a copy before invoking the `async(..)` call.
> 
> 
> Diffs
> -----
> 
>   src/scheduler/scheduler.cpp a17872b46ec600e0fae6c43247ccb63f5ee55ac0 
> 
> Diff: https://reviews.apache.org/r/42273/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Anand Mazumdar
> 
>


Re: Review Request 42273: Modified scheduler library to move the queue contents before `async`.

Posted by Mesos ReviewBot <re...@mesos.apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/42273/#review114426
-----------------------------------------------------------


Patch looks great!

Reviews applied: [42273]

Passed command: export OS=ubuntu:14.04;export CONFIGURATION="--verbose";export COMPILER=gcc; ./support/docker_build.sh

- Mesos ReviewBot


On Jan. 13, 2016, 11:06 p.m., Anand Mazumdar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42273/
> -----------------------------------------------------------
> 
> (Updated Jan. 13, 2016, 11:06 p.m.)
> 
> 
> Review request for mesos and Vinod Kone.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This trivial fix invokes `std::move` on the `queue` object to not perform a copy before invoking the `async(..)` call.
> 
> 
> Diffs
> -----
> 
>   src/scheduler/scheduler.cpp a17872b46ec600e0fae6c43247ccb63f5ee55ac0 
> 
> Diff: https://reviews.apache.org/r/42273/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Anand Mazumdar
> 
>


Re: Review Request 42273: Modified scheduler library to move the queue contents before `async`.

Posted by Guangya Liu <gy...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/42273/#review114390
-----------------------------------------------------------

Ship it!


Ship It!

- Guangya Liu


On 一月 13, 2016, 11:06 p.m., Anand Mazumdar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42273/
> -----------------------------------------------------------
> 
> (Updated 一月 13, 2016, 11:06 p.m.)
> 
> 
> Review request for mesos and Vinod Kone.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This trivial fix invokes `std::move` on the `queue` object to not perform a copy before invoking the `async(..)` call.
> 
> 
> Diffs
> -----
> 
>   src/scheduler/scheduler.cpp a17872b46ec600e0fae6c43247ccb63f5ee55ac0 
> 
> Diff: https://reviews.apache.org/r/42273/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Anand Mazumdar
> 
>