You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "DDtKey (via GitHub)" <gi...@apache.org> on 2024/03/01 16:13:55 UTC

[I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

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

   `AsyncArrowWriter` created with default `WriterProperties` will have a config of `DEFAULT_MAX_ROW_GROUP_SIZE = 1024 * 1024`
   
   It means that `ArrowWriter` won't flush until it's reached. 
   It leads to the incredible memory consumption, because it will cache up to `DEFAULT_MAX_ROW_GROUP_SIZE` (1048576 by default) and will ignore `buffer_capacity` config at all.
   
   Because the flushing condition of sync writer is:
   
   ```rust
   if in_progress.buffered_rows >= self.max_row_group_size {
       self.flush()?
   }
   ```
   
   **To Reproduce**
   Try to write many large rows to parquet with `AsyncArrowWriter`, you will see the memory consumption doesn't respect buffer size.
   
   In my case it was 10gb of data (900k records) coming in streaming way being written to parquet. It consumed 10gb of memory accordingly.
   
   **Expected behavior**
   Perfectly, it should respect buffer config. 
   I.e flush on either buffer size or max row group is reached.
   
   But even if it's expected for some reason, documentation should clearly highlight that.
   
   **Additional context**
   
   Btw, why default is `1024 * 1024`? Like it's byte unites


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973968524

   
   
   Interestingly that with decreased `max_row_group_size`  it also keeps increasing over time, but much much slower.
   <img width="1723" alt="image" src="https://github.com/apache/arrow-rs/assets/26835520/aed4bd49-08cf-48cb-a907-de4bb415b87b">
   
   And this one with default one (with enabled delays in between, to slow-down process)
   <img width="1723" alt="image" src="https://github.com/apache/arrow-rs/assets/26835520/0824728f-4ba9-4a79-bc5d-82735d3171f2">
   
   


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973626245

   > Btw, why default is 1024 * 1024? Like it's byte unites
   
   According to the docs, DEFAULT_MAX_ROW_GROUP_SIZE is number of rows, not bytes
   https://docs.rs/parquet/latest/parquet/file/properties/constant.DEFAULT_MAX_ROW_GROUP_SIZE.html
   https://docs.rs/parquet/latest/parquet/file/properties/struct.WriterProperties.html#method.max_row_group_size
   
   > Returns maximum number of rows in a row group.
   
   


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973975559

   Oh, right, yes - that makes sense


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1975325677

   FWIW https://github.com/apache/arrow-rs/issues/5458 tracks moving ObjectStore away from the somewhat problematic AsyncWrite abstraction


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973783845

   > According to the docs, DEFAULT_MAX_ROW_GROUP_SIZE is number of rows, not bytes
   
   Yeah, that's totally okay. I mean default value is weird, like it's bytes


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973979619

   Btw, can't we just explicitly enforce  `ArrowWriter` to "flush" and start new row group right from `AsyncArrowWriter` in `try_flush`? 🤔 


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973921969

   <img width="743" alt="image" src="https://github.com/apache/arrow-rs/assets/26835520/15540205-b3fa-4953-b247-760e2e327659">
   
   Here is simple MRE:
   https://gist.github.com/DDtKey/706930c78dbb296899c2ef1bbf86459a
   
   Pay attention to lines 30-33, it can change everything
   
   cc @tustvold @alamb 


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1974016289

   I agree it is potentially confusing, but I think the solution is to better document what buffer size is, and potentially add separate functionality to ArrowWriter / AsyncArrowWriter to constrain row group size.
   
   I am reticent to change this definition as the API breakage would be subtle and not immediately obvious, beyond larger files and worse query performance


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1998863360

   `label_issue.py` automatically added labels {'parquet'} from #5471


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973616037

   The structure of parquet forces us to buffer an entire row group before we can flush it. The async writer should do a better job of calling this out


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973960133

   Currently this is expected behaviour, row groups are only automatically "closed" based on row count. 
   
   I would suggest the following:
   
   * Document that AsyncArrowWriter's buffer size is not authoritative, and is bounded by the row group size
   * Add the ability to limit the maximum size of a row group before ArrowWriter starts a new row group, as it writes to separate memory regions per column it can actually enforce this, unlike the underlying SerializedFileWriter


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1974043209

   I think we should start by documenting the current state of play and go from there, I'll try to get something up later today.


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold closed issue #5450: AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size
URL: https://github.com/apache/arrow-rs/issues/5450


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973991904

   To be honest, my initial expectation was that I provide buffer-size (in `AsyncArrowWriter`) to ensure it flushes this amount of data.
   But in fact, it doesn't at all, only number of rows is important.
   
   Subjectively, it looks like we should `flush` underlying `ArrowWriter` (& start new row group) each time buffer is reached its capacity. 
   
   It's typical behavior at least for buffered writers, I don't expect it continue to keep so large amount of data.
   
   Moreover, we have `max_row_group_size`, not `mai_row_group_size` - so it's confusing currenly 


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973984388

   > Btw, can't we just explicitly enforce ArrowWriter to "flush" and start new row group right from AsyncArrowWriter in try_flush? 🤔
   
   Yes, that is an option that is available to users, and with https://github.com/apache/arrow-rs/pull/5251 the necessary meta information is exposed to the clients to make this judgement for themselves.
   
   However, as this has come up a few times, providing a conservative default limit of say 1GB is probably a sane modification, users can then lower this if they're happy to accept the trade-off of smaller row groups


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973782360

   > Something is wrong here, it should only consume up to 10Mb, perhaps you could use a memory profiler to identify where the usage is coming from
   
   Well, it definitely was an `ArrowWriter`. Once I decreased max row group usage became normal - but still it caches up to row number limit ignoring memory limit.


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1974023618

   > I am reticent to change this definition as the API breakage would be subtle and not immediately obvious, beyond larger files and worse query performance
   
   It's doable by creating a new writer type or methods with changed behavior and optionally deprecate old one.
   
   Or something like that: `AsynvArrowWriter::with_respected_buffer(..)`(could be better name, just example) and internally have a flag to switch the behavior.


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973974178

   > Interestingly that with decreased max_row_group_size it also keeps increasing over time, but much much slower.
   
   This is not unexpected, certain information such as indexes and statistics need to be retained until the footer is written


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


Re: [I] AsyncArrowWriter doesn't limit underlying ArrowWriter to respect buffer-size [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5450:
URL: https://github.com/apache/arrow-rs/issues/5450#issuecomment-1973654360

   Aah yes, I thought there was a mechanism to also limit the maximum size of row groups, but perhaps that is only for pages


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