TZIPER180: Building a Hybrid CPU-GPU Compression Engine — TPECKA180 (ТРЕСКА180)

File compression is an interesting engineering problem because performance is not determined by a single component.

A powerful processor does not automatically guarantee fast compression. A powerful graphics card does not automatically make every compression algorithm faster. Even a well-optimized codec can perform poorly if the storage system becomes the bottleneck.

While developing my experimental file archiver, TZIPER180, I started exploring a question:

What if an archiver could intelligently distribute compression workloads between the CPU and GPU instead of relying primarily on one computational device?

This is one of the main directions I am currently exploring in version 0.4.8.

The objective is not simply to add GPU acceleration as a feature. I want to investigate whether a genuinely hybrid compression architecture can improve overall performance without sacrificing compression efficiency or data integrity.

The limitations of the previous architecture

Before starting development of version 0.4.8, I reviewed the actual capabilities of version 0.4.7.

The existing implementation included:

  • Zstandard.
  • LZ4.
  • LZMA2.
  • GPU-accelerated run-length encoding.
  • Adaptive codec selection modes.

However, several larger architectural ideas were still unimplemented, including global deduplication, solid compression, an advanced decision-making system called T180 Brain, and a complete set of specialized compression profiles.

I consider it important to distinguish implemented functionality from planned functionality.

Instead of pretending that these systems already existed, I decided to establish a reliable performance baseline and improve the actual compression pipeline.

One of the first discoveries was that an important bottleneck had surprisingly little to do with compression mathematics.

It was unnecessary disk access.

The hidden cost of reading files multiple times

In version 0.4.7, the archiver could perform a complete preliminary read of an input file to calculate its CRC checksum.

The same file would then be read again during compression or transfer to the GPU.

For small files, this overhead might be relatively insignificant.

For large files, particularly when using a mechanical hard drive, it can become expensive.

Consider a large file that must be read once to calculate its checksum and then read again to compress it.

The second operation is necessary.

But is the first one?

Most compression pipelines already process the original bytes during encoding. That creates an opportunity to calculate the checksum during the actual compression pass instead of requiring an independent full-file read.

The redesigned pipeline in version 0.4.8 attempts to eliminate this redundant operation wherever it can be done safely.

CRC calculation is integrated into the processing of the actual input blocks.

This preserves integrity checking while reducing unnecessary source reads.

It is a useful reminder that improving a compression engine does not always require inventing a new compression algorithm.

Sometimes the most effective optimization is removing work that should never have been necessary.

Introducing the HYBRID compression mode

The central experiment in version 0.4.8 is a dedicated mode called HYBRID.

Instead of selecting either the processor or the graphics card for an entire archive, HYBRID attempts to distribute suitable workloads between them.

The current architecture evaluates individual files and determines whether they are appropriate candidates for GPU processing.

Suitable files can be processed through a DirectCompute-based GPU run-length encoding implementation.

Other files are processed through CPU-based compression methods, currently including Zstandard or raw storage in the hybrid path.

Different files can be processed in parallel worker threads, allowing CPU and GPU operations to overlap.

The basic architecture looks like this:

 INPUT FILES | Workload analysis | Adaptive codec selection / \ / \ CPU compression GPU compression Zstandard / RAW DirectCompute RLE \ / \ / Archive assembly | Integrity checks 

This is an important architectural distinction.

The graphics card is no longer merely an optional alternative to the processor.

Both computational devices can participate in the same archive creation operation.

However, the current implementation is an initial file-level hybrid system. It does not yet represent a fully developed heterogeneous compression scheduler capable of dynamically distributing every individual compression stage.

That remains a future engineering challenge.

Why maximum GPU utilization is not always the correct objective

One of my original ambitions was to utilize the available computational hardware as aggressively as possible.

Ideally, the archiver should make effective use of all available CPU cores and a substantial portion of GPU resources whenever the workload benefits from parallel processing.

But hardware utilization alone can be a misleading performance metric.

A GPU operating at 100% utilization is not necessarily improving compression performance.

It might simply be performing an inefficient task.

For example, run-length encoding is relatively simple and can be attractive for parallel GPU execution.

However, its compression efficiency depends heavily on the structure of the input data.

A more advanced CPU-based codec may produce a significantly smaller output, even if the GPU completes its operation quickly.

There are also additional costs:

  • Transferring data into GPU memory.
  • Synchronizing GPU workloads.
  • Transferring compressed results back to system memory.
  • Managing memory allocations.
  • Coordinating CPU and GPU worker threads.
  • Writing compressed output to storage.

An effective hybrid system must consider these costs rather than assuming that GPU acceleration is inherently beneficial.

My goal is therefore evolving from simply maximizing hardware utilization toward maximizing useful computational throughput.

The hardware should remain busy when there is productive work available.

It should not perform unnecessary operations merely to make a utilization graph look impressive.

An unexpected compression result

During the development of version 0.4.8, a test involving a file containing zeros demonstrated why adaptive codec selection matters.

The development test reported the following compressed payload sizes:

Compression method Compressed payload
Forced GPU-RLE 1,572,868 bytes
HYBRID selecting Zstandard 16,843 bytes

Despite the extremely repetitive input, the current GPU-RLE implementation produced a substantially larger compressed payload.

Zstandard produced an output approximately 93 times smaller.

This does not demonstrate that GPU compression is generally inferior to CPU compression.

It demonstrates that the specific GPU codec currently implemented in TZIPER180 was not the appropriate choice for this particular workload.

Forcing the GPU to compress that file simply because GPU acceleration was available would have been a poor architectural decision.

The HYBRID mode was therefore extended to estimate not only whether data is suitable for run-length encoding, but also whether the resulting representation is likely to be competitive with CPU-based compression.

If the GPU representation is expected to increase the archive size significantly, the file is redirected to a CPU codec.

This is exactly the type of decision-making I want to expand in future versions.

Adaptive compression instead of fixed compression

Traditional compression settings often ask users to make decisions such as:

  • Which compression algorithm should be used?
  • Which compression level should be selected?
  • How many CPU threads should be enabled?
  • Should compression prioritize speed or archive size?

These options are useful, but they require the user to understand the characteristics of the workload.

I want TZIPER180 to increasingly make these decisions internally.

In the current HYBRID implementation, small samples distributed across a file help estimate its suitability for GPU-RLE without requiring a complete preliminary scan.

In the future, this analysis could become significantly more advanced.

Potential decision factors include:

  • Estimated data entropy.
  • Repeated byte sequences.
  • Repeated blocks across files.
  • File size.
  • Predicted compression ratio.
  • Predicted encoding time.
  • GPU transfer overhead.
  • Available CPU worker capacity.
  • Available GPU memory.
  • Storage throughput.
  • Current hardware utilization.
  • The user's selected balance between speed and compression efficiency.

Rather than treating every file in an archive identically, the archiver could select a processing strategy based on the characteristics of each workload.

This is part of the broader idea behind the planned T180 Brain system.

T180 Brain is not yet a completed component. It represents a future direction for a more sophisticated compression decision engine.

The current HYBRID implementation is an initial step toward that architecture.

Data integrity remains non-negotiable

Performance optimization is meaningless if an archiver cannot reliably restore the original data.

Every change to the compression pipeline must preserve correctness.

The first reported round-trip test of the new HYBRID implementation processed 512 MiB of data.

After compression and extraction:

  • The original data was restored byte for byte.
  • SHA-256 checksums matched.
  • The integrity verification passed.

This is an encouraging initial result, but it is not sufficient to establish production-level reliability.

A complete validation process must include many different file types, archive sizes, compression modes, interruption scenarios, and corrupted input conditions.

In particular, removing preliminary checksum passes introduces a requirement to ensure that the data being compressed does not change unexpectedly during processing.

The implementation therefore also addresses the protection of source files against concurrent modification while they are being read.

Compression performance should never come at the cost of silent data corruption.

The next major challenge: hardware scheduling

The current HYBRID mode distributes different files between CPU and GPU workers.

But this is only the beginning.

A more advanced scheduler could potentially divide large workloads into independent blocks, provided that the codec and archive format support this without unacceptable compression losses.

It could monitor available computational resources and dynamically adjust the distribution of tasks.

For example, consider an archive containing:

  • Large binary files.
  • Source code.
  • Repetitive data.
  • Executables.
  • Images.
  • Already compressed multimedia.
  • Thousands of small documents.

These workloads have very different characteristics.

Some might benefit from CPU compression.

Others could potentially benefit from GPU-based preprocessing or specialized parallel algorithms.

Some should be stored without further compression.

A future hybrid scheduler should ideally recognize these differences and prevent individual computational resources from remaining idle when useful work is available.

Possible future pipeline improvements include:

  • Separate CPU and GPU task queues.
  • Dynamic workload balancing.
  • Asynchronous GPU execution.
  • Overlapping data transfers and compression.
  • Double-buffered input processing.
  • Memory pooling.
  • Storage-aware scheduling.
  • Parallel checksum calculations.
  • Adaptive block sizing.
  • GPU-assisted data analysis.
  • Hybrid preprocessing and CPU-based final encoding.

These are planned research and development directions, not completed features of version 0.4.8.

The problem with existing GPU compression efficiency

Another important observation from the current development process is that GPU acceleration requires suitable algorithms.

The existing GPU-RLE codec is relatively limited.

It can process certain patterns, but it is not designed to replace more sophisticated general-purpose compression algorithms.

This means that the long-term potential of TZIPER180 cannot depend exclusively on GPU-RLE.

I want to investigate additional ways of using the graphics card, including parallel pattern detection, block analysis, preprocessing, and potentially more advanced GPU-compatible compression techniques.

In such an architecture, the GPU would not necessarily produce the final compressed representation independently.

It could accelerate expensive computational stages that help the CPU produce a better compressed result.

That would create a more interesting form of cooperation between the two devices.

The processor and graphics card would no longer simply compete over which one should compress a particular file.

They could contribute different computational strengths to the same compression pipeline.

Benchmarking against 7-Zip

One of my long-term ambitions is to develop TZIPER180 into an archiver capable of competing with established compression software such as 7-Zip.

However, meaningful comparisons require more than carefully selected synthetic tests.

A hybrid architecture must be evaluated across realistic workloads.

The current development process includes work with the Silesia compression corpus, alongside comparisons against the previous version of TZIPER180 and official 7-Zip builds.

I want the eventual benchmarking process to include:

  • Compression speed.
  • Extraction speed.
  • Final archive size.
  • CPU utilization.
  • GPU utilization.
  • Peak memory consumption.
  • GPU memory consumption.
  • Storage throughput.
  • Performance on large individual files.
  • Performance on thousands of small files.
  • Performance on highly repetitive data.
  • Performance on difficult-to-compress data.
  • Complete data integrity verification.

The objective is not to claim victory based on a single favorable benchmark.

A compression engine that performs exceptionally well on repetitive test data but poorly on real-world files has limited practical value.

Likewise, an archiver that creates files quickly but produces archives several times larger than its competitors may simply be exchanging compression efficiency for speed.

Finding a better balance between these objectives is the actual engineering challenge.

At the current stage, I am not claiming that TZIPER180 is generally faster than 7-Zip.

That remains a development objective that must be demonstrated through reproducible measurements.

Development status of version 0.4.8

Version 0.4.8 is currently under active development.

The implementation has been developed in a separate working copy, preserving the previous version for direct comparison.

The current development report includes:

  • Introduction of a dedicated HYBRID mode.
  • Integration of HYBRID into the graphical interface and command-line interface.
  • Parallel file-level CPU and GPU processing.
  • Adaptive selection between GPU-RLE and CPU compression.
  • Estimation of potential GPU compression inefficiency.
  • Reduction of redundant source-file reads.
  • Integration of CRC calculation into encoding operations where appropriate.
  • Successful initial 512 MiB round-trip verification.
  • Separate testing of forced GPU compression.
  • Ongoing benchmarking against previous implementations and 7-Zip.

The final performance results are not yet available.

There is still considerable work ahead before I can evaluate the full effectiveness of the new architecture.

The long-term vision

I do not want TZIPER180 to become merely another graphical interface built around existing compression libraries.

The long-term objective is to develop a compression system capable of intelligently coordinating the entire available hardware environment.

The CPU, GPU, system memory, video memory, and storage system should work as interconnected parts of a single processing architecture.

Different resources should handle the tasks for which they are best suited.

Compression decisions should adapt to the workload instead of depending entirely on fixed presets.

And improvements in speed should be accompanied by improvements in compression efficiency and reliability.

Whether this approach can eventually compete with established archivers remains an open question.

But that uncertainty is precisely what makes developing TZIPER180 interesting to me.

Final thoughts

Working on version 0.4.8 has reinforced an important engineering principle:

The fastest system is not necessarily the one that performs the most work. It is the one that performs the right work as efficiently as possible.

Sometimes that means using every available CPU core.

Sometimes it means accelerating a task with the GPU.

Sometimes it means allowing both devices to operate simultaneously.

And sometimes the best optimization is deciding not to perform an unnecessary operation at all.

I am continuing to explore how these principles can be combined into a practical adaptive compression engine.

I would be particularly interested in hearing from developers who have experience with heterogeneous computing, GPU compression, DirectCompute, parallel algorithms, or high-performance data processing.

What do you think is the most promising role for GPUs in general-purpose file compression: independent encoding, parallel preprocessing, pattern detection, or something entirely different?

Author: TPECKA180 (ТРЕСКА180)

Independent software developer and creator of TZIPER180.