All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Tatashin <pasha.tatashin@oracle.com>
To: Timofey Titovets <nefelim4ag@gmail.com>
Cc: linux-mm@kvack.org, Sioh Lee <solee@os.korea.ac.kr>,
	Andrea Arcangeli <aarcange@redhat.com>,
	kvm@vger.kernel.org
Subject: Re: [PATCH V6 2/2 RESEND] ksm: replace jhash2 with faster hash
Date: Thu, 24 May 2018 21:16:57 -0400	[thread overview]
Message-ID: <20180525011657.4qxrosmm3xjzo24w@xakep.localdomain> (raw)
In-Reply-To: <CAGqmi76-qK9q_OTvyqpb-9k_m0CLMt3o860uaN5LL8nBkf5RTg@mail.gmail.com>

Hi Timofey,

> > Do you have performance numbers of crc32c without acceleration?
> Yes, https://lkml.org/lkml/2017/12/30/222
> 
> The experimental results (the experimental value is the average of the
> measured values)
> crc32c_intel: 1084.10ns
> crc32c (no hardware acceleration): 7012.51ns
> xxhash32: 2227.75ns
> xxhash64: 1413.16ns
> jhash2: 5128.30ns

Excellent, thank you for this data.

> > I understand that losing half of the hash result might be acceptable in
> > this case, but I am not really sure how XOirng one more time can possibly
> > make hash function worse, could you please elaborate?
> 
> IIRC, because of xor are symmetric
> i.e. shift:
> 0b01011010 >> 4 = 0b0101
> and xor:
> 0b0101 ^ 0b1010 = 0b1111
> Xor will decrease randomness/entropy and will lead to hash collisions.

Makes perfect sense. Yes, XORing two random numbers reduces entropy.

> That possible to move decision from lazy load, to ksm_thread,
> that will allow us to start bench and not slowdown boot.
> 
> But for that to works, ksm must start later, after init of crypto.

After studying this dependency some more I agree, it is OK to choose hash
function where it is, but I still disagree that we must measure the
performance at runtime.

> crc32c with no hw, are slower in compare to jhash2 on x86, so i think on
> other arches result will be same.

Agreed.

Below, is your patch updated with my suggested changes.

1. Removes dependency on crc32c, use it only when it is available.
2. Do not spend time measuring the performance, choose only if there is HW
optimized implementation of crc32c is available.
3. Replace the logic with static branches.
4. Fix a couple minor bugs: 
   fastest_hash_setup() and crc32c_available() were marked as __init
   functions. Thus could be unmapped by the time they are run for the
   first time. I think section mismatch would catch those
   Removed dead code:  "desc.flags = 0", and also replaced desc with sash.
   Removed unnecessary local global "static struct shash_desc desc" this
   removes it from data page.
   Fixed few spelling errors, and other minor changes to pass
   ./scripts/checkpatch.pl

The patch is untested, but should work. Please let me know if you agree
with the changes. If so, you can test and resubmit the series.

Thank you,
Pavel

Patch:
==========================================================================

  reply	other threads:[~2018-05-25  1:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-18 19:32 [PATCH V6 0/2 RESEND] KSM replace hash algo with faster hash Timofey Titovets
2018-04-18 19:32 ` [PATCH V6 1/2 RESEND] xxHash: create arch dependent 32/64-bit xxhash() Timofey Titovets
2018-04-18 19:32 ` [PATCH V6 2/2 RESEND] ksm: replace jhash2 with faster hash Timofey Titovets
2018-05-08 15:26   ` Claudio Imbrenda
2018-05-11 23:06     ` Timofey Titovets
2018-05-14 10:17       ` Claudio Imbrenda
2018-05-16 10:26         ` Timofey Titovets
2018-05-22 20:22   ` Pavel Tatashin
2018-05-23 13:45     ` Timofey Titovets
2018-05-23 14:24       ` Pavel Tatashin
2018-05-24  8:01         ` Timofey Titovets
2018-05-25  1:16           ` Pavel Tatashin [this message]
2018-05-26 20:25             ` [PATCH] " kbuild test robot
2018-05-26 21:06             ` kbuild test robot
2018-05-27 13:03           ` [PATCH V6 2/2 RESEND] " Mike Rapoport
2018-05-29 14:45             ` Pavel Tatashin
2018-06-07  8:58               ` Timofey Titovets
2018-06-07 11:52                 ` Mike Rapoport
2018-06-08  1:29                   ` Pavel Tatashin
2018-06-10  5:38                     ` Mike Rapoport
2018-06-22 18:48                       ` Pavel Tatashin
2018-06-25  8:48                     ` Mike Rapoport
2018-09-13 10:35                       ` Timofey Titovets
2018-09-13 18:01                         ` Mike Rapoport
2018-09-13 18:10                           ` Pasha Tatashin
  -- strict thread matches above, loose matches on Subject: below --
2018-02-07 10:22 [PATCH V6 0/2 RESEND] KSM replace hash algo " Timofey Titovets
2018-02-07 10:22 ` [PATCH V6 2/2 RESEND] ksm: replace jhash2 " Timofey Titovets
2018-02-07 10:22   ` Timofey Titovets

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=20180525011657.4qxrosmm3xjzo24w@xakep.localdomain \
    --to=pasha.tatashin@oracle.com \
    --cc=aarcange@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nefelim4ag@gmail.com \
    --cc=solee@os.korea.ac.kr \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.