1717import static java .nio .charset .StandardCharsets .UTF_8 ;
1818
1919import com .google .common .collect .ImmutableList ;
20+ import com .google .common .flogger .GoogleLogger ;
2021import java .io .ByteArrayOutputStream ;
2122import java .io .FileDescriptor ;
2223import java .io .FileInputStream ;
@@ -93,6 +94,8 @@ final class CpuProfiler {
9394 JNI .load ();
9495 }
9596
97+ private static final GoogleLogger logger = GoogleLogger .forEnclosingClass ();
98+
9699 private final PprofWriter pprof ;
97100
98101 private CpuProfiler (OutputStream out , Duration period ) {
@@ -126,9 +129,10 @@ static StarlarkThread setStarlarkThread(StarlarkThread thread) {
126129 }
127130
128131 /** Start the profiler. */
129- static void start (OutputStream out , Duration period ) {
132+ static boolean start (OutputStream out , Duration period ) {
130133 if (!supported ()) {
131- throw new UnsupportedOperationException ("this platform does not support Starlark profiling" );
134+ logger .atWarning ().log ("--starlark_cpu_profile is unsupported on this platform" );
135+ return false ;
132136 }
133137 if (instance != null ) {
134138 throw new IllegalStateException ("profiler started twice without intervening stop" );
@@ -140,6 +144,7 @@ static void start(OutputStream out, Duration period) {
140144 }
141145
142146 instance = new CpuProfiler (out , period );
147+ return true ;
143148 }
144149
145150 /** Stop the profiler and wait for the log to be written. */
0 commit comments