Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
tools.skpbench._hardware_android.HardwareAndroid Class Reference
Inheritance diagram for tools.skpbench._hardware_android.HardwareAndroid:
tools.skpbench._hardware.Hardware tools.skpbench._hardware_nexus_6p.HardwareNexus6P tools.skpbench._hardware_pixel2.HardwarePixel2 tools.skpbench._hardware_pixel.HardwarePixel tools.skpbench._hardware_pixel_c.HardwarePixelC

Public Member Functions

def __init__ (self, adb)
 
def __enter__ (self)
 
def __exit__ (self, exception_type, exception_value, traceback)
 
def sanity_check (self)
 
def print_debug_diagnostics (self)
 
def setDesiredClock (self, c)
 
def lock_top_three_cores (self)
 
def lock_adreno_gpu (self)
 
- Public Member Functions inherited from tools.skpbench._hardware.Hardware
def __init__ (self)
 
def __enter__ (self)
 
def __exit__ (self, exception_type, exception_value, traceback)
 
def filter_line (self, line)
 
def sanity_check (self)
 
def print_debug_diagnostics (self)
 

Public Attributes

 warmup_time
 
 desiredClock
 
- Public Attributes inherited from tools.skpbench._hardware.Hardware
 warmup_time
 

Detailed Description

Definition at line 11 of file _hardware_android.py.

Constructor & Destructor Documentation

◆ __init__()

def tools.skpbench._hardware_android.HardwareAndroid.__init__ (   self,
  adb 
)

Reimplemented from tools.skpbench._hardware.Hardware.

Reimplemented in tools.skpbench._hardware_nexus_6p.HardwareNexus6P, tools.skpbench._hardware_pixel.HardwarePixel, tools.skpbench._hardware_pixel2.HardwarePixel2, and tools.skpbench._hardware_pixel_c.HardwarePixelC.

Definition at line 12 of file _hardware_android.py.

12 def __init__(self, adb):
13 Hardware.__init__(self)
14 self.warmup_time = 5
15 self._adb = adb
16 self.desiredClock = 0.66
17
18 if self._adb.root():
19 self._adb.remount()
20
string root
Definition: scale_cpu.py:20

Member Function Documentation

◆ __enter__()

def tools.skpbench._hardware_android.HardwareAndroid.__enter__ (   self)

Reimplemented from tools.skpbench._hardware.Hardware.

Reimplemented in tools.skpbench._hardware_nexus_6p.HardwareNexus6P, tools.skpbench._hardware_pixel.HardwarePixel, tools.skpbench._hardware_pixel2.HardwarePixel2, and tools.skpbench._hardware_pixel_c.HardwarePixelC.

Definition at line 21 of file _hardware_android.py.

21 def __enter__(self):
22 Hardware.__enter__(self)
23 if not self._adb.is_root() and self._adb.root():
24 self._adb.remount()
25
26 self._adb.shell('\n'.join([
27 # turn on airplane mode.
28 '''
29 settings put global airplane_mode_on 1''',
30
31 # disable GPS.
32 '''
33 settings put secure location_providers_allowed -gps
34 settings put secure location_providers_allowed -wifi
35 settings put secure location_providers_allowed -network''']))
36
37 if self._adb.is_root():
38
39 # For explanation of variance reducing steps, see
40 # https://g3doc.corp.google.com/engedu/portal/android/g3doc/learn/develop/performance/content/best/reliable-startup-latency.md?cl=head
41
42 self._adb.shell('\n'.join([
43 # disable bluetooth, wifi, and mobile data.
44 '''
45 service call bluetooth_manager 8
46 svc wifi disable
47 svc data disable''',
48
49 # kill the gui.
50 '''
51 setprop ctl.stop media
52 setprop ctl.stop zygote
53 setprop ctl.stop surfaceflinger
54 setprop ctl.stop drm''',
55
56 # disable ASLR
57 '''
58 echo 0 > /proc/sys/kernel/randomize_va_space''',
59 ]))
60
61 self.lock_top_three_cores()
62
63 self.lock_adreno_gpu()
64
65 else:
66 print("WARNING: no adb root access; results may be unreliable.",
67 file=sys.stderr)
68
69 return self
70
def print(*args, **kwargs)
Definition: run_tests.py:49
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ __exit__()

def tools.skpbench._hardware_android.HardwareAndroid.__exit__ (   self,
  exception_type,
  exception_value,
  traceback 
)

Reimplemented from tools.skpbench._hardware.Hardware.

Definition at line 71 of file _hardware_android.py.

71 def __exit__(self, exception_type, exception_value, traceback):
72 Hardware.__exit__(self, exception_type, exception_value, traceback)
73 self._adb.reboot() # some devices struggle waking up; just hard reboot.
74

◆ lock_adreno_gpu()

def tools.skpbench._hardware_android.HardwareAndroid.lock_adreno_gpu (   self)

Definition at line 136 of file _hardware_android.py.

136 def lock_adreno_gpu(self):
137 # Use presence of /sys/class/kgsl to indicate Adreno GPU
138 exists = self._adb.check('test -d /sys/class/kgsl && echo y')
139 if (exists.strip() != 'y'):
140 print('Not attempting Adreno GPU clock locking steps')
141 return
142
143 # variance reducing changes
144 self._adb.shell('''
145 echo 0 > /sys/class/kgsl/kgsl-3d0/bus_split
146 echo 1 > /sys/class/kgsl/kgsl-3d0/force_clk_on
147 echo 10000 > /sys/class/kgsl/kgsl-3d0/idle_timer''')
148
149 freqs = self._adb.check('cat /sys/class/kgsl/kgsl-3d0/devfreq/available_frequencies').split()
150 speed = freqs[int((len(freqs)-1) * self.desiredClock)]
151
152 # Set GPU to performance mode and lock clock
153 self._adb.shell('''
154 echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor
155 echo {speed} > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq
156 echo {speed} > /sys/class/kgsl/kgsl-3d0/devfreq/min_freq'''.format(speed=speed))
157
158 # Set GPU power level
159 self._adb.shell('''
160 echo 1 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel
161 echo 1 > /sys/class/kgsl/kgsl-3d0/min_pwrlevel''')
#define check(reporter, ref, unref, make, kill)
Definition: RefCntTest.cpp:85

◆ lock_top_three_cores()

def tools.skpbench._hardware_android.HardwareAndroid.lock_top_three_cores (   self)

Definition at line 111 of file _hardware_android.py.

111 def lock_top_three_cores(self):
112 # Lock the clocks of the fastest three cores and disable others.
113 # Assumes root privlidges
114 core_count = int(self._adb.check('cat /proc/cpuinfo | grep processor | wc -l'))
115 max_speeds = []
116 for i in range(core_count):
117 khz = int(self._adb.check('cat /sys/devices/system/cpu/cpu%i/cpufreq/cpuinfo_max_freq' % i))
118 max_speeds.append((khz, i)) # the tuple's first position and it will be the sort key
119 cores_in_desc_order_of_max_speed = [a[1] for a in sorted(max_speeds, reverse=True)]
120 top_cores = cores_in_desc_order_of_max_speed[:3]
121 disable_cores = cores_in_desc_order_of_max_speed[3:]
122 if disable_cores:
123 self._adb.shell('\n'.join([('echo 0 > /sys/devices/system/cpu/cpu%i/online' % i) for i in disable_cores]))
124 # since thermal-engine will be disabled, don't pick the max freq to lock these at,
125 # pick something lower, so it doesn't get too hot (it'd reboot)
126 # get a list of available scaling frequencies and pick one 2/3 of the way up.
127 for i in top_cores:
128 freqs = self._adb.check('cat /sys/devices/system/cpu/cpu%i/cpufreq/scaling_available_frequencies' % i).split()
129 speed = freqs[int((len(freqs)-1) * self.desiredClock)]
130 self._adb.shell('''echo 1 > /sys/devices/system/cpu/cpu{id}/online
131 echo userspace > /sys/devices/system/cpu/cpu{id}/cpufreq/scaling_governor
132 echo {speed} > /sys/devices/system/cpu/cpu{id}/cpufreq/scaling_max_freq
133 echo {speed} > /sys/devices/system/cpu/cpu{id}/cpufreq/scaling_min_freq
134 echo {speed} > /sys/devices/system/cpu/cpu{id}/cpufreq/scaling_setspeed'''.format(id=i, speed=speed))
135

◆ print_debug_diagnostics()

def tools.skpbench._hardware_android.HardwareAndroid.print_debug_diagnostics (   self)
Prints any info that may help improve or debug hardware monitoring.

Reimplemented from tools.skpbench._hardware.Hardware.

Definition at line 78 of file _hardware_android.py.

78 def print_debug_diagnostics(self):
79 # search for and print thermal trip points that may have been exceeded.
80 self._adb.shell('''\
81 THERMALDIR=/sys/class/thermal
82 if [ ! -d $THERMALDIR ]; then
83 exit
84 fi
85 for ZONE in $(cd $THERMALDIR; echo thermal_zone*); do
86 cd $THERMALDIR/$ZONE
87 if [ ! -e mode ] || grep -Fxqv enabled mode || [ ! -e trip_point_0_temp ]; then
88 continue
89 fi
90 TEMP=$(cat temp)
91 TRIPPOINT=trip_point_0_temp
92 if [ $TEMP -le $(cat $TRIPPOINT) ]; then
93 echo "$ZONE ($(cat type)): temp=$TEMP <= $TRIPPOINT=$(cat $TRIPPOINT)" 1>&2
94 else
95 let i=1
96 while [ -e trip_point_${i}_temp ] &&
97 [ $TEMP -gt $(cat trip_point_${i}_temp) ]; do
98 TRIPPOINT=trip_point_${i}_temp
99 let i=i+1
100 done
101 echo "$ZONE ($(cat type)): temp=$TEMP > $TRIPPOINT=$(cat $TRIPPOINT)" 1>&2
102 fi
103 done''')
104
105 Hardware.print_debug_diagnostics(self)
106

◆ sanity_check()

def tools.skpbench._hardware_android.HardwareAndroid.sanity_check (   self)
Raises a HardwareException if any hardware state is not as expected.

Reimplemented from tools.skpbench._hardware.Hardware.

Reimplemented in tools.skpbench._hardware_nexus_6p.HardwareNexus6P, tools.skpbench._hardware_pixel.HardwarePixel, tools.skpbench._hardware_pixel2.HardwarePixel2, and tools.skpbench._hardware_pixel_c.HardwarePixelC.

Definition at line 75 of file _hardware_android.py.

75 def sanity_check(self):
76 Hardware.sanity_check(self)
77

◆ setDesiredClock()

def tools.skpbench._hardware_android.HardwareAndroid.setDesiredClock (   self,
  c 
)

Definition at line 108 of file _hardware_android.py.

108 def setDesiredClock(self, c):
109 self.desiredClock = c / 100
110

Member Data Documentation

◆ desiredClock

tools.skpbench._hardware_android.HardwareAndroid.desiredClock

Definition at line 16 of file _hardware_android.py.

◆ warmup_time

tools.skpbench._hardware_android.HardwareAndroid.warmup_time

Definition at line 14 of file _hardware_android.py.


The documentation for this class was generated from the following file: