----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/50553/ -----------------------------------------------------------
Review request for mesos, Benjamin Mahler, Joris Van Remoortere, and Klaus Ma. Repository: mesos Description ------- The current logic of `Resources::contains` is using `-=` to remove the contained resource object and the `-=` resource object will invoke `validate` which is not necessary as all of the resource objects are valid. The fix is using `subtract` instead of `-=` for `Resources::contains` , this can make sure there is no validation and can improve performance of `Resources::contains` for resources object. Diffs ----- src/common/resources.cpp 3dbff24d6859d3b1ed8589cec50170a5202cfbcb src/v1/resources.cpp 3c85dc8aa8125962b44e60806ece83a7653d0dc7 Diff: https://reviews.apache.org/r/50553/diff/ Testing ------- make make check The performance for `ports` resources was improved about `9s` with 5000 operations. Before fix with validation. ``` [ RUN ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2 Took 2.705859secs to perform 1000 'total += r' operations on ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1... Took 30.612245secs to perform 1000 'total.contains(r)' operations on ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1... Took 3.532576secs to perform 1000 'total -= r' operations on ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1... Took 2.902233secs to perform 1000 'total = total + r' operations on ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1... Took 3.608806secs 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 (43364 ms) [----------] 3 tests from ResourcesOperators/Resources_BENCHMARK_Test (193001 ms total) ``` After fix without validation. ``` [ RUN ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2 Took 2.899972secs to perform 1000 'total += r' operations on ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1... Took 21.577654secs to perform 1000 'total.contains(r)' operations on ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1... Took 3.580736secs to perform 1000 'total -= r' operations on ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1... Took 3.028626secs to perform 1000 'total = total + r' operations on ports(*):[1-2, 4-5, 7-8, 10-11, 13-14, 16-17, 1... Took 3.699126secs 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 (34789 ms) ``` Thanks, Guangya Liu