public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vittorio.romeo at outlook dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/104719] Use of `std::move` in libstdc++ leads to worsened debug performance
Date: Tue, 01 Mar 2022 02:23:06 +0000	[thread overview]
Message-ID: <bug-104719-4-wRs6ks7dKm@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104719-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104719

--- Comment #9 from Vittorio Romeo <vittorio.romeo at outlook dot com> ---
I have done some benchmarking for three use cases, both with `-O0` and `-Og`,
hacking my `libstdc++` headers to add `[[gnu::always_inline]]` where deemed
appropriate. 

---

The use cases were:

1. `operator[]` benchmark -- `vector_squareop` and `carray_squareop` as seen
above

2. Iterator benchmark -- `vector_iter` and `carray_iter` as seen above

3. Algorithm benchmark -- `std::accumulate` versus a raw `for` loop

---

All the benchmark results, benchmarking rig specs, and used code available
here:
https://gist.github.com/vittorioromeo/efa005d44ccd4ec7279181768a0c1f0b

---

In short, these are the results:

- For all benchmarks, when using `-O0` without any modification to `libstdc++`,
the overhead of the Standard Library can be huge (+25-400%).

- For all benchmarks, when using `-Og` without any modification to `libstdc++`,
the overhead of the Standard Library is small (+5-15%).

- For the `operator[]` benchmark, when using `-O0` after applying
`[[gnu::always_inline]]` to all the functions touched by the benchmark, we
reduce the overhead from 25% to around 10%.

- For the `operator[]` benchmark, when using `-Og` after applying
`[[gnu::always_inline]]` to all the functions touched by the benchmark, we
reduce the overhead from 34% to around 11%. 

- For the iterator benchmark, when using `-O0` after applying
`[[gnu::always_inline]]` to all the functions touched by the benchmark, we
reduce the overhead from 302% to around 186%. 

- For the iterator benchmark, when using `-Og` after applying
`[[gnu::always_inline]]` to all the functions touched by the benchmark, we
reduce the overhead from 11% to around 8%. 

- For the algorithm benchmark, when using `-O0` after applying
`[[gnu::always_inline]]` to all the functions touched by the benchmark, we
reduce the overhead from 304% to around 47%.

- For the algorithm benchmark, when using `-Og`, independently of whether we
modify `libstdc++` or not, the overhead is around 36%.

  parent reply	other threads:[~2022-03-01  2:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28 16:20 [Bug libstdc++/104719] New: " vittorio.romeo at outlook dot com
2022-02-28 16:46 ` [Bug libstdc++/104719] " redi at gcc dot gnu.org
2022-02-28 16:50 ` redi at gcc dot gnu.org
2022-02-28 16:56 ` egallager at gcc dot gnu.org
2022-02-28 17:00 ` vittorio.romeo at outlook dot com
2022-02-28 17:16 ` redi at gcc dot gnu.org
2022-02-28 17:20 ` vittorio.romeo at outlook dot com
2022-02-28 17:24 ` redi at gcc dot gnu.org
2022-02-28 17:37 ` redi at gcc dot gnu.org
2022-03-01  2:23 ` vittorio.romeo at outlook dot com [this message]
2022-03-01 20:12 ` redi at gcc dot gnu.org
2022-03-01 20:14 ` redi at gcc dot gnu.org
2022-03-10 23:04 ` jason at gcc dot gnu.org
2022-03-26 23:37 ` jason at gcc dot gnu.org
2022-03-27  7:35 ` redi at gcc dot gnu.org
2022-05-04 15:34 ` cvs-commit at gcc dot gnu.org
2022-05-04 15:34 ` cvs-commit at gcc dot gnu.org
2022-05-04 15:49 ` unlvsur at live dot com
2022-05-04 15:55 ` redi at gcc dot gnu.org

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=bug-104719-4-wRs6ks7dKm@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).