Skip to content

Workaround for nvcomp zstd overwriting blocks for orc due to underestimate of sizes - #11288

Merged
rapids-bot[bot] merged 7 commits into
NVIDIA:branch-22.08from
jbrennan333:jtb-cudf-orc-workaround
Jul 22, 2022
Merged

Workaround for nvcomp zstd overwriting blocks for orc due to underestimate of sizes#11288
rapids-bot[bot] merged 7 commits into
NVIDIA:branch-22.08from
jbrennan333:jtb-cudf-orc-workaround

Conversation

@jbrennan333

@jbrennan333 jbrennan333 commented Jul 18, 2022

Copy link
Copy Markdown
Contributor

This is a possible workaround for issue #11280. We have a goal to support NVCOMP ZSTD in 22.08, so a short-term fix is desired.

There is a heuristic in gpuParseCompressedStripeData to estimate the size of the decompress buffer for very small compressed blocks. For ZSTD, it is possible to have a high enough compression ratio that this heuristic underestimates the needed decompress size.

This pr adds a boolean parameter to allow us to disable the block size estimate for ZSTD. When the estimate is disabled, it falls back to the maximum block size, which is guaranteed to be big enough.

cc: @devavret, @vuule

@jbrennan333 jbrennan333 added bug Something isn't working 4 - Needs cuIO Reviewer non-breaking Non-breaking change labels Jul 18, 2022
@jbrennan333 jbrennan333 self-assigned this Jul 18, 2022
@github-actions github-actions Bot added the libcudf Affects libcudf (C++/CUDA) code. label Jul 18, 2022
@jbrennan333

Copy link
Copy Markdown
Contributor Author

I think I might put up a less hacky alternative that just adds a boolean allow_block_size_estimate parameter to ParseCompressedStripeData. I can set it to true for all but ZSTD.

@codecov

codecov Bot commented Jul 18, 2022

Copy link
Copy Markdown

Codecov Report

Merging #11288 (e9a9688) into branch-22.08 (edc5062) will increase coverage by 0.06%.
The diff coverage is 100.00%.

❗ Current head e9a9688 differs from pull request most recent head f496f8d. Consider uploading reports for the commit f496f8d to get more accurate results

@@               Coverage Diff                @@
##           branch-22.08   #11288      +/-   ##
================================================
+ Coverage         86.34%   86.40%   +0.06%     
================================================
  Files               144      143       -1     
  Lines             22826    22753      -73     
================================================
- Hits              19708    19659      -49     
+ Misses             3118     3094      -24     
Impacted Files Coverage Δ
python/cudf/cudf/_lib/__init__.py 100.00% <ø> (ø)
python/cudf/cudf/core/column/column.py 89.77% <100.00%> (+0.07%) ⬆️
python/cudf/cudf/io/parquet.py 90.93% <100.00%> (+0.09%) ⬆️
python/cudf/cudf/core/dataframe.py 93.57% <0.00%> (+0.04%) ⬆️
python/cudf/cudf/core/column/string.py 88.80% <0.00%> (+0.12%) ⬆️
python/cudf/cudf/core/groupby/groupby.py 91.02% <0.00%> (+0.21%) ⬆️
python/cudf/cudf/core/column/numerical.py 96.19% <0.00%> (+0.29%) ⬆️
python/cudf/cudf/core/tools/datetimes.py 84.49% <0.00%> (+0.30%) ⬆️
python/cudf/cudf/core/column/lists.py 91.70% <0.00%> (+0.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update edc5062...f496f8d. Read the comment docs.

@jbrennan333

Copy link
Copy Markdown
Contributor Author

The build error looks like it is unrelated to this change. I think it is related to #11025.

15:53:20 [13/229] Building CXX object cudf/_lib/CMakeFiles/binaryop.dir/binaryop.cxx.o
15:53:20 FAILED: cudf/_lib/CMakeFiles/binaryop.dir/binaryop.cxx.o 
15:53:20 $BUILD_PREFIX/bin/aarch64-conda-linux-gnu-c++ -DCUDF_VERSION=22.08.00 -DJITIFY_USE_CACHE -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -Dbinaryop_EXPORTS -I$PREFIX/include/python3.8 -I$PREFIX/include/rapids/libcudacxx -I$PREFIX/include/libcudf/Thrust -I$PREFIX/include/libcudf/Thrust/dependencies -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/cudf-22.08.00a -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe -isystem /opt/conda/envs/rapids/include -isystem /usr/local/cuda/include -O3 -DNDEBUG -fPIC -MD -MT cudf/_lib/CMakeFiles/binaryop.dir/binaryop.cxx.o -MF cudf/_lib/CMakeFiles/binaryop.dir/binaryop.cxx.o.d -o cudf/_lib/CMakeFiles/binaryop.dir/binaryop.cxx.o -c $SRC_DIR/python/cudf/_skbuild/linux-aarch64-3.8/cmake-build/cudf/_lib/binaryop.cxx
15:53:20 $SRC_DIR/python/cudf/_skbuild/linux-aarch64-3.8/cmake-build/cudf/_lib/binaryop.cxx: In function 'int __pyx_pymod_exec_binaryop(PyObject*)':
15:53:20 $SRC_DIR/python/cudf/_skbuild/linux-aarch64-3.8/cmake-build/cudf/_lib/binaryop.cxx:23027:129: error: 'INT_POW' is not a member of 'cudf::binary_operator'
15:53:20 23027 |   __pyx_t_4 = __Pyx_PyInt_From_int32_t(((__pyx_t_4cudf_4_lib_8binaryop_underlying_type_t_binary_operator)cudf::binary_operator::INT_POW)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 60, __pyx_L1_error)
15:53:20       |                                                                                                                                 ^~~~~~~

@jbrennan333

Copy link
Copy Markdown
Contributor Author

rerun tests

@jbrennan333
jbrennan333 marked this pull request as ready for review July 19, 2022 14:06
@jbrennan333
jbrennan333 requested a review from a team as a code owner July 19, 2022 14:06
@jbrennan333
jbrennan333 requested review from devavret and trxcllnt July 19, 2022 14:06

@devavret devavret left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just needs a test

@jbrennan333

Copy link
Copy Markdown
Contributor Author

@devavret I have added a test and verified it fails without this fix and passes with it.

One issue with the current test is that it assumes ZSTD compression is supported for ORC.
All of the checks for ZSTD support are in nvcomp_adapter.cpp and they are not currently exposed.
How do you recommend I check for ZSTD support in the test?

Currently, it will fail if you build with a version of nvcomp that does not support ZSTD. Maybe that is acceptable for a test?

I tried it by compiling with nvcomp-2.2, and it failed with this:

/home/jimb/dev/rapids/cudf/cpp/tests/io/orc_test.cpp:1121: Failure
Failed
statement:cudf_io::read_orc(in_opts)
reason: cuDF failure at: /home/jimb/dev/rapids/cudf/cpp/src/io/comp/nvcomp_adapter.cpp:163: nvCOMP 2.3 or newer is required for Zstandard compression

@jbrennan333

Copy link
Copy Markdown
Contributor Author

rerun tests

1 similar comment
@jbrennan333

Copy link
Copy Markdown
Contributor Author

rerun tests

@devavret

Copy link
Copy Markdown
Contributor

Seems like we want the NVCOMP_HAS_ZSTD macro or a function that can return a bool in a header. I'd like @vuule's opinion on this.
If we had one of those, we could GTEST_SKIP() the test.

@jbrennan333

Copy link
Copy Markdown
Contributor Author

Another alternative is to replicate this code from nvcomp_adapter.cpp in orc_test.cpp:

#define NVCOMP_ZSTD_HEADER <nvcomp/zstd.h>
#if __has_include(NVCOMP_ZSTD_HEADER)
#include NVCOMP_ZSTD_HEADER
#define NVCOMP_HAS_ZSTD 1
#else
#define NVCOMP_HAS_ZSTD 0
#endif

Let me know what you guys prefer.
Note that the build failures appear to be unrelated to my change. I'm going to hold off rerunning tests until we resolve how we want to handle this.

@jbrennan333
jbrennan333 requested a review from vuule July 21, 2022 14:34
@jbrennan333

Copy link
Copy Markdown
Contributor Author

rerun tests

@vuule vuule left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few suggestions.

Comment thread cpp/src/io/orc/orc_gpu.hpp Outdated
Comment thread cpp/src/io/orc/reader_impl.cu Outdated
Comment thread cpp/tests/io/orc_test.cpp
@vuule

vuule commented Jul 21, 2022

Copy link
Copy Markdown
Contributor

Another alternative is to replicate this code from nvcomp_adapter.cpp in orc_test.cpp:

#define NVCOMP_ZSTD_HEADER <nvcomp/zstd.h>
#if __has_include(NVCOMP_ZSTD_HEADER)
#include NVCOMP_ZSTD_HEADER
#define NVCOMP_HAS_ZSTD 1
#else
#define NVCOMP_HAS_ZSTD 0
#endif

Let me know what you guys prefer. Note that the build failures appear to be unrelated to my change. I'm going to hold off rerunning tests until we resolve how we want to handle this.

I slightly prefer moving NVCOMP_HAS_ZSTD and NVCOMP_HAS_DEFLATE to nvcomp_adapter.hpp. Not perfect because no namespace, but it's not a practical concern IMO.
Longer term we should add a new exception type for unsupported compression; then the test can catch or check the result.

@vuule vuule left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed my mind about the macros. This looks good 👍

@jbrennan333

Copy link
Copy Markdown
Contributor Author

Thanks for the review @vuule! I was in the process of putting up a change where I just added the include check to orc_test.cpp while you were reviewing, so I didn't see this comment. I can definitely change it to move the defines if you prefer that.

@jbrennan333

Copy link
Copy Markdown
Contributor Author

I did it again - comments crossing. Thanks for the reviews @vuule and @devavret!

@vyasr vyasr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@vyasr

vyasr commented Jul 22, 2022

Copy link
Copy Markdown
Contributor

@gpucibot merge

@vyasr
vyasr dismissed devavret’s stale review July 22, 2022 16:56

Stale review

@vyasr

vyasr commented Jul 22, 2022

Copy link
Copy Markdown
Contributor

@gpucibot merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 - Needs Review Waiting for reviewer to review or respond bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants