Commit 9b59da7a by Tomasz Ciesielczyk

power buffer fix

parent 01d1ed41
......@@ -52,8 +52,11 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.30" level="project" />
<orderEntry type="module" module-name="m2dc-rtm-utils_main" />
<orderEntry type="library" name="Gradle: org.ojalgo:ojalgo:45.1.0" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.2.30" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.30" level="project" />
<orderEntry type="library" name="Gradle: com.google.code.gson:gson:2.8.1" level="project" />
<orderEntry type="library" name="Gradle: org.apache.commons:commons-configuration2:2.1.1" level="project" />
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-log4j12:1.7.25" level="project" />
......@@ -63,15 +66,12 @@
<orderEntry type="library" name="Gradle: org.apache.directory.studio:org.apache.commons.codec:1.8" level="project" />
<orderEntry type="library" name="Gradle: org.apache.commons:commons-lang3:3.4" level="project" />
<orderEntry type="library" name="Gradle: commons-beanutils:commons-beanutils:1.9.3" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0" level="project" />
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Gradle: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Gradle: xmlpull:xmlpull:1.1.3.1" level="project" />
<orderEntry type="library" name="Gradle: xpp3:xpp3_min:1.1.4c" level="project" />
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.8" level="project" />
<orderEntry type="library" name="Gradle: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.30" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.2.30" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.30" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -5,7 +5,6 @@ import org.slf4j.LoggerFactory
import psnc.m2dc.rtm.CurrentState
import psnc.m2dc.rtm.StorageKeys
import psnc.m2dc.rtm.model.rest.ESMPowerPolicy
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.rpm.RPMApi
import psnc.m2dc.rtm.utils.logError
import psnc.m2dc.rtm.utils.printConsole
......@@ -48,7 +47,7 @@ class ESMApi {
fun optimize(): Boolean {
try {
val powerUsage = RPMApi.instance().getPowerUsageList().sum()
val state = CurrentState(powerUsage * (1 + Keys.PCM.power_buffer.get()))//, DAO.Chassis.getRCUUtil())
val state = CurrentState(powerUsage)// * (1 + Keys.PCM.power_buffer.get()))//, DAO.Chassis.getRCUUtil())
printConsole("testx $state")
ESMWorker.start(state)
return true
......
package psnc.m2dc.rtm.esm
import psnc.m2dc.rtm.pcm.PCMApi
import psnc.m2dc.rtm.pcm.algorithm.Evaluation
import psnc.m2dc.rtm.pcm.algorithm.Solver
import psnc.m2dc.rtm.properties.keys.Keys
......@@ -8,4 +9,6 @@ import psnc.m2dc.rtm.properties.keys.Keys
*
* Created by Tomek on 2018-06-25.
*/
class ESMSolver(e: Evaluation) : Solver(e, SolverMode.esm, Keys.ESM.power_buffer.get())
class ESMSolver(e: Evaluation) : Solver(e, SolverMode.esm,
Keys.ESM.power_buffer.get() *
(PCMApi.instance().getPowerLimit() ?: 0.0))
......@@ -31,8 +31,9 @@ object ActionPredictor {
listOf(0.1, 0.15, 0.15).forEach { lvl ->
val powerSpan = Math.min(lvl * maximumPowerIncrease, lvl * powercapRatio)
powerUsage + pcmBuffer
val state = CurrentState(pcmBuffer + powerSpan + minPower)
// powerUsage + pcmBuffer
// val state = CurrentState(pcmBuffer + powerSpan + minPower)
val state = CurrentState(powerSpan + minPower)
val algoResult = PCMAlgorithm(state).next()
val toList = algoResult.getResources().map { resource ->
resource.id to algoResult.getActions(resource)
......
......@@ -135,8 +135,8 @@ class PCMApi() {
// printConsole("checkLimits $limits")
if (limits.limitExceeded) {// || Keys.PCM.simple_performance_restore.get()) {
Timer.start()
val state = CurrentState(limits.currentPowerUsage +
((StorageKeys.POWER_LIMIT ?: 0.0) * Keys.PCM.power_buffer.get()))
val state = CurrentState(limits.currentPowerUsage)//+
// ((StorageKeys.POWER_LIMIT ?: 0.0) * Keys.PCM.power_buffer.get()))
Timer.stop()
PCMWorker.start(state)
......
......@@ -8,6 +8,7 @@ import psnc.m2dc.rtm.properties.keys.Keys
*
* Created by Tomek on 2018-06-25.
*/
class PCMSolver(e: Evaluation) : Solver(e, SolverMode.pcm, Keys.PCM.power_buffer.get()) {
class PCMSolver(e: Evaluation) : Solver(e, SolverMode.pcm,Keys.PCM.power_buffer.get() *
(PCMApi.instance().getPowerLimit() ?: 0.0)) {
}
\ No newline at end of file
......@@ -3,7 +3,6 @@ package psnc.m2dc.rtm.pcm
import psnc.m2dc.rtm.ActionCache
import psnc.m2dc.rtm.CurrentState
import psnc.m2dc.rtm.RTMWorker
import psnc.m2dc.rtm.StorageKeys
import psnc.m2dc.rtm.esm.ESMWorker
import psnc.m2dc.rtm.properties.keys.Keys
import psnc.m2dc.rtm.utils.Timer
......@@ -76,7 +75,7 @@ class PCMWorker(var state: CurrentState) : RTMWorker() {
} else {
println("actioncache: " + ActionCache.toString())
println(" new: " +actions.toJson())
println(" new: " + actions.toJson())
startActions(actions, state)
}
this.currentIteration++
......@@ -117,8 +116,8 @@ class PCMWorker(var state: CurrentState) : RTMWorker() {
private fun updateLimits() {
synchronized(lock) {
val limits = PCMApi.instance().checkLimits()
this.state = CurrentState(limits.currentPowerUsage.toFloat() +
((StorageKeys.POWER_LIMIT ?: 0.0) * Keys.PCM.power_buffer.get()))
this.state = CurrentState(limits.currentPowerUsage)
// + ((StorageKeys.POWER_LIMIT ?: 0.0) * Keys.PCM.power_buffer.get()))
this.algorithm.updateState(state)
// this.state.currentPowerOverLimit = -limit.powerBudget.toFloat()
printConsole("update limits:${limits.toJson()} : ${this.state.currentPowerOverLimit} ")
......
......@@ -269,7 +269,7 @@ advancedPriorityMode: Boolean = true) {
weight = Math.abs(powerChange)
}
if (print)
println("${currentState.perfLevel}/${perfLvlx} gain $gainX, cost: $costX ${(gainX - costX) * Math.abs(
println("${currentState.perfLevel}/$perfLvlx gain $gainX, cost: $costX ${(gainX - costX) * Math.abs(
powerChange)}")
return (gainX - costX) * weight
......
......@@ -53,9 +53,9 @@ open class Solver(e: Evaluation, var mode: SolverMode, val powerBuffer: Double)
}
init {
val limit = PCMApi.instance().getPowerLimit() ?: 0.0
logInfo("current budget: ${-e.powerOverLimit}, buffer: $powerBuffer, actual limit: ${limit}")
currentBudget = -(e.powerOverLimit + powerBuffer * limit)
logInfo("current budget: ${-e.powerOverLimit}, buffer: $powerBuffer ")
currentBudget = -(e.powerOverLimit + powerBuffer )
var max = 0
e.listResources().forEach { resource ->
val state = e.getState(resource)!!
......
......@@ -61,7 +61,7 @@ object RTMScannerWorker {
LightStorage.saveStorage()
iter = 0
} else if (iter > esmRatio) {
ActionPredictor.predict(PCMApi.instance().getPowerLimit())
ActionPredictor.predict(PCMApi.instance().getPowerLimit()).generateScripts()
if (Keys.ESM.status.get()) {
ESMApi.instance().optimize()
} else {
......
package psnc.m2dc.rtm.commands.java
val APP_VERSION = "1.0.426_33338"
\ No newline at end of file
val APP_VERSION = "1.0.426_53008"
\ No newline at end of file
package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.426_51333"
\ No newline at end of file
const val APP_VERSION = "1.1.426_53009"
\ No newline at end of file
......@@ -7,6 +7,7 @@ import psnc.m2dc.rtm.client.RTMRestClient
import psnc.m2dc.rtm.client.utils.debugConsole
import psnc.m2dc.rtm.rest.Handlers
import psnc.m2dc.rtm.rest.HandlersMap
import psnc.m2dc.rtm.utils.printConsole
import psnc.m2dc.rtm.utils.toJson
/**
......@@ -38,7 +39,7 @@ class StatusCommand : Runnable {
Option.save -> saveState()?.toJson(true)
Option.resources -> listResources()?.toJson(true)
Option.nodelist -> listNodes()?.toJson(true)
Option.nodeid -> listNodeIds()?.joinToString(separator = ",") { it }
Option.nodeid -> listNodeIds()?.joinToString(separator = ",") { it }?.printConsole()
}
......
......@@ -179,6 +179,9 @@ fun printConsole(msg: String, trimMessage: Boolean = true) {
RTMProperties.log.debug(result)
}
fun Any.printConsole(trimMessage: Boolean = true) {
printConsole(this.toString(), trimMessage)
}
fun HashMap<String, Double>.sum(): Double {
var sum = 0.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment