You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/12/13 02:10:20 UTC

[GitHub] [arrow-rs] iajoiner opened a new issue, #3338: Improve performance of the CSV reader

iajoiner opened a new issue, #3338:
URL: https://github.com/apache/arrow-rs/issues/3338

   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   <!--
   A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 
   (This section helps Arrow developers understand the context and *why* for this feature, in addition to  the *what*)
   -->
   
   **Describe the solution you'd like**
   <!--
   A clear and concise description of what you want to happen.
   -->
   
   **Describe alternatives you've considered**
   <!--
   A clear and concise description of any alternative solutions or features you've considered.
   -->
   
   **Additional context**
   <!--
   Add any other context or screenshots about the feature request here.
   -->
   


-- 
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.apache.org

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


[GitHub] [arrow-rs] tustvold commented on issue #3338: Improve performance of the CSV parser

Posted by GitBox <gi...@apache.org>.
tustvold commented on issue #3338:
URL: https://github.com/apache/arrow-rs/issues/3338#issuecomment-1356291819

   Interestingly switching to ByteRecord appears to make performance worse. This is not hugely surprising when UTF-8 validation is only 4% of the profile, with the majority spent in parsing logic or memory allocation
   
   ![image](https://user-images.githubusercontent.com/1781103/208247453-998666ec-f4fe-4c30-93ea-6c2091ed03b9.png)
   
   This does suggest switching to csv-core may yield significant returns, but would be a significantly more involved rework :thinking: 


-- 
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-rs] tustvold commented on issue #3338: Improve performance of the CSV parser

Posted by GitBox <gi...@apache.org>.
tustvold commented on issue #3338:
URL: https://github.com/apache/arrow-rs/issues/3338#issuecomment-1369607403

   Closing as I have done all I plan to on this, there may be further optimisations but I think we've got most of the low-hanging fruit


-- 
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-rs] tustvold closed issue #3338: Improve performance of the CSV parser

Posted by GitBox <gi...@apache.org>.
tustvold closed issue #3338: Improve performance of the CSV parser
URL: https://github.com/apache/arrow-rs/issues/3338


-- 
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-rs] tustvold commented on issue #3338: Improve performance of the CSV parser

Posted by GitBox <gi...@apache.org>.
tustvold commented on issue #3338:
URL: https://github.com/apache/arrow-rs/issues/3338#issuecomment-1348617807

   In general arrow-rs delegates responsibility for parallelism to downstream crates such as DataFusion. This keeps things simple and flexible, whilst also not introducing coupling to any particular threading approach. I think one could parallelise CsvExec, as we already have the plumbing to split byte streams on newline characters.
   
   > Could we do a binary search looking for CR characters until we have N equal sized chunks, then process each chunk in parallel
   
   It is a bit more complex as you need to account for escaping and quotes, see [LineDelimiter](https://github.com/apache/arrow-datafusion/blob/master/datafusion/core/src/physical_plan/file_format/delimited_stream.rs#L35)


-- 
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-rs] avantgardnerio commented on issue #3338: Improve performance of the CSV parser

Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on issue #3338:
URL: https://github.com/apache/arrow-rs/issues/3338#issuecomment-1348602048

   Disclaimer: I haven't looked at the code. Do we have any parallelism? Could we do a binary search looking for CR characters until we have N equal sized chunks, then process each chunk in parallel


-- 
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-rs] avantgardnerio commented on issue #3338: Improve performance of the CSV parser

Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on issue #3338:
URL: https://github.com/apache/arrow-rs/issues/3338#issuecomment-1348633429

   Wow, I had no idea that was possible, but: https://en.wikipedia.org/wiki/Comma-separated_values
   
   ```
   Fields with embedded line breaks must be quoted
   ```
   
   I learned something new today, ty!


-- 
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-rs] tustvold commented on issue #3338: Improve performance of the CSV parser

Posted by GitBox <gi...@apache.org>.
tustvold commented on issue #3338:
URL: https://github.com/apache/arrow-rs/issues/3338#issuecomment-1348053571

   Couple of areas that might be fruitful
   
   * The various arrays are parsed using `FromIterator`, this is normally suboptimal. It is almost always faster to construct the buffers manually, especially for UTF8 columns where a pre-pass can determine the buffer sizes first to avoid bump-allocating
   * Data is parsed as `StringRecord`, switching to `ByteRecord` may be faster, would open the door to supporting binary arrays #3292, and allows using the optimised UTF-8 validation logic #3168
   * Investigate using lexical-core to decode primitives, this was found to be faster in arrow-cast
   
   I hope to spend some time on this in the near future, as I think we could make this significantly faster


-- 
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-rs] Dandandan commented on issue #3338: Improve performance of the CSV parser

Posted by GitBox <gi...@apache.org>.
Dandandan commented on issue #3338:
URL: https://github.com/apache/arrow-rs/issues/3338#issuecomment-1348081054

   I did some optimization to the CSV parser in the past.
   
   An additional suggestion is to avoid materializing to `StringRecord` or `ByteRecord` as those allocate (which the code tries to reuse across batches). This should be possible by using the `csv-core` crate instead of the higher level `csv`.
   


-- 
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-rs] tustvold commented on issue #3338: Improve performance of the CSV parser

Posted by GitBox <gi...@apache.org>.
tustvold commented on issue #3338:
URL: https://github.com/apache/arrow-rs/issues/3338#issuecomment-1354406285

   I plan to take a stab at this this weekend


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