Re: Review Request 42762: Improved performance of 'roles::validate'.

2016-01-26 Thread Benjamin Bannier


> On Jan. 26, 2016, 3:14 a.m., Anand Mazumdar wrote:
> > LGTM. Puzzled me for a bit at why the temporary is being constructed 
> > (assuming the correct `operator==` for `const char*` was being invoked) 
> > till I looked up here:
> > 
> > https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/basic_string.h#L2468
> > 
> > ```
> >  Determines the effective length rlen of the strings to compare as the 
> > smallest of size() and the length of a string constructed from @a __s. 
> > ```

Maybe I am too dense, but I think this comment is misleading, see the impl 
https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/include/bits/basic_string.tcc#L1390.
 Nothing there seems to construct a temporary string. What could cause 
different performance for `string` and `const char*` is that the length of a 
`const char*` might need to be calculated at runtime (technically a compiler 
could use the known length of the literal to make this a nop since this is all 
implemented in headers, 
https://code.woboq.org/gcc/include/c++/5.2.0/bits/char_traits.h.html#__gnu_cxx::char_traits::length).
 The actual comparsion is just a `memcmp` 
(https://code.woboq.org/gcc/include/c++/5.2.0/bits/char_traits.h.html#__gnu_cxx::char_traits::length).


- Benjamin


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


On Jan. 26, 2016, 1:10 a.m., Joris Van Remoortere wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42762/
> ---
> 
> (Updated Jan. 26, 2016, 1:10 a.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> This validation is used inside resource math which in turn is used
> heavily in the code base.
> The temporary string allocations caused a significant performance
> degradation in this critical path.
> 
> 
> Diffs
> -
> 
>   src/common/roles.cpp 5be807018ff84174cf0cabb933f6828d458d3846 
> 
> Diff: https://reviews.apache.org/r/42762/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Joris Van Remoortere
> 
>



Re: Review Request 42762: Improved performance of 'roles::validate'.

2016-01-25 Thread Mesos ReviewBot

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



Patch looks great!

Reviews applied: [42761, 42762]

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

- Mesos ReviewBot


On Jan. 26, 2016, 12:10 a.m., Joris Van Remoortere wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42762/
> ---
> 
> (Updated Jan. 26, 2016, 12:10 a.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> This validation is used inside resource math which in turn is used
> heavily in the code base.
> The temporary string allocations caused a significant performance
> degradation in this critical path.
> 
> 
> Diffs
> -
> 
>   src/common/roles.cpp 5be807018ff84174cf0cabb933f6828d458d3846 
> 
> Diff: https://reviews.apache.org/r/42762/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Joris Van Remoortere
> 
>



Re: Review Request 42762: Improved performance of 'roles::validate'.

2016-01-25 Thread Joris Van Remoortere


> On Jan. 26, 2016, 2:14 a.m., Anand Mazumdar wrote:
> > src/common/roles.cpp, line 62
> > 
> >
> > Not yours: Can we remove the period at the end of each of the error 
> > messages?
> > 
> > We dump them with the periods later: 
> > https://github.com/apache/mesos/blob/master/src/master/master.cpp#L635

Updated in the review after this one.
Thanks for catching this.


- Joris


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


On Jan. 26, 2016, 12:10 a.m., Joris Van Remoortere wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42762/
> ---
> 
> (Updated Jan. 26, 2016, 12:10 a.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> This validation is used inside resource math which in turn is used
> heavily in the code base.
> The temporary string allocations caused a significant performance
> degradation in this critical path.
> 
> 
> Diffs
> -
> 
>   src/common/roles.cpp 5be807018ff84174cf0cabb933f6828d458d3846 
> 
> Diff: https://reviews.apache.org/r/42762/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Joris Van Remoortere
> 
>



Re: Review Request 42762: Improved performance of 'roles::validate'.

2016-01-25 Thread Joris Van Remoortere


> On Jan. 26, 2016, 12:28 a.m., Benjamin Bannier wrote:
> > Was any of this confirm by profiling? In standard C++ there is an 
> > overloaded `operator==` for `std::string` which can compare with a `const 
> > char*`.

Yes confirmed by profiler. It it constructing the strings per iteration.


- Joris


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


On Jan. 26, 2016, 12:10 a.m., Joris Van Remoortere wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42762/
> ---
> 
> (Updated Jan. 26, 2016, 12:10 a.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> This validation is used inside resource math which in turn is used
> heavily in the code base.
> The temporary string allocations caused a significant performance
> degradation in this critical path.
> 
> 
> Diffs
> -
> 
>   src/common/roles.cpp 5be807018ff84174cf0cabb933f6828d458d3846 
> 
> Diff: https://reviews.apache.org/r/42762/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Joris Van Remoortere
> 
>



Re: Review Request 42762: Improved performance of 'roles::validate'.

2016-01-25 Thread Benjamin Bannier

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



Was any of this confirm by profiling? In standard C++ there is an overloaded 
`operator==` for `std::string` which can compare with a `const char*`.

- Benjamin Bannier


On Jan. 26, 2016, 1:10 a.m., Joris Van Remoortere wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42762/
> ---
> 
> (Updated Jan. 26, 2016, 1:10 a.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> This validation is used inside resource math which in turn is used
> heavily in the code base.
> The temporary string allocations caused a significant performance
> degradation in this critical path.
> 
> 
> Diffs
> -
> 
>   src/common/roles.cpp 5be807018ff84174cf0cabb933f6828d458d3846 
> 
> Diff: https://reviews.apache.org/r/42762/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Joris Van Remoortere
> 
>



Re: Review Request 42762: Improved performance of 'roles::validate'.

2016-01-25 Thread Neil Conway

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




src/common/roles.cpp (line 59)


Would `static constexpr` be better?


- Neil Conway


On Jan. 26, 2016, 12:10 a.m., Joris Van Remoortere wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42762/
> ---
> 
> (Updated Jan. 26, 2016, 12:10 a.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> This validation is used inside resource math which in turn is used
> heavily in the code base.
> The temporary string allocations caused a significant performance
> degradation in this critical path.
> 
> 
> Diffs
> -
> 
>   src/common/roles.cpp 5be807018ff84174cf0cabb933f6828d458d3846 
> 
> Diff: https://reviews.apache.org/r/42762/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Joris Van Remoortere
> 
>



Re: Review Request 42762: Improved performance of 'roles::validate'.

2016-01-25 Thread Benjamin Bannier


> On Jan. 26, 2016, 1:29 a.m., Neil Conway wrote:
> > src/common/roles.cpp, line 59
> > 
> >
> > Would `static constexpr` be better?

A `string` cannot be `constexpr` (could perform dynamic allocations).


- Benjamin


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


On Jan. 26, 2016, 1:10 a.m., Joris Van Remoortere wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42762/
> ---
> 
> (Updated Jan. 26, 2016, 1:10 a.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> This validation is used inside resource math which in turn is used
> heavily in the code base.
> The temporary string allocations caused a significant performance
> degradation in this critical path.
> 
> 
> Diffs
> -
> 
>   src/common/roles.cpp 5be807018ff84174cf0cabb933f6828d458d3846 
> 
> Diff: https://reviews.apache.org/r/42762/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Joris Van Remoortere
> 
>



Re: Review Request 42762: Improved performance of 'roles::validate'.

2016-01-25 Thread Neil Conway


> On Jan. 26, 2016, 12:29 a.m., Neil Conway wrote:
> > src/common/roles.cpp, line 59
> > 
> >
> > Would `static constexpr` be better?
> 
> Benjamin Bannier wrote:
> A `string` cannot be `constexpr` (could perform dynamic allocations).

D'oh, I'm sure I knew that. Thanks!


- Neil


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


On Jan. 26, 2016, 12:10 a.m., Joris Van Remoortere wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42762/
> ---
> 
> (Updated Jan. 26, 2016, 12:10 a.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> This validation is used inside resource math which in turn is used
> heavily in the code base.
> The temporary string allocations caused a significant performance
> degradation in this critical path.
> 
> 
> Diffs
> -
> 
>   src/common/roles.cpp 5be807018ff84174cf0cabb933f6828d458d3846 
> 
> Diff: https://reviews.apache.org/r/42762/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Joris Van Remoortere
> 
>



Re: Review Request 42762: Improved performance of 'roles::validate'.

2016-01-25 Thread Anand Mazumdar

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


Fix it, then Ship it!




LGTM. Puzzled me for a bit at why the temporary is being constructed (assuming 
the correct `operator==` for `const char*` was being invoked) till I looked up 
here:

https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/basic_string.h#L2468

```
 Determines the effective length rlen of the strings to compare as the smallest 
of size() and the length of a string constructed from @a __s. 
```


src/common/roles.cpp (line 62)


Not yours: Can we remove the period at the end of each of the error 
messages?

We dump them with the periods later: 
https://github.com/apache/mesos/blob/master/src/master/master.cpp#L635


- Anand Mazumdar


On Jan. 26, 2016, 12:10 a.m., Joris Van Remoortere wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/42762/
> ---
> 
> (Updated Jan. 26, 2016, 12:10 a.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> This validation is used inside resource math which in turn is used
> heavily in the code base.
> The temporary string allocations caused a significant performance
> degradation in this critical path.
> 
> 
> Diffs
> -
> 
>   src/common/roles.cpp 5be807018ff84174cf0cabb933f6828d458d3846 
> 
> Diff: https://reviews.apache.org/r/42762/diff/
> 
> 
> Testing
> ---
> 
> make check
> 
> 
> Thanks,
> 
> Joris Van Remoortere
> 
>