From: Linus Torvalds <torvalds@linux-foundation.org>
To: Christopher Li <sparse@chrisli.org>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH 1/2] Add new streams to a hash-list based on their names
Date: Tue, 19 Apr 2011 15:13:13 -0700 [thread overview]
Message-ID: <BANLkTin4pZPYQh8NBCaW9EjJ89ke_j7Srg@mail.gmail.com> (raw)
In-Reply-To: <BANLkTim28ODvCB541rzmvXVgByF5h-ZAMQ@mail.gmail.com>
On Tue, Apr 19, 2011 at 3:01 PM, Christopher Li <sparse@chrisli.org> wrote:
> On Tue, Apr 19, 2011 at 11:17 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>> + while ((c = *name++) != 0)
>> + hash = (hash + (c << 4) + (c >> 4)) * 11;
>> +
>> + hash *= HASH_PRIME;
>> + hash >>= 32 - HASHED_INPUT_BITS;
>
> Just curious about this hash function, obviously it is not the same as the one
> used for hashing idents. Does it have any history or you just code it up?
It resembles the kernel pathname hash function, but without the fancy
"do it in 64 bits on 64-bit architectures".
And the exact shifting etc at the end is different (the kernel sizes
the hash table based on memory size etc).
But it might be a good idea to share the hash function with the idents
- there is absolutely nothing magical about the hashing I picked. The
kernel path component hash function has been "sufficiently good", but
it's nothing magical or special.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-04-19 22:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-19 18:12 [PATCH 0/2] Fix 'already_tokenized()' performance problem Linus Torvalds
2011-04-19 18:17 ` [PATCH 1/2] Add new streams to a hash-list based on their names Linus Torvalds
2011-04-19 22:01 ` Christopher Li
2011-04-19 22:13 ` Linus Torvalds [this message]
2011-04-19 18:19 ` PATCH 2/2] Teach 'already_tokenized()' to use the stream name hash table Linus Torvalds
2011-04-19 21:52 ` [PATCH 0/2] Fix 'already_tokenized()' performance problem Christopher Li
2011-04-19 22:09 ` Linus Torvalds
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=BANLkTin4pZPYQh8NBCaW9EjJ89ke_j7Srg@mail.gmail.com \
--to=torvalds@linux-foundation.org \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.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 NNTP newsgroup(s).