public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dprokoptsev at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/103755] {has,use}_facet() and iostream constructor performance
Date: Sun, 19 Dec 2021 03:44:50 +0000	[thread overview]
Message-ID: <bug-103755-4-AJgWbnVKMO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103755-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Dmitry Prokoptsev <dprokoptsev at gmail dot com> ---
That would also work, I suppose (it even outperforms my original approach by a
tiny bit -- 33 ns for v2 vs 36 for my original implementation).

There are a few build errors in the alternative implementations, however:
is_convertible<locale::facet*, _Facet*>::value is false, as it tries to
downcast the facet -- did you mean is_base_of<>, which would also better align
with the static assert message?

Also, despite the always_inline attribute of __try_use_facet, my attempts to
build the library with -O0 -ggdb and link my benchmark yielded a bunch of
errors like 

    ld:
/home/av/prgs/gcc/debug/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so:
undefined reference to `std::num_get<char, std::istreambuf_iterator<char,
std::char_traits<char> > > const* std::__try_use_facet<std::num_get<char,
std::istreambuf_iterator<char, std::char_traits<char> > > >(std::locale
const&)'

Suggest explicitly instantiating __try_use_facet where has_facet() and
use_facet() is instantiated.

See attached fix for build problems I discovered.

  parent reply	other threads:[~2021-12-19  3:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17  3:49 [Bug libstdc++/103755] New: " dprokoptsev at gmail dot com
2021-12-17 10:31 ` [Bug libstdc++/103755] " redi at gcc dot gnu.org
2021-12-17 17:22 ` redi at gcc dot gnu.org
2021-12-17 17:52 ` redi at gcc dot gnu.org
2021-12-17 21:05 ` redi at gcc dot gnu.org
2021-12-19  3:41 ` dprokoptsev at gmail dot com
2021-12-19  3:44 ` dprokoptsev at gmail dot com [this message]
2021-12-19 13:04 ` redi at gcc dot gnu.org
2022-02-03 17:06 ` redi at gcc dot gnu.org
2022-09-23 12:57 ` redi at gcc dot gnu.org
2022-11-11  5:29 ` cvs-commit at gcc dot gnu.org
2022-11-11 13:27 ` redi at gcc dot gnu.org
2022-11-11 21:54 ` seurer at gcc dot gnu.org
2022-11-11 21:55 ` redi at gcc dot gnu.org
2022-11-11 22:39 ` redi at gcc dot gnu.org
2022-11-12  1:30 ` cvs-commit at gcc dot gnu.org
2022-11-12  2:00 ` redi at gcc dot gnu.org
2023-01-06 12:12 ` redi at gcc dot gnu.org
2023-01-11 14:07 ` redi at gcc dot gnu.org
2023-04-21 15:01 ` cvs-commit at gcc dot gnu.org
2023-04-21 15:06 ` 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-103755-4-AJgWbnVKMO@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).