zEnterprise Data Compression(zEDC) support
With z15® or later, IBM® Integrated Accelerator for zEnterprise® Data Compression is provided on each processor chip and uses industry-standard compression formats for file compression that can enable reduction in the size of data which can save storage space and increase data transfer rates. It can also reduce CPU consumption and costs associated with moving, processing, encrypting/decrypting, and otherwise manipulating smaller amounts of compressed data.
IBM
Open Enterprise SDK for Node.js includes support for zEDC
acceleration to the Node.js for z/OS® ecosystem through the
zlib
Node.js module, which is used extensively for gzip compression and
decompression. Users of gzip compression in Node.js may notice significant performance benefits
after updating to IBM
Open Enterprise SDK for Node.js 22.0 and later
versions.
Usage
The zEDC feature for IBM Node.js is designed to be
transparent to Node.js developers, minimizing code changes required to take advantage of this
feature. For more information about data compression, see the official API document for
zlib
modules (https://nodejs.org/docs/latest-v22.x/api/zlib.html).
For situations where zEDC acceleration cannot be used, the zlib
module
automatically switches to software compression or decompression, with no further code required.
Limitation
- If compression level is set to a non-default value during initialization, software compression is automatically used instead.
- Changing compression level after initialization using
zlib.params
is ignored. For cases where high compression ratio is essential, you can turn off zEDC hardware acceleration during runtime by setting the environmental variable _HZC_COMPRESSION_METHOD to software, or by using the Node.js flag --hzc-compression-method=software - Using software compression or decompression with zlib-based streams might result in reduced performance compared to previous releases of Node.js. Therefore, the use of hardware acceleration is recommended when possible.
- When using raw inflate, the
zlib
module automatically switches to software decompression instead. - Only software is available for Brotli-based streams.
zEDC Monitor API
The hwCheck()
function, which takes no arguments, can be used to check whether
an existing zlib stream is currently using software or hardware.
const fs = require('node:fs');
const zlib = require('node:zlib');
const file = fs.readFileSync('image.jpg');
const deflater = zlib.createDeflate();
deflater.on('data', () => {
let hwCheck = deflater.hwCheck();
if (hwCheck === zlib.constants.Z_HARDWARE_PENDING) {
console.log('the stream will try and go to the hardware if possible');
} else if (hwCheck === zlib.constants.Z_HARDWARE) {
console.log('the stream is currently using hardware');
} else if (hwCheck === zlib.constants.Z_SOFTWARE) {
console.log('the stream is currently using software');
}
});
deflater.end(file);
zEDC enablement
For more information about zEDC enablement, check Overview and planning of zEnterprise Data Compression (zEDC).