Based on the profiling result of
MESOS-8989, the range subtraction operation is about 2~3 times more expensive than that of addition. It's not obvious that this has to be the case.
The current range subtraction implementation relies on boost IntervalSet, the construction cost of the IntervalSet could be the culprit:
I think we could do better by writing a one-pass (with sorting) algorithm like that of addition.