Skip to content

Add BGZIP data_chunk_reader - #11652

Merged
rapids-bot[bot] merged 25 commits into
NVIDIA:branch-22.10from
upsj:feature/bgzip_reader
Sep 27, 2022
Merged

rapids-bot[bot] merged 25 commits into
NVIDIA:branch-22.10from
upsj:feature/bgzip_reader

Conversation

@upsj

@upsj upsj commented Sep 5, 2022 •

Copy link
Copy Markdown

Description

This adds a BGZIP data_chunk_reader usable with multibyte_split. The BGZIP format is a modified GZIP format that consists of multiple blocks of at most 65536 bytes compressed data describing at most 65536 bytes of uncompressed data. The data can be accessed with record offsets provided by Tabix index files, which contain so-called virtual offsets (unsigned 64 bit) of the following form

63                    16       0
+----------------------+-------+
|      block offset    | local |
+----------------------+-------+

The lower 16 bits describe the offset inside the uncompressed data belonging to a single compressed block, the upper 48 bits describe the offset of the compressed block inside the BGZIP file. The interface allows two modes: Reading a full compressed file, and reading between the locations described by two Tabix virtual offsets.

For a description of the BGZIP format, check section 4 in the SAM specification.

Closes #10466

TODO

  • Use events to avoid clobbering data that is still in use
  • stricter handling of local_begin (currently it may overflow into subsequent blocks)
  • add tests where local_begin and local_end are in the same chunk or even block
  • add cudf deflate fallback if nvComp doesn't support it this should not be necessary, since we only test with compatible nvcomp versions

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@upsj upsj added feature request New feature or request 2 - In Progress Currently a work in progress libcudf Affects libcudf (C++/CUDA) code. labels Sep 5, 2022
@upsj upsj added this to the Genomics read_text support milestone Sep 5, 2022
@upsj upsj self-assigned this Sep 5, 2022
@github-actions github-actions Bot added the CMake CMake build issue label Sep 5, 2022
@codecov

codecov Bot commented Sep 5, 2022 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (branch-22.10@972708a). Click here to learn what that means.
Patch has no changes to coverable lines.

❗ Current head 7a6e8a1 differs from pull request most recent head 5576bcc. Consider uploading reports for the commit 5576bcc to get more accurate results

Additional details and impacted files
@@               Coverage Diff               @@
##             branch-22.10   #11652   +/-   ##
===============================================
  Coverage                ?   87.52%           
===============================================
  Files                   ?      133           
  Lines                   ?    21794           
  Branches                ?        0           
===============================================
  Hits                    ?    19075           
  Misses                  ?     2719           
  Partials                ?        0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@upsj upsj added the non-breaking Non-breaking change label Sep 6, 2022
@upsj
upsj marked this pull request as ready for review September 6, 2022 13:55
@upsj
upsj requested review from a team as code owners September 6, 2022 13:55
@upsj
upsj requested review from PointKernel and harrism September 6, 2022 13:55
@upsj upsj added 3 - Ready for Review Ready for review by team and removed 2 - In Progress Currently a work in progress labels Sep 6, 2022
Comment thread cpp/src/io/comp/nvcomp_adapter.cpp Resolved

@isVoid isVoid 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.

cmake approval

@upsj upsj changed the title Add BGZIP reader Add BGZIP data_chunk_reader Sep 9, 2022

@PointKernel PointKernel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The first round of review

@upsj upsj added 4 - Needs Review Waiting for reviewer to review or respond and removed 3 - Ready for Review Ready for review by team labels Sep 19, 2022
@upsj
upsj force-pushed the feature/bgzip_reader branch from da1beda to a6af835 Compare September 19, 2022 09:56
@vuule

vuule commented Sep 22, 2022

Copy link
Copy Markdown
Contributor

High level design question (realized this after seeing the benchmark code): can we separate compression type from the data source (file, host, device)? With the current implementation we can only read BGZIP files from disk. maybe BGZIP decompressor should be another layer, rather than one of the data_chunked_reader implementations.

@upsj

upsj commented Sep 22, 2022

Copy link
Copy Markdown
Author

@vuule This would involve adding another abstraction that can read both small inputs on the host side (header, footer) as well as large inputs to a pinned buffer or the device side (deflate stream). Since this is a pretty domain-specific format (mostly related to genomics), I am not sure if it warrants the complexity of stacking it on top of another abstraction for host/device IO. You can already somewhat serve things from host memory by using a different std::istream, which I think is a quite useful abstraction for this case.

@upsj upsj added the DO NOT MERGE Hold off on merging; see PR for details label Sep 22, 2022
@upsj

upsj commented Sep 22, 2022

Copy link
Copy Markdown
Author

Tests are currently failing, might be related to rapidsai/rapids-cmake#272

@upsj upsj removed the DO NOT MERGE Hold off on merging; see PR for details label Sep 23, 2022

@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.

Another partial review, some minor suggestions.

@upsj
upsj requested review from PointKernel and vuule September 26, 2022 14:56
@upsj

upsj commented Sep 26, 2022

Copy link
Copy Markdown
Author

rerun tests

@PointKernel PointKernel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks!

@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.

An optional suggestion; overall 🔥

@upsj

upsj commented Sep 27, 2022

Copy link
Copy Markdown
Author

@gpucibot merge

@rapids-bot
rapids-bot Bot merged commit 831ef04 into NVIDIA:branch-22.10 Sep 27, 2022
@upsj upsj added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 4 - Needs Review Waiting for reviewer to review or respond labels Sep 27, 2022
@upsj upsj mentioned this pull request Sep 28, 2022
3 tasks done
rapids-bot Bot pushed a commit that referenced this pull request Sep 29, 2022
Compile warning was introduced in #11652 in `bgzip_data_chunk_source.cu`. The warning can be seen here https://gpuci.gpuopenanalytics.com/job/rapidsai/job/gpuci/job/cudf/job/prb/job/cudf-cpu-cuda-build/CUDA=11.5/12417/consoleFull (search for `177-D`)
```
/cudf/cpp/src/io/text/bgzip_data_chunk_source.cu(362): warning #177-D: variable "nvtx3_range__" was declared but never referenced
```
The `nvtx3_range__` is part of the `CUDF_FUNC_RANGE()` macro. The warning is incorrect and likely a compiler bug. The workaround in this PR is to add `[[maybe_unused]]` to the variable declaration.

I was not able to create a small reproducer for compile bug filing.

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Tobias Ribizel (https://github.com/upsj)
  - MithunR (https://github.com/mythrocks)

URL: #11798
rapids-bot Bot pushed a commit that referenced this pull request Oct 7, 2022
Adds the missing integration, plus some tests. I decided to extend the `read_text` interface rather than add a new one. For details on the bgzip format, see #11652

Authors:
  - Tobias Ribizel (https://github.com/upsj)

Approvers:
  - Ashwin Srinath (https://github.com/shwina)
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #11802
rapids-bot Bot pushed a commit that referenced this pull request Oct 10, 2022
This refactors #11652 to extract the BGZIP IO and adds another `source_type` to the `multibyte_split` benchmark, creating a compressed file using `zlib`.

A quick benchmark shows performance results around 2.5x slower than reading from a device buffer at around 1:5 compression ratio

### [0] Tesla T4

| source_type | delim_size | delim_percent |    size_approx    | byte_range_percent | Time  | Peak Memory Usage | Encoded file size |
|-------------|------------|---------------|-------------------|--------------------|------------|-------------------|-------------------|
|           bgzip |          1 |             1 | 2^30 = 1073741824 |                100 |  507.479 ms |         4.022 GiB |      1006.638 MiB |
|           file |          1 |             1 | 2^30 = 1073741824 |                100 |  339.860 ms |    3.947 GiB |      1006.638 MiB |
|           device |          1 |             1 | 2^30 = 1073741824 |                100 | 201.556 ms |       3.947 GiB |      1006.638 MiB |

Authors:
  - Tobias Ribizel (https://github.com/upsj)

Approvers:
  - Robert Maynard (https://github.com/robertmaynard)
  - Vukasin Milovanovic (https://github.com/vuule)
  - Bradley Dice (https://github.com/bdice)
  - Jordan Jacobelli (https://github.com/Ethyling)

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

Labels

5 - Ready to Merge Testing and reviews complete, ready to merge CMake CMake build issue feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA] Read Tabix indexed files in read_text

6 participants