mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
Log the GPU ceiling and mid-session clock hold changes (#2893)
* Log the GPU ceiling, steps and mid-session clock hold changes The clock log now records the GPU frequency steps and floor once in its header, probes each limit file as readable or refused, and adds the allowed GPU maximum to every sample in the CPU cur/max(of top) style, so a vendor or thermal cap on the GPU ceiling shows up and changes during a session are visible. Samples are unchanged when no limit file is readable. The limit reading is shared with the device info GPU clock range. Turning the GPU clock hold on or off during a session now logs the same line the session start logs. * Ignore a zero GPU ceiling and log hold changes in order A ceiling file that reads zero is no longer printed as a limit and is listed as refused, matching how the step list is read. The hold state line is logged under the same lock as the state change, so overlapping toggles cannot log out of order. * Find a GPU ceiling that turns readable later and probe step tables as tables A ceiling file that read zero at session start is looked for again on each sample until one is found, and the log notes where it came from. Step and floor sources are probed with the same parser that reads them, so a table with a leading zero is listed as readable.
This commit is contained in:
1 parent
de73e429cc
commit
cc93ab51c5
7 files changed
+192
-34
No files matched your search
@@ -3,6 +3,8 @@ package com.droiddeck.launcher.gpu
|
||||
import android.content.Intent
|
||||
import android.os.BatteryManager
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -40,4 +42,68 @@ class ClockLogComponentTest {
|
||||
clocks = ClockLogComponent(log).also { it.attach(context); it.stop(); it.start() }
|
||||
assertTrue(log.readText(), log.length() == 0L)
|
||||
}
|
||||
@Test fun gpuStepsAndCeilingAreParsedAndPrinted() {
|
||||
val table = tmp.newFile("gpu_available_frequencies").apply { writeText("443000000 350000000 285000000 160000000\n") }
|
||||
val ceiling = tmp.newFile("max_gpuclk").apply { writeText("285000000\n") }
|
||||
val floor = tmp.newFile("min_clock_mhz").apply { writeText("160\n") }
|
||||
val clock = tmp.newFile("gpu_clock").apply { writeText("230\n") }
|
||||
val steps = GpuLimits.first(listOf(tmp.root.path + "/missing", table.path))!!
|
||||
assertEquals(listOf(160L, 285L, 350L, 443L), steps.mhz)
|
||||
assertEquals(
|
||||
listOf(
|
||||
"gpu steps: 160 285 350 443 MHz from ${table.path}",
|
||||
"gpu ceiling from: ${ceiling.path}",
|
||||
"gpu floor: 160 MHz from ${floor.path}",
|
||||
),
|
||||
ClockLogComponent.limitLines(steps, ceiling.path, GpuLimits.first(listOf(floor.path))),
|
||||
)
|
||||
assertEquals(" | gpu 230/285(of 443) MHz", ClockLogComponent.gpuField(clock.path, ceiling.path, steps.mhz.last()))
|
||||
ceiling.writeText("443000000\n")
|
||||
assertEquals(" | gpu 230/443 MHz", ClockLogComponent.gpuField(clock.path, ceiling.path, steps.mhz.last()))
|
||||
}
|
||||
|
||||
@Test fun aZeroCeilingIsNotALimit() {
|
||||
val clock = tmp.newFile("gpu_clock").apply { writeText("0\n") }
|
||||
val zero = tmp.newFile("max_gpuclk").apply { writeText("0\n") }
|
||||
assertEquals(" | gpu 0 MHz", ClockLogComponent.gpuField(clock.path, zero.path, 443))
|
||||
assertEquals(listOf("gpu limit ${zero.path}: refused"), ClockLogComponent.probeLines("gpu limit", listOf(zero.path), ClockLogComponent::limit))
|
||||
assertEquals(listOf("gpu source ${clock.path}: readable"), ClockLogComponent.probeLines("gpu source", listOf(clock.path)))
|
||||
assertNull(ClockLogComponent.ceilingSource(listOf(zero.path)))
|
||||
zero.writeText("285000000\n")
|
||||
assertEquals(zero.path, ClockLogComponent.ceilingSource(listOf(zero.path)))
|
||||
assertEquals(" | gpu 0/285(of 443) MHz", ClockLogComponent.gpuField(clock.path, zero.path, 443))
|
||||
}
|
||||
|
||||
@Test fun aStepTableWithALeadingZeroIsReadable() {
|
||||
val steps = tmp.newFile("freq_table_mhz").apply { writeText("0 160000000 285000000\n") }
|
||||
assertEquals(listOf(160L, 285L), GpuLimits.first(listOf(steps.path))?.mhz)
|
||||
assertEquals(listOf("gpu limit ${steps.path}: readable"), ClockLogComponent.probeLines("gpu limit", listOf(steps.path), ClockLogComponent::firstStep))
|
||||
}
|
||||
|
||||
@Test fun unreadableOrMissingLimitsLeaveTheSampleUnchanged() {
|
||||
val clock = tmp.newFile("clock_mhz").apply { writeText("230\n") }
|
||||
val refused = tmp.newFolder("max_clock_mhz")
|
||||
val missing = tmp.root.path + "/gpu_max_clock"
|
||||
assertEquals(" | gpu 230 MHz", ClockLogComponent.gpuField(clock.path, null, null))
|
||||
assertEquals(" | gpu 230 MHz", ClockLogComponent.gpuField(clock.path, missing, 443))
|
||||
assertEquals(" | gpu 230 MHz", ClockLogComponent.gpuField(clock.path, refused.path, 443))
|
||||
assertEquals("", ClockLogComponent.gpuField(null, null, null))
|
||||
assertNull(GpuLimits.first(listOf(missing, refused.path)))
|
||||
assertEquals(listOf("gpu limit ${refused.path}: refused"), ClockLogComponent.probeLines("gpu limit", listOf(missing, refused.path)))
|
||||
assertEquals(
|
||||
listOf("gpu steps: nothing readable", "gpu ceiling from: nothing readable", "gpu floor: nothing readable"),
|
||||
ClockLogComponent.limitLines(null, null, null),
|
||||
)
|
||||
}
|
||||
|
||||
@Test fun aCeilingChangeMidSessionShowsInTheNextSample() {
|
||||
val clock = tmp.newFile("cur_freq").apply { writeText("443000000\n") }
|
||||
val ceiling = tmp.newFile("max_freq").apply { writeText("443000000\n") }
|
||||
val first = ClockLogComponent.gpuField(clock.path, ceiling.path, 443)
|
||||
ceiling.writeText("285000000\n")
|
||||
clock.writeText("285000000\n")
|
||||
val second = ClockLogComponent.gpuField(clock.path, ceiling.path, 443)
|
||||
assertEquals(" | gpu 443/443 MHz", first)
|
||||
assertEquals(" | gpu 285/285(of 443) MHz", second)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class GpuClockPinTest {
|
||||
private val context = RuntimeEnvironment.getApplication()
|
||||
|
||||
@After fun stop() { GpuClockPin.stop(context) }
|
||||
|
||||
@Test fun aToggleOutsideASessionSaysNothing() {
|
||||
SessionPrefs.setGpuClockPin(context, true)
|
||||
assertNull(GpuClockPin.sync(context))
|
||||
}
|
||||
|
||||
@Test fun aToggleMidSessionReportsTheHoldWithTheStartWording() {
|
||||
SessionPrefs.setGpuClockPin(context, false)
|
||||
val started = GpuClockPin.start(context)
|
||||
assertEquals("gpu clock: governed", started)
|
||||
SessionPrefs.setGpuClockPin(context, true)
|
||||
val held = GpuClockPin.sync(context)
|
||||
assertEquals("gpu clock: no /dev/kgsl-3d0, left governed", held)
|
||||
SessionPrefs.setGpuClockPin(context, false)
|
||||
assertEquals(started, GpuClockPin.sync(context))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user