Allow to specify shmem size in script.
Change-Id: Icd2b7db1780a81f8760759dd759bc4531e018b6b
diff --git a/protos/perfetto/config/perfetto_config.proto b/protos/perfetto/config/perfetto_config.proto
index a9ff219..c70bd4a 100644
--- a/protos/perfetto/config/perfetto_config.proto
+++ b/protos/perfetto/config/perfetto_config.proto
@@ -743,6 +743,11 @@
// Size of the shared memory buffer between the profiled processes and
// heapprofd. Defaults to 8 MiB. If larger than 500 MiB, truncated to 500
// MiB.
+ //
+ // Needs to be:
+ // * at least 8192,
+ // * a power of two,
+ // * a multiple of 4096.
optional uint64 shmem_size_bytes = 8;
}
diff --git a/protos/perfetto/config/profiling/heapprofd_config.proto b/protos/perfetto/config/profiling/heapprofd_config.proto
index 04b16dc..ad2548c 100644
--- a/protos/perfetto/config/profiling/heapprofd_config.proto
+++ b/protos/perfetto/config/profiling/heapprofd_config.proto
@@ -59,5 +59,10 @@
// Size of the shared memory buffer between the profiled processes and
// heapprofd. Defaults to 8 MiB. If larger than 500 MiB, truncated to 500
// MiB.
+ //
+ // Needs to be:
+ // * at least 8192,
+ // * a power of two,
+ // * a multiple of 4096.
optional uint64 shmem_size_bytes = 8;
}
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 67e1098..2c49b02 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -3647,6 +3647,11 @@
// Size of the shared memory buffer between the profiled processes and
// heapprofd. Defaults to 8 MiB. If larger than 500 MiB, truncated to 500
// MiB.
+ //
+ // Needs to be:
+ // * at least 8192,
+ // * a power of two,
+ // * a multiple of 4096.
optional uint64 shmem_size_bytes = 8;
}
diff --git a/src/perfetto_cmd/perfetto_config.descriptor.h b/src/perfetto_cmd/perfetto_config.descriptor.h
index 38e8604..7eb3ce7 100644
--- a/src/perfetto_cmd/perfetto_config.descriptor.h
+++ b/src/perfetto_cmd/perfetto_config.descriptor.h
@@ -12,7 +12,7 @@
// SHA1(tools/gen_binary_descriptors)
// e329b1e1e964417db57f83d8ecf081e041923e78
// SHA1(protos/perfetto/config/perfetto_config.proto)
-// 28a602336155eef6cbee091ec61dd38641a5f7b9
+// f02b3413d4ff0373b84692271d5c667121fa357d
// This is the proto PerfettoConfig encoded as a ProtoFileDescriptor to allow
// for reflection without libprotobuf full/non-lite protos.
diff --git a/tools/heap_profile b/tools/heap_profile
index 0e29f86..942c807 100755
--- a/tools/heap_profile
+++ b/tools/heap_profile
@@ -88,6 +88,7 @@
heapprofd_config {{
all: {all}
+ shmem_size_bytes: {shmem_size}
sampling_interval_bytes: {interval}
{target_cfg}
{continuous_dump_cfg}
@@ -136,6 +137,10 @@
parser.add_argument("--disable-selinux", action="store_true",
help="Disable SELinux enforcement for duration of "
"profile")
+ parser.add_argument("--shmem-size", help="Size of buffer between client and "
+ "heapprofd. Default 8MiB. Needs to be a power of two "
+ "multiple of 4096, at least 8192.", type=int,
+ default=8 * 1048576)
args = parser.parse_args()
@@ -149,6 +154,15 @@
if args.interval is None:
print("FATAL: No interval given.", file=sys.stderr)
fail = True
+ if args.shmem_size % 4096:
+ print("FATAL: shmem-size is not a multiple of 4096.", file=sys.stderr)
+ fail = True
+ if args.shmem_size < 8192:
+ print("FATAL: shmem-size is less than 8192.", file=sys.stderr)
+ fail = True
+ if args.shmem_size & (args.shmem_size - 1):
+ print("FATAL: shmem-size is not a power of two.", file=sys.stderr)
+ fail = True
if fail:
parser.print_help()
return 1
@@ -179,7 +193,8 @@
dump_interval=args.continuous_dump)
cfg = CFG.format(all=str(args.all == True).lower(), interval=args.interval,
duration=args.duration, target_cfg=target_cfg,
- continuous_dump_cfg=continuous_dump_cfg)
+ continuous_dump_cfg=continuous_dump_cfg,
+ shmem_size=args.shmem_size)
if args.disable_selinux:
enforcing = subprocess.check_output(['adb', 'shell', 'getenforce'])