Integrated the profiler into the framework. We run it all the time if the persist.sampling_profiler

system property is set. Saves snapshots to the SD card.
This commit is contained in:
Bob Lee
2009-09-04 18:31:17 -07:00
parent 9cc1817d46
commit e540833fdf
5 changed files with 315 additions and 121 deletions

View File

@@ -18,6 +18,7 @@ package com.android.server;
import com.android.server.am.ActivityManagerService;
import com.android.server.status.StatusBarService;
import com.android.internal.os.SamplingProfilerIntegration;
import dalvik.system.VMRuntime;
@@ -41,6 +42,9 @@ import android.util.EventLog;
import android.util.Log;
import android.accounts.AccountManagerService;
import java.util.Timer;
import java.util.TimerTask;
class ServerThread extends Thread {
private static final String TAG = "SystemServer";
private final static boolean INCLUDE_DEMO = false;
@@ -452,6 +456,9 @@ public class SystemServer
public static final int FACTORY_TEST_LOW_LEVEL = 1;
public static final int FACTORY_TEST_HIGH_LEVEL = 2;
static Timer timer;
static final long SNAPSHOT_INTERVAL = 60 * 60 * 1000; // 1hr
/**
* This method is called from Zygote to initialize the system. This will cause the native
* services (SurfaceFlinger, AudioFlinger, etc..) to be started. After that it will call back
@@ -460,6 +467,17 @@ public class SystemServer
native public static void init1(String[] args);
public static void main(String[] args) {
if (SamplingProfilerIntegration.isEnabled()) {
SamplingProfilerIntegration.start();
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
SamplingProfilerIntegration.writeSnapshot("system_server");
}
}, SNAPSHOT_INTERVAL, SNAPSHOT_INTERVAL);
}
// The system server has to run all of the time, so it needs to be
// as efficient as possible with its memory usage.
VMRuntime.getRuntime().setTargetHeapUtilization(0.8f);