From: Paul Moore <paul@paul-moore.com>
To: "Christian Göttsche" <cgzones@googlemail.com>, selinux@vger.kernel.org
Cc: Stephen Smalley <stephen.smalley.work@gmail.com>,
Ondrej Mosnacek <omosnace@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] selinux: improve symtab string hashing
Date: Wed, 27 Mar 2024 19:26:23 -0400 [thread overview]
Message-ID: <eef33b146490969c6741cefdf353dcf4@paul-moore.com> (raw)
In-Reply-To: <20240315181414.649045-1-cgzones@googlemail.com>
On Mar 15, 2024 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com> wrote:
>
> The number of buckets is calculated by performing a binary AND against
> the mask of the hash table, which is one less than its size (which is a
> power of two). This leads to all top bits being discarded, requiring
> for short or similar inputs a hash function with a good avalanche
> effect.
>
> Use djb2a:
>
> # current
> common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11
> classes: 134 entries and 100/256 buckets used, longest chain length 5, sum of chain length^2 234
> roles: 15 entries and 6/16 buckets used, longest chain length 5, sum of chain length^2 57
> types: 4448 entries and 3016/8192 buckets used, longest chain length 41, sum of chain length^2 14922
> users: 7 entries and 3/8 buckets used, longest chain length 3, sum of chain length^2 17
> bools: 306 entries and 221/512 buckets used, longest chain length 4, sum of chain length^2 524
> levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1
> categories: 1024 entries and 400/1024 buckets used, longest chain length 4, sum of chain length^2 2740
>
> # patch
> common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11
> classes: 134 entries and 101/256 buckets used, longest chain length 3, sum of chain length^2 210
> roles: 15 entries and 9/16 buckets used, longest chain length 3, sum of chain length^2 31
> types: 4448 entries and 3459/8192 buckets used, longest chain length 5, sum of chain length^2 6778
> users: 7 entries and 5/8 buckets used, longest chain length 3, sum of chain length^2 13
> bools: 306 entries and 236/512 buckets used, longest chain length 5, sum of chain length^2 470
> levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1
> categories: 1024 entries and 518/1024 buckets used, longest chain length 7, sum of chain length^2 2992
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
> v2:
> add licensing note
> ---
> security/selinux/ss/symtab.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
Merged into selinux/dev, thanks.
--
paul-moore.com
prev parent reply other threads:[~2024-03-27 23:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-15 18:14 Christian Göttsche
2024-03-15 18:14 ` [PATCH v2 1/2] selinux: dump statistics for more hash tables Christian Göttsche
2024-03-27 23:26 ` Paul Moore
2024-03-27 23:26 ` Paul Moore [this message]
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=eef33b146490969c6741cefdf353dcf4@paul-moore.com \
--to=paul@paul-moore.com \
--cc=cgzones@googlemail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
/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
all inboxes | Powered by JetHome®