mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guangya Liu <gyliu...@gmail.com>
Subject Review Request 50569: Added `isNegative` to check if the scalar resource is negative.
Date Fri, 29 Jul 2016 05:43:54 GMT

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

Review request for mesos, Benjamin Mahler, Joris Van Remoortere, and Klaus Ma.


Bugs: MESOS-5921
    https://issues.apache.org/jira/browse/MESOS-5921


Repository: mesos


Description
-------

When subtract resources finished, we need to call `validate` to
check if the scalar resource is negative so as to remove this
resource if it is negative. This is a bit heavy as the `validate`
did many stuffs.

This patch is introducing a new helper function `isNegative`
to check if the resource is a negative scalar resource.


Diffs
-----

  include/mesos/resources.hpp 88a9feabf66ed34e7e5b1c6cb7e831818e7f7883 
  include/mesos/v1/resources.hpp 054ed00a03319ae5e350542add34f497eaf79152 
  src/common/resources.cpp 3dbff24d6859d3b1ed8589cec50170a5202cfbcb 
  src/v1/resources.cpp 3c85dc8aa8125962b44e60806ece83a7653d0dc7 

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


Testing
-------

make
make check

The time of 1000 `ports` `-=` operations was reduced about `0.3s`, even though this does not
improve much, the update does make the logic more clear.

Before fix:
```
[ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2
Took 2.834335secs to perform 1000 'total += r' operations on ports(*):[1-2, 4-5, 7-8, 10-11,
13-14, 16-17, 1...
Took 21.828846secs to perform 1000 'total.contains(r)' operations on ports(*):[1-2, 4-5, 7-8,
10-11, 13-14, 16-17, 1...
Took 3.689858secs to perform 1000 'total -= r' operations on ports(*):[1-2, 4-5, 7-8, 10-11,
13-14, 16-17, 1...
Took 2.962259secs to perform 1000 'total = total + r' operations on ports(*):[1-2, 4-5, 7-8,
10-11, 13-14, 16-17, 1...
Took 3.760281secs to perform 1000 'total = total - r' operations on ports(*):[1-2, 4-5, 7-8,
10-11, 13-14, 16-17, 1...
Took 125159us to perform 1000 'r.nonRevocable()' operations on ports(*):[1-2, 4-5, 7-8, 10-11,
13-14, 16-17, 1...
[       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2 (35204 ms)
```

After fix:
```
[ RUN      ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2
Took 2.619237secs to perform 1000 'total += r' operations on ports(*):[1-2, 4-5, 7-8, 10-11,
13-14, 16-17, 1...
Took 20.528293secs to perform 1000 'total.contains(r)' operations on ports(*):[1-2, 4-5, 7-8,
10-11, 13-14, 16-17, 1...
Took 3.39984secs to perform 1000 'total -= r' operations on ports(*):[1-2, 4-5, 7-8, 10-11,
13-14, 16-17, 1...
Took 2.78301secs to perform 1000 'total = total + r' operations on ports(*):[1-2, 4-5, 7-8,
10-11, 13-14, 16-17, 1...
Took 3.399465secs to perform 1000 'total = total - r' operations on ports(*):[1-2, 4-5, 7-8,
10-11, 13-14, 16-17, 1...
Took 121055us to perform 1000 'r.nonRevocable()' operations on ports(*):[1-2, 4-5, 7-8, 10-11,
13-14, 16-17, 1...
[       OK ] ResourcesOperators/Resources_BENCHMARK_Test.Arithmetic/2 (32854 ms)
```


Thanks,

Guangya Liu


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message