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


Ship it!




Ship It!

- Jiang Yan Xu


On Aug. 3, 2016, 12:36 a.m., Anindya Sinha wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/50738/
> -----------------------------------------------------------
> 
> (Updated Aug. 3, 2016, 12:36 a.m.)
> 
> 
> Review request for mesos and Jiang Yan Xu.
> 
> 
> Bugs: MESOS-5978
>     https://issues.apache.org/jira/browse/MESOS-5978
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Avoid multiple calls to addable and subtractable in the arithmetic
> operations in Resources. While adding or subtracting two Resources
> objects, check for addable() is done in Resources::add(), and check
> for subtractable() is done in Resources::subtract(). Since the
> Resource_ class is private and += and -= operators are only called
> from within Resources::add() and Resources::subtract(); so we do not
> need to call addable() or subtractable() again.
> 
> This improves the performance of += and -= operators by about 25%.
> 
> 
> Diffs
> -----
> 
>   include/mesos/resources.hpp 829f39d7c1af3eb4e2efd97e01f87acf7c854bb4 
>   include/mesos/v1/resources.hpp f3c5f315c3701e37aeb8fd468ee288829461338e 
>   src/common/resources.cpp b5d20d699553cb5e0aae1718d8a5d73e9192f10a 
>   src/v1/resources.cpp 71eedb29ccacfbd616f5088890d759ab669f8ce7 
> 
> Diff: https://reviews.apache.org/r/50738/diff/
> 
> 
> Testing
> -------
> 
> Tests ok. Ran the benchmark for resources arithmetic and observed about 30% 
> improvement in arithmetic operations for scalars.
> 
> HEAD
> ====
> 
> [==========] Running 4 tests from 1 test case.
> [----------] Global test environment set-up.
> [----------] 4 tests from ResourcesOperators/Resources_BENCHMARK_Test
> [ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/0
> Took 73155us to perform 50000 'total += r' operations on cpus(*):1; 
> gpus(*):1; mem(*):128; disk(*):256
> Took 78983us to perform 50000 'total -= r' operations on cpus(*):1; 
> gpus(*):1; mem(*):128; disk(*):256
> Took 294658us to perform 50000 'total = total + r' operations on cpus(*):1; 
> gpus(*):1; mem(*):128; disk(*):256
> Took 302820us to perform 50000 'total = total - r' operations on cpus(*):1; 
> gpus(*):1; mem(*):128; disk(*):256
> [       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/0 (752 ms)
> [ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/1
> Took 4.171325secs to perform 10 'total += r' operations on cpus(0, 
> principal_0, {key_0: value_0}):1; gpus(...
> Took 4.320892secs to perform 10 'total -= r' operations on cpus(0, 
> principal_0, {key_0: value_0}):1; gpus(...
> Took 4.239706secs to perform 10 'total = total + r' operations on cpus(0, 
> principal_0, {key_0: value_0}):1; gpus(...
> Took 4.413952secs to perform 10 'total = total - r' operations on cpus(0, 
> principal_0, {key_0: value_0}):1; gpus(...
> [       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/1 (17196 
> ms)
> [ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2
> Took 475848us to perform 1000 'total += r' operations on ports(*):[1-2, 4-5, 
> 7-8, 10-11, 13-14, 16-17, 1...
> Took 2270us to perform 1000 'total -= r' operations on ports(*):[1-2, 4-5, 
> 7-8, 10-11, 13-14, 16-17, 1...
> Took 562153us to perform 1000 'total = total + r' operations on 
> ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1...
> Took 2357us to perform 1000 'total = total - r' operations on ports(*):[1-2, 
> 4-5, 7-8, 10-11, 13-14, 16-17, 1...
> [       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2 (1044 
> ms)
> [ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/3
> Took 60524us to perform 50000 'total += r' operations on cpus(*):1; 
> mem(*):128; disk(test)[persistentId:...
> Took 64486us to perform 50000 'total -= r' operations on cpus(*):1; 
> mem(*):128; disk(test)[persistentId:...
> Took 343349us to perform 50000 'total = total + r' operations on cpus(*):1; 
> mem(*):128; disk(test)[persistentId:...
> Took 342624us to perform 50000 'total = total - r' operations on cpus(*):1; 
> mem(*):128; disk(test)[persistentId:...
> [       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/3 (812 ms)
> [----------] 4 tests from ResourcesOperators/Resources_BENCHMARK_Test (19804 
> ms total)
> 
> [----------] Global test environment tear-down
> [==========] 4 tests from 1 test case ran. (19820 ms total)
> [  PASSED  ] 4 tests.
> 
> With this patch
> ===============
> 
> [==========] Running 4 tests from 1 test case.
> [----------] Global test environment set-up.
> [----------] 4 tests from ResourcesOperators/Resources_BENCHMARK_Test
> [ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/0
> Took 53892us to perform 50000 'total += r' operations on cpus(*):1; 
> gpus(*):1; mem(*):128; disk(*):256
> Took 59655us to perform 50000 'total -= r' operations on cpus(*):1; 
> gpus(*):1; mem(*):128; disk(*):256
> Took 268692us to perform 50000 'total = total + r' operations on cpus(*):1; 
> gpus(*):1; mem(*):128; disk(*):256
> Took 266523us to perform 50000 'total = total - r' operations on cpus(*):1; 
> gpus(*):1; mem(*):128; disk(*):256
> [       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/0 (649 ms)
> [ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/1
> Took 4.120889secs to perform 10 'total += r' operations on cpus(0, 
> principal_0, {key_0: value_0}):1; gpus(...
> Took 4.354236secs to perform 10 'total -= r' operations on cpus(0, 
> principal_0, {key_0: value_0}):1; gpus(...
> Took 4.241712secs to perform 10 'total = total + r' operations on cpus(0, 
> principal_0, {key_0: value_0}):1; gpus(...
> Took 4.417649secs to perform 10 'total = total - r' operations on cpus(0, 
> principal_0, {key_0: value_0}):1; gpus(...
> [       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/1 (17186 
> ms)
> [ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2
> Took 483411us to perform 1000 'total += r' operations on ports(*):[1-2, 4-5, 
> 7-8, 10-11, 13-14, 16-17, 1...
> Took 2276us to perform 1000 'total -= r' operations on ports(*):[1-2, 4-5, 
> 7-8, 10-11, 13-14, 16-17, 1...
> Took 562171us to perform 1000 'total = total + r' operations on 
> ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1...
> Took 2353us to perform 1000 'total = total - r' operations on ports(*):[1-2, 
> 4-5, 7-8, 10-11, 13-14, 16-17, 1...
> [       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2 (1051 
> ms)
> [ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/3
> Took 40168us to perform 50000 'total += r' operations on cpus(*):1; 
> mem(*):128; disk(test)[persistentId:...
> Took 44792us to perform 50000 'total -= r' operations on cpus(*):1; 
> mem(*):128; disk(test)[persistentId:...
> Took 330984us to perform 50000 'total = total + r' operations on cpus(*):1; 
> mem(*):128; disk(test)[persistentId:...
> Took 328513us to perform 50000 'total = total - r' operations on cpus(*):1; 
> mem(*):128; disk(test)[persistentId:...
> [       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/3 (745 ms)
> [----------] 4 tests from ResourcesOperators/Resources_BENCHMARK_Test (19631 
> ms total)
> 
> [----------] Global test environment tear-down
> [==========] 4 tests from 1 test case ran. (19643 ms total)
> [  PASSED  ] 4 tests.
> 
> 
> Thanks,
> 
> Anindya Sinha
> 
>

Reply via email to