public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: valerij zaporogeci <vlrzprgts@gmail.com>
To: edk2-devel <edk2-devel@lists.01.org>
Subject: Re: Crc32
Date: Fri, 2 Sep 2016 01:36:55 +0300	[thread overview]
Message-ID: <CANPuzFxRQ5NouHotsDRUzA7PLQGMNGViAO5Q576JynCtcC509g@mail.gmail.com> (raw)
In-Reply-To: <CANPuzFxGeZ_g2Zg7u-E1BgbCVJhqjL=TF0_yL8JCMUUj0pWmeQ@mail.gmail.com>

Please read this, don't discard hastily, it might be intesting for the project.
I have a suggestion about the implementation of Crc32 found in this place:
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/RuntimeDxe/Crc32.c

Figuring out why proper mathematical crc calculation differs from
results returned by this function, I found it's because the function
reverts bits in bytes. It's all clear, this is a need rooting from
some hardware protocol requirements and specifics (ethernet?), where
it was needed and here it is repeated as it became a de facto
standard.
But looking at the implementation, I found that it is possible to get
THE SAME results with much less processing. Namely, instead of
reverting every byte in the sequnece (moreover, please note, that the
implementation in fact casts every byte to UINT32 and only then
reverts it - yet 4 times more of a wasting job), so, instead of
reverting every byte of the entire message (which might be of any
size), we might statically revert bits ONLY in the Polynomial
representation itself. And that's all! It's absolutely identical
mathematically. It returns identical results on every input. But it is
a significant performance improvement. The interface and semantics
would not change, they remain the same for any caller. Internal
ReverseBits() function is not needed any more and doesn't get called
anywhere. The implementation remains the same table driven, but the
table initializes now MUCH more faster (without reverting).
If you have interest in this suggestion, I have prepared (and tested)
the changed file in question, and might send it if there would be
interest.
Thank you.
PS. It is NOT changing a polynomial. It's improvement of the internal
implementation which takes into account (strange) treatment of bit
ordering of this particular case.


      reply	other threads:[~2016-09-01 22:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30  0:54 Crc32 valerij zaporogeci
2016-08-30 11:08 ` Crc32 Michael Zimmermann
2016-08-30 13:32   ` Crc32 valerij zaporogeci
2016-08-30 14:09     ` Crc32 Andrew Fish
2016-08-30 15:17       ` Crc32 valerij zaporogeci
2016-08-30 16:15         ` Crc32 Andrew Fish
2016-08-31  1:11           ` Crc32 valerij zaporogeci
2016-08-31  3:54             ` Crc32 Michael Zimmermann
2016-08-31 14:31               ` Crc32 valerij zaporogeci
2016-08-31 23:27                 ` Crc32 valerij zaporogeci
2016-09-01 22:36                   ` valerij zaporogeci [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-list 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=CANPuzFxRQ5NouHotsDRUzA7PLQGMNGViAO5Q576JynCtcC509g@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /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