Use shared Zstd(De)Compressor in ResolvedFunction encoding#11217
Use shared Zstd(De)Compressor in ResolvedFunction encoding#11217electrum merged 3 commits intotrinodb:masterfrom
Conversation
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
0ec551f to
bd7976b
Compare
electrum
left a comment
There was a problem hiding this comment.
ZstdDecompressor is not safe to share across threads. It uses ZstdFrameDecompressor which holds state during the decompression operation.
ZstdCompressor has no state, so there shouldn't be any benefit to reusing it.
We don't document the thread safety of the Airlift Compressor and Decompressor interfaces, but probably should. cc @martint
|
@electrum actually ByteBuffer based methods are thread safe in ZstdDecompressor |
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
|
@wendigo you're right. That's a strange choice. We should probably make them both thread safe. In that case, we need to order the commits so that the byte buffer change is first, so that the commit which uses a shared decompressor is safe. |
Compressors and Decompressors are not meant to be thread safe. Some may be due to implementation details, but it's not a requirement. Yes, we should document that. |
That's only a side effect -- we had to resort to synchronization to prevent the JVM from collecting the objects (and deallocating the underlying buffers) while the method is running. But the methods are not required or guaranteed to be thread safe (as mentioned above, Compressors and Decompressors are not meant to be thread-safe) |
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
bd7976b to
5265db2
Compare
5265db2 to
f08b7b5
Compare
|
is the checks' failure related? |
|
@findepi I don't think so. There is a problem with upper bounds for dbpool from commons in redis module. I'm investigating. |
Do you mean we don't have precise version pinned? |
|
@findepi there was dependency pulled in by redis module (transitive from jedis client) and I've added another version since the conflict. |
core/trino-parser/src/main/java/io/trino/sql/tree/QualifiedName.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/util/ThreadSafeCompressorDecompressor.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/util/ThreadSafeCompressorDecompressor.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/util/ThreadSafeCompressorDecompressor.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
f08b7b5 to
81af48e
Compare
|
@findepi PTAL now. I've reworked this PR |
findepi
left a comment
There was a problem hiding this comment.
"Reuse thread-local Zstd de/compressor in ResolvedFunction to Qualifie…"
core/trino-main/src/main/java/io/trino/util/ThreadSafeCompressorDecompressor.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/util/ThreadSafeCompressorDecompressor.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/util/ThreadSafeCompressorDecompressor.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
81af48e to
faf4cd8
Compare
findepi
left a comment
There was a problem hiding this comment.
"Reuse thread-local Zstd de/compressor in ResolvedFunction to Qualifie…"
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
findepi
left a comment
There was a problem hiding this comment.
"Speed up QualifiedName implementation"
core/trino-parser/src/main/java/io/trino/sql/tree/QualifiedName.java
Outdated
Show resolved
Hide resolved
findepi
left a comment
There was a problem hiding this comment.
"Memoize ResolvedFunction <-> QualifiedName conversions"
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
faf4cd8 to
181993d
Compare
core/trino-main/src/main/java/io/trino/metadata/ResolvedFunction.java
Outdated
Show resolved
Hide resolved
181993d to
7b5a2ea
Compare
|
@findepi can we merge it? |
That's probably a question to David. |
Description
Speeds up ResolvedFunction serialization and deserialization, i.e. TestLocalExecutionPlanner now executes in
5530 seconds, instead of 2 minutes 33 seconds.Improvement
Core query engine
Speeds up function resolution
Related issues, pull requests, and links
Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
(x ) No release notes entries required.
( ) Release notes entries required with the following suggested text: