> On 十月 19, 2016, 6:35 a.m., Guangya Liu wrote:
> > After sort the `ranges` in `validate`, the elapse time was reduced from
> > `25+s` to `26992us`.
> >
> > ```
> > [ RUN ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/2
> > Took 26992us to perform 1 'validate(r)' operations on ports(*):[1-1, 3-3,
> > 5-5, 7-7, 9-9, 11-11, 13-13...
> > [ OK ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/2
> > (55 ms)
> > ```
>
> Benjamin Mahler wrote:
> Do you have a review for the improvement?
For `validate`, my thinking is add a new API in values.cpp as `Value::Ranges
coalesce(const Value::Ranges& ranges);`
```
Value::Ranges coalesce(const Value::Ranges& ranges)
{
Value::Ranges result;
coalesce(&result, {ranges});
return result;
}
```
, and then enable the `validate` call this API to sort the resources ranges.
I think that it does not impact much even if the `Value::Ranges coalesce(const
Value::Ranges& ranges);` coalesce invalid ranges such as `[5-4, 2-1]`, as after
we `coalesce` the ranges, we still have some validation logic to validate the
invalid ranges in `validate`, what do you think this solution?
BTW: The `value::parse()` is also calling `coalesce` for invalid ranges.
Did some test with invalid ranges as following:
```
// This shows that `coalesce` will sort the ranges even
// it is invalid.
Value::Ranges ranges5 = parse("[5-4, 2-1]")->ranges();
ASSERT_EQ(2, ranges5.range_size());
EXPECT_EQ(2U, ranges5.range(0).begin());
EXPECT_EQ(1U, ranges5.range(0).end());
EXPECT_EQ(5U, ranges5.range(1).begin());
EXPECT_EQ(4U, ranges5.range(1).end());
// This shows that `coalesce` will merge the ranges.
Value::Ranges ranges6 = parse("[1-2, 3-5]")->ranges();
ASSERT_EQ(1, ranges6.range_size());
EXPECT_EQ(1U, ranges6.range(0).begin());
EXPECT_EQ(5U, ranges6.range(0).end());
// This shows that `coalesce` will sort the ranges.
Value::Ranges ranges7 = parse("[4-5, 1-2]")->ranges();
ASSERT_EQ(2, ranges7.range_size());
EXPECT_EQ(1U, ranges7.range(0).begin());
EXPECT_EQ(2U, ranges7.range(0).end());
EXPECT_EQ(4U, ranges7.range(1).begin());
EXPECT_EQ(5U, ranges7.range(1).end());
```
- Guangya
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/51033/#review153249
-----------------------------------------------------------
On 十月 18, 2016, 7:05 a.m., Guangya Liu wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/51033/
> -----------------------------------------------------------
>
> (Updated 十月 18, 2016, 7:05 a.m.)
>
>
> Review request for mesos, Benjamin Mahler and Jiang Yan Xu.
>
>
> Bugs: MESOS-5700
> https://issues.apache.org/jira/browse/MESOS-5700
>
>
> Repository: mesos
>
>
> Description
> -------
>
> Added validation benchmark test for resources.
>
>
> Diffs
> -----
>
> src/tests/resources_tests.cpp 6a12783c26f359dda835b4866b299a8fcfb3f972
>
> Diff: https://reviews.apache.org/r/51033/diff/
>
>
> Testing
> -------
>
> make
> make check
>
> ```
> ./bin/mesos-tests.sh --benchmark
> --gtest_filter="*Resources_Validate_BENCHMARK_Test.Validate/*"
> [==========] Running 4 tests from 1 test case.
> [----------] Global test environment set-up.
> [----------] 4 tests from ResourcesValidate/Resources_Validate_BENCHMARK_Test
> [ RUN ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/0
> Took 21152us to perform 5000 'validate(r)' operations on cpus(*):1;
> gpus(*):1; mem(*):128; disk(*):256
> [ OK ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/0
> (21 ms)
> [ RUN ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/1
> Took 21312us to perform 5000 'validate(r)' operations on cpus(role1):1;
> gpus(role2):1; mem(*):128; disk(...
> [ OK ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/1
> (21 ms)
> [ RUN ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/2
> Took 25.465787secs to perform 1 'validate(r)' operations on ports(*):[1-1,
> 3-3, 5-5, 7-7, 9-9, 11-11, 13-13...
> [ OK ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/2
> (25493 ms)
> [ RUN ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/3
> Took 17877us to perform 5000 'validate(r)' operations on
> disk(role)[PATH:mnt,2:path]:10
> [ OK ] ResourcesValidate/Resources_Validate_BENCHMARK_Test.Validate/3
> (18 ms)
> [----------] 4 tests from ResourcesValidate/Resources_Validate_BENCHMARK_Test
> (25553 ms total)
>
> [----------] Global test environment tear-down
> [==========] 4 tests from 1 test case ran. (25569 ms total)
> [ PASSED ] 4 tests.
> ```
>
>
> Thanks,
>
> Guangya Liu
>
>