mesos / storm

Storm on Mesos!
Apache License 2.0
139 stars 66 forks source link

use fixed point math for Offer resource calculations #161

Open erikdw opened 8 years ago

erikdw commented 8 years ago

Problem Description

During testing of PR #154 we noticed that the floating point math done in the AggregatedOffers logic can lead to incorrectly accounting for the resources used. e.g., with CPUs available being 4.1 and then having a worker need 1.1 CPUs, the subtraction lead to the CPUs being 2.9999999999999996 instead of 3.0 as expected. [1]

Effect?

The effect of this will be a failure to squeeze every bit of resources out of a set of Offers.

Implementation Options

Switch from Double/double to one of these fixed-point implementations:

  1. BigDecimal
  2. decimal4j (supposedly more performant than BigDecimal, although I'm not sure that's a concern for us)

    Appendix

[1] Specifically, this value is the "bad" one: CreateMesosWorkerSlot()'s aggregatedOffers.availableResources[0].value.totalAvailableResource.