Enabling hardware compression acceleration (AIX, Linux only)

You can use hardware compression acceleration to increase the speed of data compression and decompression on some Power Systems or IBM Z® systems. If your application uses java.util.zip classes to provide Java™ compression services, hardware compression can reduce CPU consumption and shorten processing times.

Before you begin

Hardware compression is done by a PCIe data compression/decompression card, driven by the Generic Work Queue Engine (GenWQE) device driver that is provided in some operating systems. If you want your Java applications to use hardware compression services, your system must meet the following software and hardware requirements:
AIX
  • AIX® 7.1, Technology Level 3, Service Pack 2, or later
  • GenWQE device driver. The aforementioned operating systems already include this driver.
  • PCIe3 LP Field Programmable Gate Array (FPGA) Accelerator Adapter
Linux on Power Systems
  • One of the following operating systems:
    • Red Hat Enterprise Linux® 7 for 64-bit Power Systems
    • Start of changes for service refresh 1Red Hat Enterprise Linux 7.1 for 64-bit Power Systems (Little Endian)End of changes for service refresh 1
    • Red Hat Enterprise Linux 7.3 for 64-bit Power Systems (Little Endian)
  • GenWQE device driver. The aforementioned operating systems already include this driver.
  • PCIe3 LP Field Programmable Gate Array (FPGA) Accelerator Adapter
Start of changes for service refresh 2 fix pack 10
Linux on IBM Z
  • One of the following hardware systems: IBM zEnterprise® zEC12 GA2, zBC12, z13, z14, Start of changes for service refresh 6z15 or laterEnd of changes for service refresh 6. Additional requirements depend on your hardware system:
Start of changes for service refresh 6
z15 and later
There are no hardware or software requirements for z15 or later systems. The Integrated Accelerator for zEDC solution in these systems provides built-in data acceleration, so a separate adapter is no longer required.
End of changes for service refresh 6
z14 and earlier
  • One of the following operating systems:
    • SUSE Linux Enterprise Server for System z® 12 SP1 or later
    • Start of changes for service refresh 3Red Hat Enterprise Linux 7.2 for z Systems®End of changes for service refresh 3
  • GenWQE device driver. The aforementioned operating systems already include this driver.
  • IBM® zEnterprise zEC12 GA2, zBC12, z13, or z14.
  • zEDC Express adapter, installed in the PCIe I/O drawers of the server.
Note: Hardware compression on z14 and earlier systems uses the zEDC Express adapter, which is now deprecated.
End of changes for service refresh 2 fix pack 10

For more information about installing and using GenWQE, see Generic Work Queue Engine (GenWQE) introduction in the Linux information.

About this task

Accelerated Data Compression is provided as part of the developer kit Zip native library, which you call by using the java.util.zip application programming interface.

Procedure

  1. z14 and earlier only: Set the following environment variables:
    export ZLIB_DEFLATE_IMPL=1
    export ZLIB_INFLATE_IMPL=1
    These environment variables specify whether hardware or software compression or decompression is used. By default, both variables are set to 0, which specifies that software compression services are used for both compression and decompression for Java applications.
  2. z14 and earlier only: Check that the input buffers for your Java application are sufficiently large.

    Some CPU resource is required to send data to the hardware compression accelerator. For small amounts of data, this resource cost can be greater than the savings that are achieved by using hardware compression services. You can set a threshold value for the data that is to be sent to hardware compression services, by using the ZLIB_INFLATE_THRESHOLD variable. If the size of the data is below the threshold (default 16 KB), software compression is used instead.

    Here are some methods for determining an application's current buffer size:
    • Examine the source code
    • Examine the behavior of the application by tracing it (see Tracing Java applications in the J9 VM reference), or monitoring it with a tool.
  3. In your Java application, use the classes and methods in the java.util.zip package to compress and decompress data.
    The following example (which excludes imports and try/catch blocks) uses the GZIPOutputStream class to read data from one file and write compressed data to another file:
    // This 64 KB input buffer exceeds the threshold value set by ZLIB_INFLATE_THRESHOLD, 
    // so is elegible for hardware compression:
    byte buffer[] = new byte[64 * 1024];
    byte outputFile[];
    
    input = new FileInputStream(argv[0]);
    output = new ByteArrayOutputStream();
    gzStream = new GZIPOutputStream(output, 4096);
    
    for(;;) {
        // Read data from an uncompressed file:
        readBytes = input.read(buffer);
        if(readBytes < 0) {
            break;
        }
        else {
            // Write data to a compressed file:
            gzStream.write(buffer, 0, readBytes);
        }
    }

Results

If your system meets the requirements and conditions that are described, accelerated hardware data compression is used. Otherwise, software-based compression services are used for data compression and decompression.

If you want to measure the difference in performance for your Java application with and without hardware compression, you can use the following environment variables to temporarily disable hardware acceleration:
  • Start of changes for service refresh 6z15 or later: DFLTCC=0End of changes for service refresh 6
  • z14 or earlier: ZLIB_DEFLATE_IMPL=0 for compression and ZLIB_INFLATE_IMPL=0 for decompression.

If you experience problems, see Hardware compression acceleration issues on Power Systems and IBM Z systems (AIX, Linux only).