All of lore.kernel.org
 help / color / mirror / Atom feed
From: "massimo toscanelli" <massimo.toscanelli@leica-geosystems.com>
To: "openembedded-devel@lists.openembedded.org"
	<openembedded-devel@lists.openembedded.org>
Cc: Khem Raj <raj.khem@gmail.com>
Subject: Re: [meta-oe,dunfell][PATCH] sysbench: fix memory test
Date: Fri, 23 Jul 2021 08:26:54 +0000	[thread overview]
Message-ID: <AM6PR06MB5158DD115D8B575AD6260C34A0E59@AM6PR06MB5158.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <20210714162656.20938-1-massimo.toscanelli@leica-geosystems.com>

Hello,

any update?

-----Original Message-----
From: massimo toscanelli <massimo.toscanelli@leica-geosystems.com> 
Sent: 14 July 2021 18:27
To: openembedded-devel@lists.openembedded.org
Cc: TOSCANELLI Massimo <massimo.toscanelli@leica-geosystems.com>; Khem Raj <raj.khem@gmail.com>
Subject: [meta-oe,dunfell][PATCH] sysbench: fix memory test

In sysbench version 0.4, the tmp variable used by the memory test to execute requests is optimized by the compiler. Caching mechanism reduces the direct accesses to the memory increasing the transfer speed. This leads to false timing estimations that considerably affect read and also random write operations.

In sysbench version 1, this issue is fixed adding the volatile modifier to the tmp variable. This prevents compiler optimizations forcing a direct access to the memory.

The final result is a realistic transfer speed measurement.

Signed-off-by: massimo toscanelli <massimo.toscanelli@leica-geosystems.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>

(cherry picked from commit 59cce5ad1603c2975684ae15b639e0e3cd688c40)
Signed-off-by: massimo toscanelli <massimo.toscanelli@leica-geosystems.com>
---
 ...modifier-to-tmp-variable-in-memory-t.patch | 40 +++++++++++++++++++
 .../sysbench/sysbench_0.4.12.bb               |  4 +-
 2 files changed, 43 insertions(+), 1 deletion(-)  create mode 100644 meta-oe/recipes-benchmark/sysbench/sysbench/0001-Adding-volatile-modifier-to-tmp-variable-in-memory-t.patch

diff --git a/meta-oe/recipes-benchmark/sysbench/sysbench/0001-Adding-volatile-modifier-to-tmp-variable-in-memory-t.patch b/meta-oe/recipes-benchmark/sysbench/sysbench/0001-Adding-volatile-modifier-to-tmp-variable-in-memory-t.patch
new file mode 100644
index 000000000..d628e81b5
--- /dev/null
+++ b/meta-oe/recipes-benchmark/sysbench/sysbench/0001-Adding-volatile-m
+++ odifier-to-tmp-variable-in-memory-t.patch
@@ -0,0 +1,40 @@
+From c1ebf893e32a0a77e820484d48a903523fef7c1b Mon Sep 17 00:00:00 2001
+From: Vasily Tarasov <tarasov@vasily.name>
+Date: Fri, 10 Jun 2016 14:33:48 -0400
+Subject: [PATCH] Adding volatile modifier to tmp variable in memory 
+test
+
+Issue explanation:
+
+./sysbench/sysbench --test=memory --num-threads=16 \
+		    --memory-block-size=268435456 \
+		    --memory-total-size=137438953472 \
+		    --memory-oper=read \
+		    --memory-access-mode=seq \
+		    --memory-scope=local run
+
+Without this commit the time to run the above command is 0.0004 seconds.
+With this commit the time is greater than 3 seconds.  Essentially, 
+without the volatile modifier, the compiler optimizes read access so 
+that no real access happens.
+
+Upstream-Status: Backport [part of v1.0.0 
+https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithu
+b.com%2Fakopytov%2Fsysbench%2Fcommit%2F8753cb93be4c0b81a20b704ced91e7a4
+22da52b1&amp;data=04%7C01%7C%7C313329a480e84fd7b72c08d946e43eb0%7C1b16a
+b3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C637618768380002742%7CUnknown%7CTW
+FpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6M
+n0%3D%7C1000&amp;sdata=%2FIgZtBTkbsCsRueM5s0oa%2BpTob7X%2FShLXlm9gtGTj%
+2BM%3D&amp;reserved=0]
+
+(cherry picked from commit 8753cb93be4c0b81a20b704ced91e7a422da52b1)
+Signed-off-by: massimo toscanelli 
+<massimo.toscanelli@leica-geosystems.com>
+---
+ sysbench/tests/memory/sb_memory.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/sysbench/tests/memory/sb_memory.c 
+b/sysbench/tests/memory/sb_memory.c
+index 2e8998f..7d22bb9 100644
+--- a/sysbench/tests/memory/sb_memory.c
++++ b/sysbench/tests/memory/sb_memory.c
+@@ -244,7 +244,7 @@ sb_request_t memory_get_request(int tid)  int 
+memory_execute_request(sb_request_t *sb_req, int thread_id)  {
+   sb_mem_request_t    *mem_req = &sb_req->u.mem_request;
+-  int                 tmp = 0;
++  volatile int        tmp = 0;
+   int                 idx; 
+   int                 *buf, *end;
+   log_msg_t           msg;
diff --git a/meta-oe/recipes-benchmark/sysbench/sysbench_0.4.12.bb b/meta-oe/recipes-benchmark/sysbench/sysbench_0.4.12.bb
index 708c71f4f..d1725dddd 100644
--- a/meta-oe/recipes-benchmark/sysbench/sysbench_0.4.12.bb
+++ b/meta-oe/recipes-benchmark/sysbench/sysbench_0.4.12.bb
@@ -8,7 +8,9 @@ inherit autotools
 
 # The project has moved from Sourceforge to Launchpad, to Github. Use the source tarball from  # Launchpad until the next release is available from Github.
-SRC_URI = "https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flaunchpad.net%2Fubuntu%2F%2Barchive%2Fprimary%2F%2Bfiles%2F%24&amp;data=04%7C01%7C%7C313329a480e84fd7b72c08d946e43eb0%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C637618768380002742%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=C2opVas%2BXGw7WRR1b5VrKye%2FO5UNvAJj4hmgqGXZWvU%3D&amp;reserved=0{BPN}_${PV}.orig.tar.gz"
+SRC_URI = "https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flaunchpad.net%2Fubuntu%2F%2Barchive%2Fprimary%2F%2Bfiles%2F%24&amp;data=04%7C01%7C%7C313329a480e84fd7b72c08d946e43eb0%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C637618768380002742%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=C2opVas%2BXGw7WRR1b5VrKye%2FO5UNvAJj4hmgqGXZWvU%3D&amp;reserved=0{BPN}_${PV}.orig.tar.gz \
+           file://0001-Adding-volatile-modifier-to-tmp-variable-in-memory-t.patch \
+           "
 
 SRC_URI[md5sum] = "3a6d54fdd3fe002328e4458206392b9d"
 SRC_URI[sha256sum] = "83fa7464193e012c91254e595a89894d8e35b4a38324b52a5974777e3823ea9e"
--
2.17.1


      reply	other threads:[~2021-07-23  8:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14 16:26 [meta-oe,dunfell][PATCH] sysbench: fix memory test massimo toscanelli
2021-07-23  8:26 ` massimo toscanelli [this message]

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=AM6PR06MB5158DD115D8B575AD6260C34A0E59@AM6PR06MB5158.eurprd06.prod.outlook.com \
    --to=massimo.toscanelli@leica-geosystems.com \
    --cc=openembedded-devel@lists.openembedded.org \
    --cc=raj.khem@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.