Re: [PATCH v1 0/8] Batched zswap_store() with compression batching

From: Kanchana P. Sridhar

Date: Sun Oct 18 2026 - 21:35:26 EST


On Fri, Oct 16, 2026 at 10:07 PM Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, Oct 16, 2026 at 10:02:13PM -0700, Kanchana P. Sridhar wrote:
> [ .. ]
>
> That isn't quite right though. We need to ensure that it really
> is a singleton before taking the short-cut. So you need at
> least one conditional:
>
> if (likely(req->unit_size == req->slen))
> take short-cut

I added the check for the singleton req [2]. I hope this looks Ok.

With the latest crypto_acomp_compress(), the batch compress latency
improves considerably:

usemem 10 iterations average throughput:

patch 6 (store batching only): 19,119 KB/s
patch 8 (+ compress batching): 24,076 KB/s (+25.93%)

bpftrace measurement of zswap compress latency per-page:

Sequential_zswap_compress nr_samples p25 p50 p75
p95 p99
=================================================================================
zswap_compress_ns_per_page 1,722,489 43,947 57,791 88,489
130,165 323,961

Batched_zswap_compress nr_samples p25 p50 p75
p95 p99
=================================================================================
zswap_compress_ns_per_page 665,267 41,511 54,915 77,707
124,648 213,962
=================================================================================
Latency saving (ns) -2,435 -2,876 -10,782
-5,517 -109,999
=================================================================================

Please let me know if [2] looks good and I can include this in v2, thanks!

[2]:

int crypto_acomp_compress(struct acomp_req *req)
{
struct crypto_acomp *tfm = crypto_acomp_reqtfm(req);

if (unlikely(acomp_req_on_stack(req) && acomp_is_async(tfm)))
return -EAGAIN;

if (likely(req->unit_size && acomp_request_issg(req))) {
if (likely(!crypto_acomp_req_seg(tfm))) {
if (likely(req->unit_size == req->slen)) {
int err = tfm->compress(req);

req->dst->length = unlikely(err) ? err : req->dlen;
return err;
} else {
return acomp_do_req_chain(req, true);
}
}

return tfm->compress(req);
}

if (crypto_acomp_req_virt(tfm) || acomp_request_issg(req))
return tfm->compress(req);

return acomp_do_req_chain(req, true);
}


>
> Cheers,
> --
> Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt