You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@celeborn.apache.org by "Jraaay (via GitHub)" <gi...@apache.org> on 2025/07/31 07:49:14 UTC

[PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Jraaay opened a new pull request, #3402:
URL: https://github.com/apache/celeborn/pull/3402

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     - Make sure the PR title start w/ a JIRA ticket, e.g. '[CELEBORN-XXXX] Your PR title ...'.
     - Be sure to keep the PR description updated to reflect all changes.
     - Please write your PR title to summarize what this PR proposes.
     - If possible, provide a concise example to reproduce the issue for a faster review.
   -->
   
   ### What changes were proposed in this pull request?
   This PR adds support for lz4 decompression in CppClient.
   
   
   ### Why are the changes needed?
   To support reading from Celeborn with CppClient.
   
   
   ### Does this PR introduce _any_ user-facing change?
   No.
   
   
   ### How was this patch tested?
   By compilation and UTs.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "HolyLow (via GitHub)" <gi...@apache.org>.
HolyLow commented on code in PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#discussion_r2246761121


##########
cpp/celeborn/client/compress/Lz4Trait.h:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+namespace celeborn {
+namespace client {
+namespace compress {
+
+struct Lz4Trait {
+  static constexpr int MAGIC_LENGTH = 8;

Review Comment:
   The static constants' naming method might be kMagicLength, rather than CAPCITAL_CAPITAL?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "HolyLow (via GitHub)" <gi...@apache.org>.
HolyLow commented on PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#issuecomment-3141952910

   @Jraaay Thanks for your contribution. It seems that the data must be copied to a buffer before it is read from CelebornInputStream regardless of whether the compression is involved or not. But the initial implementation avoids the copying when compression is not involved. Could we find a way to avoid the unnecessary copy in the non-compression case?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "HolyLow (via GitHub)" <gi...@apache.org>.
HolyLow commented on code in PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#discussion_r2246764793


##########
cpp/celeborn/client/reader/CelebornInputStream.h:
##########
@@ -68,6 +70,10 @@ class CelebornInputStream {
   int attemptNumber_;
   int startMapIndex_;
   int endMapIndex_;
+  bool shouldDecompress_;
+  std::unique_ptr<compress::Decompressor> decompressor_;
+  std::vector<char> rawDataBuf_;

Review Comment:
   Use uint8_t might be slightly better than using char. char is not a well-defined type as it might be signed in some compilers while unsigned in others.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "HolyLow (via GitHub)" <gi...@apache.org>.
HolyLow commented on code in PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#discussion_r2246766477


##########
cpp/celeborn/client/CMakeLists.txt:
##########
@@ -16,7 +16,12 @@ add_library(
         client
         reader/WorkerPartitionReader.cpp
         reader/CelebornInputStream.cpp
-        ShuffleClient.cpp)
+        ShuffleClient.cpp
+        compress/Decompressor.h

Review Comment:
   .h file is not needed in compilation. Only .c files are compilation units.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "Jraaay (via GitHub)" <gi...@apache.org>.
Jraaay commented on PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#issuecomment-3143902719

   @HolyLow Refactored as requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "SteNicholas (via GitHub)" <gi...@apache.org>.
SteNicholas closed pull request #3402: [CELEBORN-2090] Support Lz4 Decompression in CppClient
URL: https://github.com/apache/celeborn/pull/3402


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "HolyLow (via GitHub)" <gi...@apache.org>.
HolyLow commented on code in PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#discussion_r2250466687


##########
cpp/celeborn/memory/ByteBuffer.h:
##########
@@ -126,6 +125,9 @@ class ReadOnlyByteBuffer : public ByteBuffer {
     return cursor_->pullAtMost(buf, len);
   }
 
+  std::unique_ptr<ReadOnlyByteBuffer> readToReadOnlyBuffer(
+      const uint32_t len) const;

Review Comment:
   shouldbe size_t type



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "HolyLow (via GitHub)" <gi...@apache.org>.
HolyLow commented on code in PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#discussion_r2250468591


##########
cpp/celeborn/client/compress/Decompressor.h:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include "celeborn/protocol/CompressionCodec.h"
+
+namespace celeborn {
+namespace client {
+namespace compress {
+
+class Decompressor {
+ public:
+  virtual ~Decompressor() = default;
+
+  virtual int decompress(const uint8_t* src, uint8_t* dst, int dst_off) = 0;
+
+  virtual int getOriginalLen(const uint8_t* src) = 0;
+
+  static std::unique_ptr<Decompressor> getDecompressor(

Review Comment:
   rename to `create` might be more consistent to other code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "Jraaay (via GitHub)" <gi...@apache.org>.
Jraaay commented on PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#issuecomment-3149228935

   > Looks great % a few naming suggestions.
   
   @HolyLow Refactored as requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "Jraaay (via GitHub)" <gi...@apache.org>.
Jraaay commented on PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#issuecomment-3139212714

   @HolyLow @FMX @RexXiong @SteNicholas Could you kindly help review this PR? Thanks a lot.
   
   Note that the dev image is updated to `jraaaay/celeborn-cpp-dev:0.4` to add lz4 & xxhash lib in the dev container.
   
   Any suggestion is welcome.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "HolyLow (via GitHub)" <gi...@apache.org>.
HolyLow commented on code in PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#discussion_r2246760207


##########
cpp/celeborn/client/compress/Lz4Trait.h:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+namespace celeborn {
+namespace client {
+namespace compress {
+
+struct Lz4Trait {
+  static constexpr int MAGIC_LENGTH = 8;
+  static constexpr char MAGIC[MAGIC_LENGTH] =
+      {'L', 'Z', '4', 'B', 'l', 'o', 'c', 'k'};
+
+  static constexpr int HEADER_LENGTH = MAGIC_LENGTH + 1 + 4 + 4 + 4;

Review Comment:
   Maybe consider using sizeof(xxx) rather than raw number.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "HolyLow (via GitHub)" <gi...@apache.org>.
HolyLow commented on code in PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#discussion_r2246764793


##########
cpp/celeborn/client/reader/CelebornInputStream.h:
##########
@@ -68,6 +70,10 @@ class CelebornInputStream {
   int attemptNumber_;
   int startMapIndex_;
   int endMapIndex_;
+  bool shouldDecompress_;
+  std::unique_ptr<compress::Decompressor> decompressor_;
+  std::vector<char> rawDataBuf_;

Review Comment:
   Use uint8_t would be better than using char. char is not a well-defined type as it might be signed in some compilers while unsigned in others.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CELEBORN-2090] Support Lz4 Decompression in CppClient [celeborn]

Posted by "HolyLow (via GitHub)" <gi...@apache.org>.
HolyLow commented on PR #3402:
URL: https://github.com/apache/celeborn/pull/3402#issuecomment-3149357720

   LGTM. Thanks for your contribution.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org