mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Guan-Chun Wu <409411716@gms.tku.edu.tw>
Cc: ebiggers@kernel.org, tytso@mit.edu, jaegeuk@kernel.org,
	xiubli@redhat.com, idryomov@gmail.com, kbusch@kernel.org,
	axboe@kernel.dk, hch@lst.de, sagi@grimberg.me,
	visitorckw@gmail.com, home7438072@gmail.com,
	linux-nvme@lists.infradead.org, linux-fscrypt@vger.kernel.org,
	ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 0/6] lib/base64: add generic encoder/decoder, migrate users
Date: Fri, 31 Oct 2025 21:09:47 -0700	[thread overview]
Message-ID: <20251031210947.1d2b028da88ef526aebd890d@linux-foundation.org> (raw)
In-Reply-To: <20251029101725.541758-1-409411716@gms.tku.edu.tw>

On Wed, 29 Oct 2025 18:17:25 +0800 Guan-Chun Wu <409411716@gms.tku.edu.tw> wrote:

> This series introduces a generic Base64 encoder/decoder to the kernel
> library, eliminating duplicated implementations and delivering significant
> performance improvements.
> 
> The Base64 API has been extended to support multiple variants (Standard,
> URL-safe, and IMAP) as defined in RFC 4648 and RFC 3501. The API now takes
> a variant parameter and an option to control padding. As part of this
> series, users are migrated to the new interface while preserving their
> specific formats: fscrypt now uses BASE64_URLSAFE, Ceph uses BASE64_IMAP,
> and NVMe is updated to BASE64_STD.
> 
> On the encoder side, the implementation processes input in 3-byte blocks,
> mapping 24 bits directly to 4 output symbols. This avoids bit-by-bit
> streaming and reduces loop overhead, achieving about a 2.7x speedup compared
> to previous implementations.
> 
> On the decoder side, replace strchr() lookups with per-variant reverse tables
> and process input in 4-character groups. Each group is mapped to numeric values
> and combined into 3 bytes. Padded and unpadded forms are validated explicitly,
> rejecting invalid '=' usage and enforcing tail rules.

Looks like wonderful work, thanks.  And it's good to gain a selftest
for this code.

> This improves throughput by ~43-52x.

Well that isn't a thing we see every day.

: Decode:
:   64B   ~1530ns  ->  ~80ns    (~19.1x)
:   1KB  ~27726ns  -> ~1239ns   (~22.4x)


: Encode:
:   64B   ~90ns   -> ~32ns   (~2.8x)
:   1KB  ~1332ns  -> ~510ns  (~2.6x)
: 
: Decode:
:   64B  ~1530ns  -> ~35ns   (~43.7x)
:   1KB ~27726ns  -> ~530ns  (~52.3x)


: This change also improves performance: encoding is about 2.7x faster and
: decoding achieves 43-52x speedups compared to the previous implementation.

: This change also improves performance: encoding is about 2.7x faster and
: decoding achieves 43-52x speedups compared to the previous local
: implementation.


Do any of these callers spend a sufficient amount of time in this
encoder/decoder for the above improvements to be observable/useful?


I'll add the series to mm.git's mm-nonmm-unstable branch to give it
linux-next exposure.  I ask the NVMe, ceph and fscrypt teams to check
the code and give it a test in the next few weeks, thanks.  


  parent reply	other threads:[~2025-11-01  4:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29 10:17 Guan-Chun Wu
2025-10-29 10:20 ` [PATCH v4 1/6] lib/base64: Add support for multiple variants Guan-Chun Wu
2025-10-29 10:20 ` [PATCH v4 2/6] lib/base64: Optimize base64_decode() with reverse lookup tables Guan-Chun Wu
2025-10-29 10:21 ` [PATCH v4 3/6] lib/base64: rework encode/decode for speed and stricter validation Guan-Chun Wu
2025-10-29 10:21 ` [PATCH v4 4/6] lib: add KUnit tests for base64 encoding/decoding Guan-Chun Wu
2025-10-29 10:21 ` [PATCH v4 5/6] fscrypt: replace local base64url helpers with lib/base64 Guan-Chun Wu
2025-10-29 10:22 ` [PATCH v4 6/6] ceph: replace local base64 " Guan-Chun Wu
2025-11-01  4:09 ` Andrew Morton [this message]
2025-11-03 10:24   ` [PATCH v4 0/6] lib/base64: add generic encoder/decoder, migrate users Andy Shevchenko
2025-11-03 11:07     ` Kuan-Wei Chiu
2025-11-03 13:22       ` David Laight
2025-11-03 14:41         ` Andy Shevchenko
2025-11-03 18:16           ` Andy Shevchenko
2025-11-03 19:29             ` David Laight
2025-11-03 19:37               ` Andy Shevchenko
2025-11-03 22:32                 ` David Laight
2025-11-04  8:21                   ` Andy Shevchenko
2025-11-04  1:27       ` Andrew Morton
2025-11-04  8:22         ` Andy Shevchenko
2025-11-04  9:03       ` David Laight
2025-11-04  9:48         ` Andy Shevchenko
2025-11-05  9:48           ` David Laight
2025-11-05 14:13             ` Andy Shevchenko
2025-11-05 14:38               ` David Laight
2025-11-09 12:36                 ` Guan-Chun Wu

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=20251031210947.1d2b028da88ef526aebd890d@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=409411716@gms.tku.edu.tw \
    --cc=axboe@kernel.dk \
    --cc=ceph-devel@vger.kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=hch@lst.de \
    --cc=home7438072@gmail.com \
    --cc=idryomov@gmail.com \
    --cc=jaegeuk@kernel.org \
    --cc=kbusch@kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=tytso@mit.edu \
    --cc=visitorckw@gmail.com \
    --cc=xiubli@redhat.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

Powered by JetHome