linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Budankov <alexey.budankov@linux.intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Andi Kleen <ak@linux.intel.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH v9 09/12] perf record: implement -z,--compression_level[=<n>] option
Date: Sat, 16 Mar 2019 17:16:26 +0300	[thread overview]
Message-ID: <c24bb3c8-2569-ab34-ac4c-9745ae1ba4ac@linux.intel.com> (raw)
In-Reply-To: <c1423198-e474-1739-e800-4615cce501ce@linux.intel.com>


Implemented -z,--compression_level[=<n>] option that enables compression
of mmaped kernel data buffers content in runtime during perf record
mode collection. Default option value is 1 (fastest compression).

Compression overhead has been measured for serial and AIO streaming
when profiling matrix multiplication workload:

    -------------------------------------------------------------
    | SERIAL			  | AIO-1                       |
----------------------------------------------------------------|
|-z | OVH(x) | ratio(x) size(MiB) | OVH(x) | ratio(x) size(MiB) |
|---------------------------------------------------------------|
| 0 | 1,00   | 1,000    179,424   | 1,00   | 1,000    187,527   |
| 1 | 1,04   | 8,427    181,148   | 1,01   | 8,474    188,562   |
| 2 | 1,07   | 8,055    186,953   | 1,03   | 7,912    191,773   |
| 3 | 1,04   | 8,283    181,908   | 1,03   | 8,220    191,078   |
| 5 | 1,09   | 8,101    187,705   | 1,05   | 7,780    190,065   |
| 8 | 1,05   | 9,217    179,191   | 1,12   | 6,111    193,024   |
-----------------------------------------------------------------

OVH = (Execution time with -z N) / (Execution time with -z 0)

ratio - compression ratio
size  - number of bytes that was compressed

	size ~= trace size x ratio

Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
---
 tools/perf/Documentation/perf-record.txt |  5 +++++
 tools/perf/builtin-record.c              | 25 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 18fceb49434e..0567bacc2ae6 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -471,6 +471,11 @@ Also at some cases executing less trace write syscalls with bigger data size can
 shorter than executing more trace write syscalls with smaller data size thus lowering
 runtime profiling overhead.
 
+-z::
+--compression-level[=n]::
+Produce compressed trace using specified level n (default: 1 - fastest compression,
+22 - smallest trace)
+
 --all-kernel::
 Configure all used events to run in kernel space.
 
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 2e083891affa..7258f2964a3b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -440,6 +440,26 @@ static int record__mmap_flush_parse(const struct option *opt,
 	return 0;
 }
 
+#ifdef HAVE_ZSTD_SUPPORT
+static unsigned int comp_level_default = 1;
+static int record__parse_comp_level(const struct option *opt,
+				    const char *str,
+				    int unset)
+{
+	struct record_opts *opts = (struct record_opts *)opt->value;
+
+	if (unset) {
+		opts->comp_level = 0;
+	} else {
+		if (str)
+			opts->comp_level = strtol(str, NULL, 0);
+		if (!opts->comp_level)
+			opts->comp_level = comp_level_default;
+	}
+
+	return 0;
+}
+#endif
 static unsigned int comp_level_max = 22;
 
 static int record__comp_enabled(struct record *rec)
@@ -2169,6 +2189,11 @@ static struct option __record_options[] = {
 	OPT_CALLBACK(0, "affinity", &record.opts, "node|cpu",
 		     "Set affinity mask of trace reading thread to NUMA node cpu mask or cpu of processed mmap buffer",
 		     record__parse_affinity),
+#ifdef HAVE_ZSTD_SUPPORT
+	OPT_CALLBACK_OPTARG('z', "compression-level", &record.opts, &comp_level_default,
+		     "n", "Produce compressed trace using specified level (default: 1 - fastest compression, 22 - smallest trace)",
+		     record__parse_comp_level),
+#endif
 	OPT_END()
 };
 
-- 
2.20.1


  parent reply	other threads:[~2019-03-16 14:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-16  8:58 [PATCH v9 00/12] perf: enable compression of record mode trace to save storage space Alexey Budankov
2019-03-16 14:09 ` [PATCH v9 01/12] feature: implement libzstd check, LIBZSTD_DIR and NO_LIBZSTD defines Alexey Budankov
2019-03-16 14:10 ` [PATCH v9 02/12] perf record: implement --mmap-flush=<number> option Alexey Budankov
2019-03-16 14:11 ` [PATCH v9 03/12] perf session: define bytes_transferred and bytes_compressed metrics Alexey Budankov
2019-03-16 14:12 ` [PATCH v9 04/12] perf record: implement COMPRESSED event record and its attributes Alexey Budankov
2019-03-16 14:13 ` [PATCH v9 05/12] perf mmap: implement dedicated memory buffer for data compression Alexey Budankov
2019-03-16 14:13 ` [PATCH v9 06/12] perf util: introduce Zstd streaming based compression API Alexey Budankov
2019-03-16 14:14 ` [PATCH v9 07/12] perf record: implement compression for serial trace streaming Alexey Budankov
2019-03-16 14:15 ` [PATCH v9 08/12] perf record: implement compression for AIO " Alexey Budankov
2019-03-16 14:16 ` Alexey Budankov [this message]
2019-03-16 14:17 ` [PATCH v9 10/12] perf report: implement record trace decompression Alexey Budankov
2019-03-18 11:46   ` Jiri Olsa
2019-03-18 12:06     ` Alexey Budankov
2019-03-16 14:17 ` [PATCH v9 11/12] perf inject: enable COMPRESSED records decompression Alexey Budankov
2019-03-16 14:18 ` [PATCH v9 12/12] perf tests: implement Zstd comp/decomp integration test Alexey Budankov
2019-03-18 11:46   ` Jiri Olsa
2019-03-18 12:07     ` Alexey Budankov
2019-03-18 11:46 ` [PATCH v9 00/12] perf: enable compression of record mode trace to save storage space Jiri Olsa
2019-03-18 17:57   ` Alexey Budankov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c24bb3c8-2569-ab34-ac4c-9745ae1ba4ac@linux.intel.com \
    --to=alexey.budankov@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).