Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
66 stars 23 forks source link

Negative CPU USE for workloads below 2% #233

Closed JacobValdemar closed 9 months ago

JacobValdemar commented 9 months ago

Bug description

Current consumption profiles is less than zero in some area where workload is above 0. This means that for 0%-2% CPU usage, power consumption will be below zero; which results in estimated negative operational emissions.

See below visualization of current consumption profiles (© own work)

billede

Example with Intel Xeon Platinum

$PowerConsumption_{IntelXeonPlatinum}(x=0)=171.1813\ln(0.0354+(x36.8953))-10.1336)≈-582W$

$PowerConsumption_{IntelXeonPlatinum}(x)=0W \rightarrow x≈0.027797$

To Reproduce

curl -X 'POST' \
  'https://dev.api.boavizta.org/v1/cloud/instance?verbose=true&criteria=gwp' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "provider": "aws",
  "instance_type": "a1.4xlarge",
  "usage": {
    "usage_location": "IRL",
    "time_workload": [
      {
        "time_percentage": 100,
        "load_percentage": 1
      }
    ]
  }
}'
Response ```json { "impacts": { "gwp": { "embedded": { "value": 457.21, "significant_figures": 5, "min": 261.51, "max": 636.59, "warnings": [ "End of life is not included in the calculation" ] }, "use": { "value": 40.725, "significant_figures": 5, "min": 36.744, "max": 48.993 }, "unit": "kgCO2eq", "description": "Total climate change" } }, "verbose": { "duration": { "value": 35040, "unit": "hours" }, ... "CPU-1": { "impacts": { "gwp": { "embedded": { "value": 22.105, "significant_figures": 5, "min": 14.146, "max": 47.734, "warnings": [ "End of life is not included in the calculation" ] }, "use": { "value": -91.662, "significant_figures": 5, "min": -91.662, "max": -91.662 }, "unit": "kgCO2eq", "description": "Total climate change" } }, ... ```

Expected behavior

$PowerConsumption(x)>0, x \in [0.000,1.000]$

Expected that consumption profiles was created so that W>0 for workload>0. Actually would have expected them to be way higher than 0 at workload=0%.

JSON OUTPUT

Additional context

Applies both to dev and main

da-ekchajzer commented 9 months ago

@samuelrince any thought ?

samuelrince commented 9 months ago

Ok I've found the issue!

Basically, we're trying to fit the model for Graviton (ARM), but starting from a power-hungry Intel (x86) (default archetype) and we have strict limits for the model (based on Intel's). The result is that the regression "tries" to approach Graviton by minimizing the Intel model as much as possible, but failed at it.

Workloads 0% 10% 50% 100%
Power [W] (default archetype) 35.6 76.6 182 260
Power [W] (estimation from Benjamin Davy) 5 13 30 41
Power [W] (Currently) -8.19 4.73 42.8 74.6
Power [W] (Quick fix) 4.77 12.9 30.0 40.8

The "quick fix" is to relax the boundaries of the model parameters a little.

All the tests passed with this correction, but I want to take the opportunity to strengthen this process and the testing of this feature.

Thanks @JacobValdemar for reporting it!


PS: There is an issue with the formula above.

The power consumption formula is: $PC(x) = a \ln(b\ {\color{red}}\ (x\ {\color{red}+}\ c)) + d$

Thus: $PowerConsumption_{IntelXeonPlatinum}(x=0)=171.1813\ln(0.0354(x+36.8953))-10.1336)≈35W$

JacobValdemar commented 9 months ago

@samuelrince oh damn! The formula in the documentation is wrong then. And that means the function goes from 0 to 100 instead of 0 to 1. Makes sense! 😄