Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bug: Power of an Idle Host is not 0 #127

Closed
wants to merge 4 commits into from

Conversation

wuusn
Copy link
Contributor

@wuusn wuusn commented Apr 21, 2018

check this:
In Not Spec Power Model:
When a host is idle(still active), its cpu capacity is 0, and its power should be MAX_POWER * STATIC_POWER_PERCENT .
However, when we use host.getPowerSupply().getPowerModel().getPower(0), the return value is 0, not MAX_POWER * STATIC_POWER_PERCENT .

The if condition in the #getPowerInternal seems to check if the host is active, but this check already included in the #getPower. So whenever the #getPowerInternal is used, the host is always active.

Hope this works!

function getPowerInternal is for active host, the inactive case already in the function getPower where getPowerInternal is used.
@wuusn
Copy link
Contributor Author

wuusn commented Apr 21, 2018

I found this when I change the HOSTS value in the PowerExample.
I am not sure when a host idle in the simulation tool like this, should its cpu utilization be 0, and/or its UtilizationOfCpuMips be 0.
If so, getUtilizationOfCpuMips() > 0 is not a good way to check if a host isActive , ==0 also can be active(idle).

manoelcampos added a commit that referenced this pull request Apr 21, 2018
- Merge branch 'pr127' into dev
@manoelcampos
Copy link
Collaborator

Thanks for contributing. We are really needing people to test the released versions.

@manoelcampos
Copy link
Collaborator

manoelcampos commented Apr 22, 2018

About your question, there is an active attribute in the Host that is used to inform if it's active or not.

@wuusn
Copy link
Contributor Author

wuusn commented Apr 22, 2018

@manoelcampos please check the line 904 in the HostSimple.java#addStateHistory, it used the cpu utilization >0 to check the host state, not the attribute you mentioned about. And this host state check affects lots of examples when we get the utilization history.

@wuusn
Copy link
Contributor Author

wuusn commented Apr 23, 2018

also check HostPowerSupply#getEnergyLinearInterpolation, not consider the idle state,
this method affects the DatacenterSimple#getPower.

Not considering the IDLE state seems a Big problem.

@manoelcampos
Copy link
Collaborator

manoelcampos commented Apr 23, 2018

These issues are all inherited from CloudSim and most of my work with CoudSim Plus is to fix them.
I've changed the line in HostSimple.java#addStateHistory to store the value of the active attribute.

About the HostPowerSupply#getEnergyLinearInterpolation it's just an estimation. This way, if you want to check the actual power consumption, you have to use the Host StateHistory to compute it.

I've changed the documentation of the PowerSupply#getEnergyLinearInterpolation, DatacenterSimple#getDatacenterPowerUsageForTimeSpan, Datacenter#getPower() and Datacenter#getPowerInKWattsHour().

I've included the issue #128 to enable actually powering Hosts on and off.

I've just realized the PowerSupply was just delegating everything to PowerModel. After all these refactorings, I merged the former into the latter and removed the former. Now, the way to use PowerModel is as before the release 2.0.0, but with all the benefits of using regular classes to implement power-aware simulations, namely DatacenterSimple, HostSimple and VmSimple.

Check the new 2.2.0 version. Thanks for contributing.

@wuusn
Copy link
Contributor Author

wuusn commented Apr 23, 2018

@manoelcampos

Glad to see your quick reply,

I made some suggestions based on version 2.10, and not have time to check the newest version yet, I post them here , just for your information.

Cause the old cloudsim had not considering the state of host completely, especially for the idle state, many power-related methods are not accurate.

Here, I list some methods I found were not correct enough and give some advise.

  1. subclasses of Host like HostSimple

#getUtilizationHistory
Use a dynamic length for utilizationHistory instead of a DEF_MAX_HISTORY_ENTRIES.
Cause the fixed-length, the old version used MathUtil.trimZeroTail(utilizationHistory) to delete the 0 case to give a useful history. However the 0 case included the idle state.

#addStateHistory
Use attribute or method like state, active, #isActived to indicate the state of the host instead of the cpu utilization.

#is/setActive confused with #is/setFailed
They are the same behavior to indicate the state of a host(i am not sure enough), but isActive not equals to isFailed, for example, when we use setFailed(true), isActive is still true.

  1. subclasses of PowerSupply like SimpleHostPowerSupply

#getEnergyLinearInterpolation
this method will affect datacenter.#getPower() or #getPowerInKWattsHour
take the idle state into consideration.

change

    if (fromUtilization == 0) {
        return 0;
     }

to

    if(!host.isActive()) return 0;
  1. host.getPowerSupply().getPower(cpuUsage) used a latest host state to compute the power. if a host shutdown during the simulation, all the power consumption before it will be lost. I fixed this used a state history.

  2. The order of Host#getUtilizationHistory is confused. The way you print is actually different from PowerExample and MigrationExample2_PowerUsage. I found this order is latest-first, which means the newest time slot is at the beginning of the array of #utilizationHistory, you can check in VmUtilizationHistory#addUtilizationHistoryValue's history.add(0, utilization);

  3. confused comment line 67-69 in cloudsimplus.examples.dynamic.DynamicHostCreation, is the 5th should be 3th.

  4. confused about time when I use simulation#addOnClockTickListener. I use BasicFirstExample as a example. When I set the scheduling_interval of datacenter to 10, and add a addOnClockTickListener to simulation to print every info.getTime().

Excepted:

      10.1
      20.1
      30.1
      40.1
      50.1
      60.1
      70.1
      80.1
      90.1
      100.1

Actual:

      10.1
      20.1
      40.1
      50.1
      60.1
      70.1
      80.1
      90.1
      100.1
      100.21
      100.21

some time will be missing and some time will be multiplied.

That's all for so far, maybe you have fixed them in the newest version, just for you information.

cause I don't have enough time to do my experiment, and this project changes so fast, I will do my simulation experiment on the old version(2.1.0), After that I will check the newest version.

Sorry for my delay, I will check that as soon as possible.

Thanks.

@manoelcampos manoelcampos changed the title Fix Bug: Power of a Idle Host is NOT 0 Fix Bug: Power of a Idle Host is not 0 Apr 24, 2018
@manoelcampos
Copy link
Collaborator

manoelcampos commented Apr 24, 2018

Thanks for your valuable information.
Check out my comments below.

HostSimple

  • getUtilizationHistory: the Host utilization history array length is being computed based on the VM having the max history length. The array trim was removed.
  • addStateHistory - it was already fixed
  • is/setActive confused with #is/setFailed - when a Host is set fo failed, it's now set to inactive too

Subclasses of PowerSupply like SimpleHostPowerSupply

  • The PowerSupply was removed in version 2.2.0 and its methods merged into PowerModel.
    • getEnergyLinearInterpolation - changed to check the Host state using the active attribute
  • host.getPowerSupply().getPower(cpuUsage) - now such a call is host.getPowerModel().getPower(cpuUsage)
    • used a latest host state to compute the power: I realized the issue in MigrationExample2_PowerUsage.
      I changed the PowerModel.getPower documentation to indicate that such power data is just available while the Host is active. I also changed the if inside the PowerModelAbstract#getPower(final double utilization)
      from if(host.getVmList().isEmpty() && !host.isActive()) to if(!host.isActive()), since an empty VM list doesn't mean the Host is inactive.
  • The order of Host#getUtilizationHistory is confused - The UtilizationHistory class stores values in inverse order. I updated the Host#getUtilizationHistory to provide such an information. I changed the MigrationExample2_PowerUsage to print time in reverse order.
  • confused comment line 67-69 - fixed
  • confused about time when I use simulation#addOnClockTickListener - fixed

@wuusn wuusn changed the title Fix Bug: Power of a Idle Host is not 0 Fix Bug: Power of an Idle Host is not 0 May 2, 2018
@manoelcampos manoelcampos self-requested a review October 17, 2018 21:03
@manoelcampos manoelcampos added the power Issues related to the Power Module label Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug power Issues related to the Power Module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants