Skip to content

Commit 58872ca

Browse files
committed
Remove a modify-thread permission requirement.
Signed-off-by: Mulugeta Mammo <[email protected]>
1 parent fd30ae6 commit 58872ca

19 files changed

+30
-504
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ For more details on Intel® QAT and installation instructions, refer to the [QAT
66
Qat-Java currently supports the following compression algorithms:
77
- **DEFLATE**
88
- **LZ4**
9-
- **Zstandard (ZSTD)**
109

1110
## Prerequisites
1211

1312
This release was validated with the following tools and libraries:
1413

1514
- [QATlib v24.09.0](https://github.com/intel/qatlib)
1615
- [QATzip v1.3.0](https://github.com/intel/QATzip/releases) and its dependencies
17-
- [Zstandard v1.5.4](https://github.com/facebook/zstd)
18-
- [Zstd-jni v1.5.6-1](https://github.com/luben/zstd-jni) or newer (if you're not building from source)
1916
- GCC 8.5 or newer
2017
- JDK 17 or newer
2118
- Clang (for fuzz testing)
@@ -62,7 +59,7 @@ mvn test -Dfuzzing=true
6259
To run an example from the `com.intel.qat.examples` package, use the following command:
6360

6461
```
65-
java -cp .:./target/classes/:path/to/zstd-jni-1.5.6-1.jar com.intel.qat.examples.<ExampleClass>
62+
java -cp .:./target/classes/ com.intel.qat.examples.<ExampleClass>
6663
```
6764

6865
## Authors

jmh/qat-java-bench/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
A set of JMH benchmarks.
33
```
44
Name | Algorithm
5-
--------------------------------------------
6-
QatJavaBench | DEFLATE, LZ4, ZSTD
7-
QatJavaStreamBench | DEFLATE, LZ4, ZSTD
5+
----------------------------------
6+
QatJavaBench | DEFLATE, LZ4
7+
QatJavaStreamBench | DEFLATE, LZ4
88
```
99

1010
## Build
@@ -17,8 +17,8 @@ mvn clean package
1717
To run the benchmark, use the below command:
1818

1919
```
20-
java -jar target/benchmarks.jar QatJavaBench -p file=/path/to/a/text-corpus -p algorithm=<"DEFLATE"|"LZ4"|"ZSTD"> -p level=<level> -p blockSize=<size> <jmh-params>
21-
java -jar target/benchmarks.jar QatJavaStreamBench -p file=/path/to/a/text-corpus -p algorithm=<"DEFLATE"|"LZ4"|"ZSTD"> -p level=<level> -p blockSize=<size> <jmh-params>
20+
java -jar target/benchmarks.jar QatJavaBench -p file=/path/to/a/text-corpus -p algorithm=<"DEFLATE"|"LZ4""> -p level=<level> -p blockSize=<size> <jmh-params>
21+
java -jar target/benchmarks.jar QatJavaStreamBench -p file=/path/to/a/text-corpus -p algorithm=<"DEFLATE"|"LZ4"> -p level=<level> -p blockSize=<size> <jmh-params>
2222
```
2323

2424
Examples:

jmh/qat-java-bench/pom.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
3535

3636
<groupId>com.intel.qat.jmh</groupId>
3737
<artifactId>qat-java-bench</artifactId>
38-
<version>2.3.2</version>
38+
<version>2.2.1</version>
3939
<packaging>jar</packaging>
4040

4141
<name>JMH benchmark sample: Java</name>
@@ -60,12 +60,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
6060
<dependency>
6161
<groupId>com.intel.qat</groupId>
6262
<artifactId>qat-java</artifactId>
63-
<version>2.3.2</version>
64-
</dependency>
65-
<dependency>
66-
<groupId>com.github.luben</groupId>
67-
<artifactId>zstd-jni</artifactId>
68-
<version>1.5.6-1</version>
63+
<version>2.2.1</version>
6964
</dependency>
7065
</dependencies>
7166

jmh/qat-java-bench/src/main/java/com/intel/qat/jmh/QatJavaBench.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class QatJavaBench {
3232
@Param({"65536"})
3333
static int blockSize;
3434

35-
@Param({"DEFLATE", "LZ4", "ZSTD"})
35+
@Param({"DEFLATE", "LZ4"})
3636
static String algorithm;
3737

3838
@State(Scope.Thread)
@@ -52,9 +52,6 @@ public ThreadState() {
5252
case "LZ4":
5353
algorithm = Algorithm.LZ4;
5454
break;
55-
case "ZSTD":
56-
algorithm = Algorithm.ZSTD;
57-
break;
5855
default:
5956
throw new IllegalArgumentException("Invalid algorithm. Supported are DEFLATE and LZ4.");
6057
}

jmh/qat-java-bench/src/main/java/com/intel/qat/jmh/QatJavaStreamBench.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class QatJavaStreamBench {
3434
@Param({"6"})
3535
static int level;
3636

37-
@Param({"DEFLATE", "LZ4", "ZSTD"})
37+
@Param({"DEFLATE", "LZ4"})
3838
static String algorithm;
3939

4040
@State(Scope.Thread)
@@ -52,9 +52,6 @@ public ThreadState() {
5252
case "LZ4":
5353
algorithm = Algorithm.LZ4;
5454
break;
55-
case "ZSTD":
56-
algorithm = Algorithm.ZSTD;
57-
break;
5855
default:
5956
throw new IllegalArgumentException("Invalid algorithm. Supported are DEFLATE and LZ4.");
6057
}

pom.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.intel.qat</groupId>
77
<artifactId>qat-java</artifactId>
8-
<version>2.3.2</version>
8+
<version>2.2.1</version>
99
<packaging>jar</packaging>
1010
<name>qat-java</name>
1111
<description>Qat-Java is a data compression library that uses Intel® QAT to speed up compression.</description>
@@ -281,11 +281,6 @@
281281
</plugins>
282282
</reporting>
283283
<dependencies>
284-
<dependency>
285-
<groupId>com.github.luben</groupId>
286-
<artifactId>zstd-jni</artifactId>
287-
<version>1.5.6-1</version>
288-
</dependency>
289284
<dependency>
290285
<groupId>org.junit.platform</groupId>
291286
<artifactId>junit-platform-suite</artifactId>
@@ -332,7 +327,7 @@
332327
<arguments>
333328
<argument>-ea</argument>
334329
<argument>-cp</argument>
335-
<argument>${project.build.directory}/qat-java-2.3.2.jar</argument>
330+
<argument>${project.build.directory}/qat-java-2.2.1.jar</argument>
336331
<argument>-cp</argument>
337332
<classpath/>
338333
<argument>com.code_intelligence.jazzer.Jazzer</argument>

src/main/java/com/intel/qat/InternalJNI.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,5 @@ static native int decompressDirectByteBufferDst(
129129
int dstLen,
130130
int retryCount);
131131

132-
static native long zstdGetSeqProdFunction();
133-
134-
static native long zstdCreateSeqProdState();
135-
136-
static native void zstdFreeSeqProdState(long sequenceProdState);
137-
138132
static native int teardown(int qzKey);
139133
}

src/main/java/com/intel/qat/QatDecompressorInputStream.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import static com.intel.qat.QatZipper.Algorithm;
1010

11-
import com.github.luben.zstd.ZstdException;
1211
import java.io.FilterInputStream;
1312
import java.io.IOException;
1413
import java.io.InputStream;
@@ -68,7 +67,6 @@ public QatDecompressorInputStream(InputStream in, int bufferSize, QatZipper.Buil
6867
super(in);
6968
if (bufferSize <= 0) throw new IllegalArgumentException();
7069
Objects.requireNonNull(in);
71-
if (builder.getAlgorithm().equals(Algorithm.ZSTD)) MAX_BUFFER_SIZE = Integer.MAX_VALUE - 1;
7270
int inputBufferSize = 0;
7371
try {
7472
inputBufferSize = Math.max(bufferSize, in.available());
@@ -258,7 +256,7 @@ private void fill() throws IOException {
258256
outputBufferLimit - outputPosition);
259257
inputPosition += qzip.getBytesRead();
260258
outputPosition += decompressed;
261-
} catch (ZstdException zstde) {
259+
} catch (RuntimeException e) {
262260
growOutputBuffer();
263261
}
264262
if (decompressed == 0 && inputPosition == 0) growOutputBuffer();

src/main/java/com/intel/qat/QatZipper.java

Lines changed: 6 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
package com.intel.qat;
88

9-
import com.github.luben.zstd.Zstd;
10-
import com.github.luben.zstd.ZstdCompressCtx;
11-
import com.github.luben.zstd.ZstdDecompressCtx;
129
import java.nio.ByteBuffer;
1310
import java.nio.ReadOnlyBufferException;
1411

@@ -116,25 +113,13 @@ public class QatZipper {
116113
/** Id of this object (set by the JNI code) based on algorithm, etc.. */
117114
private int qzKey;
118115

119-
/** Zstd compress context. */
120-
private ZstdCompressCtx zstdCompressCtx;
121-
122-
/** Zstd decompress context. */
123-
private ZstdDecompressCtx zstdDecompressCtx;
124-
125-
/** Checksum flag, currently valid for only ZSTD. */
126-
private boolean checksumFlag;
127-
128116
/** The compression algorithm to use. DEFLATE and LZ4 are supported. */
129117
public static enum Algorithm {
130118
/** The deflate compression algorithm. */
131119
DEFLATE,
132120

133121
/** The LZ4 compression algorithm. */
134-
LZ4,
135-
136-
/** The Zstandard compression algorithm. */
137-
ZSTD
122+
LZ4
138123
}
139124

140125
/** The mode of execution for QAT. */
@@ -409,11 +394,6 @@ private QatZipper(Builder builder) throws RuntimeException {
409394

410395
if (retryCount < 0) throw new IllegalArgumentException("Invalid value for retry count");
411396

412-
if (algorithm == Algorithm.ZSTD) {
413-
zstdCompressCtx = new ZstdCompressCtx();
414-
zstdDecompressCtx = new ZstdDecompressCtx();
415-
}
416-
417397
int status =
418398
InternalJNI.setup(
419399
this,
@@ -424,15 +404,6 @@ private QatZipper(Builder builder) throws RuntimeException {
424404
dataFormat.ordinal(),
425405
hwBufferSize.getValue());
426406

427-
if (algorithm == Algorithm.ZSTD) {
428-
final int QZ_OK = 0; // indicates that ZSTD can start QAT device
429-
if (mode == Mode.HARDWARE || (mode == Mode.AUTO && status == QZ_OK)) {
430-
zstdCompressCtx.registerSequenceProducer(new QatZstdSequenceProducer());
431-
zstdCompressCtx.setSequenceProducerFallback(true);
432-
}
433-
zstdCompressCtx.setLevel(level);
434-
}
435-
436407
isValid = true;
437408
}
438409

@@ -478,11 +449,7 @@ public QatZipper(Algorithm algorithm, int level) {
478449
public int maxCompressedLength(long len) {
479450
if (!isValid) throw new IllegalStateException("QAT session has been closed");
480451

481-
if (algorithm != Algorithm.ZSTD) {
482-
return InternalJNI.maxCompressedSize(qzKey, len);
483-
}
484-
485-
return (int) Zstd.compressBound(len);
452+
return InternalJNI.maxCompressedSize(qzKey, len);
486453
}
487454

488455
/**
@@ -524,16 +491,7 @@ public int compress(
524491
if (dstOffset < 0 || dstLen < 0 || dstOffset > dst.length - dstLen)
525492
throw new ArrayIndexOutOfBoundsException("Destination offset is out of bound");
526493

527-
if (algorithm != Algorithm.ZSTD) {
528-
return compressByteArray(src, srcOffset, srcLen, dst, dstOffset, dstLen);
529-
} else {
530-
bytesRead = bytesWritten = 0;
531-
int compressedSize =
532-
zstdCompressCtx.compressByteArray(dst, dstOffset, dstLen, src, srcOffset, srcLen);
533-
bytesWritten = compressedSize;
534-
bytesRead = srcLen;
535-
return compressedSize;
536-
}
494+
return compressByteArray(src, srcOffset, srcLen, dst, dstOffset, dstLen);
537495
}
538496

539497
private int compressByteArray(
@@ -569,12 +527,7 @@ public int compress(ByteBuffer src, ByteBuffer dst) {
569527

570528
if (dst.isReadOnly()) throw new ReadOnlyBufferException();
571529

572-
if (algorithm != Algorithm.ZSTD) {
573-
return compressByteBuffer(src, dst);
574-
} else {
575-
// ZSTD treats the first parameter as the destination and the second as the source.
576-
return zstdCompressCtx.compress(dst, src);
577-
}
530+
return compressByteBuffer(src, dst);
578531
}
579532

580533
private int compressByteBuffer(ByteBuffer src, ByteBuffer dst) {
@@ -690,16 +643,7 @@ public int decompress(
690643
if (dstOffset < 0 || dstLen < 0 || dstOffset > dst.length - dstLen)
691644
throw new ArrayIndexOutOfBoundsException("Destination offset is out of bound");
692645

693-
if (algorithm != Algorithm.ZSTD) {
694-
return decompressByteArray(src, srcOffset, srcLen, dst, dstOffset, dstLen);
695-
} else {
696-
bytesRead = bytesWritten = 0;
697-
int decompressedSize =
698-
zstdDecompressCtx.decompressByteArray(dst, dstOffset, dstLen, src, srcOffset, srcLen);
699-
bytesWritten = decompressedSize;
700-
bytesRead = srcLen;
701-
return decompressedSize;
702-
}
646+
return decompressByteArray(src, srcOffset, srcLen, dst, dstOffset, dstLen);
703647
}
704648

705649
private int decompressByteArray(
@@ -737,15 +681,7 @@ public int decompress(ByteBuffer src, ByteBuffer dst) {
737681

738682
if (dst.isReadOnly()) throw new ReadOnlyBufferException();
739683

740-
if (algorithm != Algorithm.ZSTD) {
741-
return decompressByteBuffer(src, dst);
742-
} else {
743-
// ZSTD treats the first parameter as the destination and the second as the source.
744-
if (!src.isDirect())
745-
throw new IllegalArgumentException(
746-
"Zstd-jni requires source buffers to be direct byte buffers");
747-
return zstdDecompressCtx.decompress(dst, src);
748-
}
684+
return decompressByteBuffer(src, dst);
749685
}
750686

751687
private int decompressByteBuffer(ByteBuffer src, ByteBuffer dst) {
@@ -845,19 +781,6 @@ public int getBytesWritten() {
845781
return bytesWritten;
846782
}
847783

848-
/**
849-
* Sets a checksum flag. Currently valid only for ZSTD.
850-
*
851-
* @param checksumFlag the checksum flag.
852-
* @throws UnsupportedOperationException if called for a compressor algorithm other than ZSTD.
853-
*/
854-
public void setChecksumFlag(boolean checksumFlag) {
855-
if (algorithm != Algorithm.ZSTD)
856-
throw new UnsupportedOperationException(
857-
"Setting a checksum flag is currently valid only for ZSTD compressor");
858-
zstdCompressCtx.setChecksum(checksumFlag);
859-
}
860-
861784
/**
862785
* Ends the current QAT session by freeing up resources. A new session must be used after a
863786
* successful call of this method.

0 commit comments

Comments
 (0)