You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2023/04/07 03:10:18 UTC

[GitHub] [arrow] mapleFU opened a new pull request, #34955: GH-34335: [C++][Parquet] Optimize Decoding DELTA_LENGTH_BYTE_ARRAY

mapleFU opened a new pull request, #34955:
URL: https://github.com/apache/arrow/pull/34955

   <!--
   Thanks for opening a pull request!
   If this is your first pull request you can find detailed information on how 
   to contribute here:
     * [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
     * [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
   
   
   If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   In the case of PARQUET issues on JIRA the title also supports:
   
       PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   -->
   
   ### Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   According to https://github.com/apache/arrow/pull/34323 . DELTA_LENGTH_BYTE_ARRAY is much more slower. So do some optimizations.
   
   ### What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Some tiny changes
   
   ### Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ### Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
   -->
   <!-- **This PR includes breaking changes to public APIs.** -->
   
   <!--
   Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
   -->
   <!-- **This PR contains a "Critical Fix".** -->


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow] github-actions[bot] commented on pull request #34955: GH-34335: [C++][Parquet] Optimize Decoding DELTA_LENGTH_BYTE_ARRAY

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #34955:
URL: https://github.com/apache/arrow/pull/34955#issuecomment-1499885660

   * Closes: #34335


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow] wjones127 merged pull request #34955: GH-34335: [C++][Parquet] Optimize Decoding DELTA_LENGTH_BYTE_ARRAY

Posted by "wjones127 (via GitHub)" <gi...@apache.org>.
wjones127 merged PR #34955:
URL: https://github.com/apache/arrow/pull/34955


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow] mapleFU commented on pull request #34955: GH-34335: [C++][Parquet] Optimize Decoding DELTA_LENGTH_BYTE_ARRAY

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #34955:
URL: https://github.com/apache/arrow/pull/34955#issuecomment-1500868181

   @wjones127 comment resolved, you can take a look when you have spare time :)


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow] wjones127 commented on a diff in pull request #34955: GH-34335: [C++][Parquet] Optimize Decoding DELTA_LENGTH_BYTE_ARRAY

Posted by "wjones127 (via GitHub)" <gi...@apache.org>.
wjones127 commented on code in PR #34955:
URL: https://github.com/apache/arrow/pull/34955#discussion_r1160976252


##########
cpp/src/parquet/encoding.cc:
##########
@@ -2745,6 +2738,7 @@ class DeltaLengthByteArrayDecoder : public DecoderImpl,
     int32_t data_size = 0;
     const int32_t* length_ptr =
         reinterpret_cast<const int32_t*>(buffered_length_->data()) + length_idx_;
+    int bytes_left = decoder_->bytes_left();

Review Comment:
   nit: could we rewrite this as `bytes_offset`? That way it's clearer why we are computing this before calling `decoder_->Advance()`
   
   ```suggestion
       int bytes_offset = len_ - decoder_->bytes_left();
   ```



##########
cpp/src/parquet/encoding.cc:
##########
@@ -2756,13 +2750,10 @@ class DeltaLengthByteArrayDecoder : public DecoderImpl,
       }
     }
     length_idx_ += max_values;
-
-    PARQUET_THROW_NOT_OK(buffered_data_->Resize(data_size));
-    if (decoder_->GetBatch(8, buffered_data_->mutable_data(), data_size) != data_size) {
+    if (ARROW_PREDICT_FALSE(!decoder_->Advance(8 * static_cast<int64_t>(data_size)))) {
       ParquetException::EofException();
     }
-    const uint8_t* data_ptr = buffered_data_->data();
-
+    const uint8_t* data_ptr = data_ + (len_ - bytes_left);

Review Comment:
   ```suggestion
       const uint8_t* data_ptr = data_ + bytes_offset;
   ```



##########
cpp/src/parquet/encoding.cc:
##########
@@ -3071,8 +3061,14 @@ class DeltaByteArrayDecoder : public DecoderImpl,
     prefix_len_offset_ = 0;
     num_valid_values_ = num_prefix;
 
+    int bytes_left = decoder_->bytes_left();
+    int suffix_begins = len - bytes_left;
+    if (suffix_begins < 0) {
+      throw ParquetException(
+          "Wrong data in DeltaByteArrayDecoder: bytes_left more than length");
+    }

Review Comment:
   If this happens, doesn't that mean we have already read past the buffer end (buffer overflow)? Seems like that should be handled in the lengths decoder.



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow] mapleFU commented on pull request #34955: GH-34335: [C++][Parquet] Optimize Decoding DELTA_LENGTH_BYTE_ARRAY

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #34955:
URL: https://github.com/apache/arrow/pull/34955#issuecomment-1499885516

   @rok @wjones127 @wgtmac 


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow] ursabot commented on pull request #34955: GH-34335: [C++][Parquet] Optimize Decoding DELTA_LENGTH_BYTE_ARRAY

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #34955:
URL: https://github.com/apache/arrow/pull/34955#issuecomment-1501005427

   Benchmark runs are scheduled for baseline = 9833a0aab31451a7dc8c3159ee7d7eac24cb5af7 and contender = 28ca876dc41b696bda8159daa1c4e9be2b799c48. 28ca876dc41b696bda8159daa1c4e9be2b799c48 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/d9608e37761d4ea7a9c4d85016d0613e...b6f23fa7cec74a4db4ef1c27483ca4bd/)
   [Finished :arrow_down:0.68% :arrow_up:0.42%] [test-mac-arm](https://conbench.ursa.dev/compare/runs/7924058cec264855afcc08fa8dc227ae...874f884fd6764131a8241cd883012af8/)
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/f11c6b7389a746e385eb7e677461d297...bb5e74dcc54547c8bd6a5fe26cf16bff/)
   [Finished :arrow_down:0.89% :arrow_up:0.43%] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/cad8246926c040be95696d11eec87fe7...91be6497facb4f37b327464d30ee18e3/)
   Buildkite builds:
   [Finished] [`28ca876d` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2659)
   [Finished] [`28ca876d` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2692)
   [Finished] [`28ca876d` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2657)
   [Finished] [`28ca876d` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2683)
   [Finished] [`9833a0aa` ec2-t3-xlarge-us-east-2](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/2658)
   [Finished] [`9833a0aa` test-mac-arm](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/2691)
   [Finished] [`9833a0aa` ursa-i9-9960x](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/2656)
   [Finished] [`9833a0aa` ursa-thinkcentre-m75q](https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/2682)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

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