Skip to contentSkip to conversation

perf record: Display data size on pipe mode

PATCH Applied Namhyung Kim 2 participants 4 messages Jan 12, 2024 – Feb 7, 2024 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf record: Display data size on pipe mode

Currently pipe mode doesn't set the file size and it results in a misleading message of 0 data size at the end. Although it might miss some accounting for pipe header or more, just displaying the data size would reduce the possible confusion.

Before:

  $ perf record -o- perf test -w noploop | perf report -i- -q --percent-limit=1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.000 MB - ]    <======  (here)
      99.58%  perf     perf                  [.] noploop

After:

  $ perf record -o- perf test -w noploop | perf report -i- -q --percent-limit=1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.229 MB - ]
      99.46%  perf     perf                  [.] noploop
---
 tools/perf/builtin-record.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/builtin-record.c +4 -1
index 91e6828c38cc..21ebcb04f1d8 100644
@@ -1773,8 +1773,11 @@ record__finish_output(struct record *rec)
 	struct perf_data *data = &rec->data;
 	int fd = perf_data__fd(data);
 
-	if (data->is_pipe)
+	if (data->is_pipe) {
+		/* Just to display approx. size */
+		data->file.size = rec->bytes_written;
 		return;
+	}
 
 	rec->session->header.data_size += rec->bytes_written;
 	data->file.size = lseek(perf_data__fd(data), 0, SEEK_CUR);
Signature · 1 line
2.43.0.275.g3460e3d667-goog
author maintainer
#1 lore raw

Ping!

Quoted 44 lines · Namhyung Kim

Currently pipe mode doesn't set the file size and it results in a misleading message of 0 data size at the end. Although it might miss some accounting for pipe header or more, just displaying the data size would reduce the possible confusion.

Before:

  $ perf record -o- perf test -w noploop | perf report -i- -q --percent-limit=1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.000 MB - ]    <======  (here)
      99.58%  perf     perf                  [.] noploop

After:

  $ perf record -o- perf test -w noploop | perf report -i- -q --percent-limit=1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.229 MB - ]
      99.46%  perf     perf                  [.] noploop
---
 tools/perf/builtin-record.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/builtin-record.c +4 -2
index 91e6828c38cc..21ebcb04f1d8 100644
@@ -1773,8 +1773,11 @@ record__finish_output(struct record *rec)
        struct perf_data *data = &rec->data;
        int fd = perf_data__fd(data);
 
-       if (data->is_pipe)
+       if (data->is_pipe) {
+               /* Just to display approx. size */
+               data->file.size = rec->bytes_written;
                return;
+       }
 
        rec->session->header.data_size += rec->bytes_written;
        data->file.size = lseek(perf_data__fd(data), 0, SEEK_CUR);
--

2.43.0.275.g3460e3d667-goog

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Namhyung Kim
Quoted 12 lines · Namhyung Kim

Currently pipe mode doesn't set the file size and it results in a misleading message of 0 data size at the end. Although it might miss some accounting for pipe header or more, just displaying the data size would reduce the possible confusion.

Before:

  $ perf record -o- perf test -w noploop | perf report -i- -q --percent-limit=1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.000 MB - ]    <======  (here)
      99.58%  perf     perf                  [.] noploop
Quoted 7 lines

After:

  $ perf record -o- perf test -w noploop | perf report -i- -q --percent-limit=1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.229 MB - ]
      99.46%  perf     perf                  [.] noploop

Thanks,
Ian

Quoted 24 lines
---
 tools/perf/builtin-record.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/builtin-record.c +4 -2
index 91e6828c38cc..21ebcb04f1d8 100644
@@ -1773,8 +1773,11 @@ record__finish_output(struct record *rec)
        struct perf_data *data = &rec->data;
        int fd = perf_data__fd(data);
 
-       if (data->is_pipe)
+       if (data->is_pipe) {
+               /* Just to display approx. size */
+               data->file.size = rec->bytes_written;
                return;
+       }
 
        rec->session->header.data_size += rec->bytes_written;
        data->file.size = lseek(perf_data__fd(data), 0, SEEK_CUR);
--

2.43.0.275.g3460e3d667-goog

author maintainer Applied
#3 lore raw
In reply to Namhyung Kim
Quoted 5 lines · Namhyung Kim

Currently pipe mode doesn't set the file size and it results in a misleading message of 0 data size at the end. Although it might miss some accounting for pipe header or more, just displaying the data size would reduce the possible confusion.

Quoted 7 lines

Before:

  $ perf record -o- perf test -w noploop | perf report -i- -q --percent-limit=1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.000 MB - ]    <======  (here)
      99.58%  perf     perf                  [.] noploop

[...]

Applied to perf-tools-next, thanks!

Best regards,

Signature · 1 line
Namhyung Kim <[email protected]>