[PR #1081] [MERGED] inflate: expand repeated matches in blocks and batch Adler reductions #1115

Closed
opened 2026-11-26 20:20:08 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1081
Author: @Kadamitas
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @QemmHD

Base: main ← Head: perf/inflate-output


📝 Commits (1)

  • f7d1862 inflate: expand repeated matches in blocks and batch Adler reductions

📊 Changes

2 files changed (+41 additions, -5 deletions)

View changed files

📝 runtime/src/shader_library.h (+25 -5)
📝 runtime/test/shader_library_test.cpp (+16 -0)

📄 Description

Claimed in the coordination issue as: RT-INFLATE-MATCH-COPY.

Depends on: none

What and why

Shader loading and DirectStorage use the same CPU inflater. This change grows the output buffer once for each length/distance match. A one-byte pattern uses a fill. Longer patterns start with the available prefix and copy completed, non-overlapping spans until the match is complete. Adler-32 reduces its two accumulators every 5,552 bytes, the maximum safe interval for 32-bit sums.

Tested

The Windows x64 MSVC shader-library suite passed, including a new case that expands overlapping one- and three-byte patterns across multiple checksum boundaries.

An independent CPU benchmark compared the parent and proposed code on 114 synthetic stored, fixed and dynamic streams. Both produced the expected decoded bytes and the same digest across 2,136 checks covering success, partial output and errors. Each batch expanded 4,493,676 bytes. In two runs per version the median fell from 12.580–12.596 ms to 3.068–3.076 ms, about 4.1× faster for this CPU workload.

The semantic suite ran 6,165 tests across 470 files. Two files failed because the SPIR-V assembler and validator were missing from the test environment. On the rebased branch, rerunning those files with both tools on PATH passed all 12 tests in test_sopc_validation and all 7 in test_unary_f16_validation.

GPUs tested: n/a (CPU-only change)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • Only source and synthetic fixtures included.
  • No shader translator rule changed.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1081 **Author:** [@Kadamitas](https://github.com/Kadamitas) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `perf/inflate-output` --- ### 📝 Commits (1) - [`f7d1862`](https://github.com/ubiquitarianism/leonida/commit/f7d18627bd1c74de0018cc13ba771cdde7042ef4) inflate: expand repeated matches in blocks and batch Adler reductions ### 📊 Changes **2 files changed** (+41 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/shader_library.h` (+25 -5) 📝 `runtime/test/shader_library_test.cpp` (+16 -0) </details> ### 📄 Description Claimed in the coordination issue as: [RT-INFLATE-MATCH-COPY](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7138821737). Depends on: none ### What and why Shader loading and DirectStorage use the same CPU inflater. This change grows the output buffer once for each length/distance match. A one-byte pattern uses a fill. Longer patterns start with the available prefix and copy completed, non-overlapping spans until the match is complete. Adler-32 reduces its two accumulators every 5,552 bytes, the maximum safe interval for 32-bit sums. ### Tested The Windows x64 MSVC shader-library suite passed, including a new case that expands overlapping one- and three-byte patterns across multiple checksum boundaries. An independent CPU benchmark compared the parent and proposed code on 114 synthetic stored, fixed and dynamic streams. Both produced the expected decoded bytes and the same digest across 2,136 checks covering success, partial output and errors. Each batch expanded 4,493,676 bytes. In two runs per version the median fell from 12.580–12.596 ms to 3.068–3.076 ms, about 4.1× faster for this CPU workload. The semantic suite ran 6,165 tests across 470 files. Two files failed because the SPIR-V assembler and validator were missing from the test environment. On the rebased branch, rerunning those files with both tools on `PATH` passed all 12 tests in `test_sopc_validation` and all 7 in `test_unary_f16_validation`. GPUs tested: n/a (CPU-only change) AI-assisted: yes ### Checklist - [x] Based on current main and merges cleanly. - [x] One topic. - [x] Only source and synthetic fixtures included. - [x] No shader translator rule changed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:20:08 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1115
No description provided.