From: Michael Matz <matz@suse.de>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: New power of 2 hash policy
Date: Fri, 11 Sep 2015 13:18:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.20.1509111508520.30229@wotan.suse.de> (raw)
In-Reply-To: <55F1E20E.7080305@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]
Hi,
On Thu, 10 Sep 2015, François Dumont wrote:
> Here is a patch to offer an alternative hash policy. This one is
> using power of 2 number of buckets allowing a faster modulo operation.
> This is obvious when running the performance test that I have adapted to
> use this alternative policy. Something between current implementation
> and the tr1 one, the old std one.
>
> Of course with this hash policy the lower bits of the hash code are
> more important. For pointers it would require to change the std::hash
> implementation to remove the lower 0 bits like in the patch I proposed
> some weeks ago.
>
> What do you think ?
No comment on if it should be included (except that it seems useful to
me), but one observation of the patch:
> + 1ul << 31,
> +#if __SIZEOF_LONG__ != 8
> + 1ul << 32
> +#else
This is wrong, 1ul<<32 is zero on a 32bit machine, and is also the 33rd
entry in that table, when you want only 32. Like you also (correctly)
stop with 1ul<<63 for a 64bit machine.
Ciao,
Michael.
next prev parent reply other threads:[~2015-09-11 13:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-10 20:11 François Dumont
2015-09-11 13:18 ` Michael Matz [this message]
2015-09-11 13:19 ` Jonathan Wakely
2015-09-11 13:28 ` Jonathan Wakely
2015-09-13 20:28 ` François Dumont
2015-09-24 20:58 ` François Dumont
2015-09-25 13:58 ` Jonathan Wakely
2015-09-28 19:39 ` François Dumont
2015-10-19 20:23 ` François Dumont
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=alpine.LSU.2.20.1509111508520.30229@wotan.suse.de \
--to=matz@suse.de \
--cc=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@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).