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] New: Use of `std::move` in libstdc++ leads to worsened debug performance Date: Mon, 28 Feb 2022 16:20:58 +0000 [thread overview] Message-ID: <bug-104719-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104719 Bug ID: 104719 Summary: Use of `std::move` in libstdc++ leads to worsened debug performance Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: vittorio.romeo at outlook dot com Target Milestone: --- `std::accumulate` is defined as follows in `libstdc++`: ``` template<typename _InputIterator, typename _Tp> _GLIBCXX20_CONSTEXPR inline _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) { // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_requires_valid_range(__first, __last); for (; __first != __last; ++__first) __init = _GLIBCXX_MOVE_IF_20(__init) + *__first; return __init; } ``` Where `_GLIBCXX_MOVE_IF_20` is: ``` #if __cplusplus > 201703L // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 2055. std::move in std::accumulate and other algorithms # define _GLIBCXX_MOVE_IF_20(_E) std::move(_E) #else # define _GLIBCXX_MOVE_IF_20(_E) _E #endif ``` When compiling a program using `std::accumulate` in debug mode, under `-Og`, there is a noticeable performance impact due to the presence of `std::move`. - With `std::move`: https://quick-bench.com/q/h_M_AUs3pgBE3bYr82rsA1_VtjU - Without `std::move`: https://quick-bench.com/q/ysis2b1CgIZkRsO2cqfjZm9Jkio This performance degradation is one example of why many people (especially in the gamedev community) are not adopting standard library algorithms and modern C++ more widely. Would it be possible to replace `std::move` calls internal to `libstdc++` with a cast, or some sort of compiler intrinsic? Or maybe mark `std::move` as "always inline" even without optimizations enabled? Related issue for libc++: https://github.com/llvm/llvm-project/issues/53689
next reply other threads:[~2022-02-28 16:20 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-28 16:20 vittorio.romeo at outlook dot com [this message] 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 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@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: linkBe 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).