Skip to content

Conversation

@quinnj
Copy link
Member

@quinnj quinnj commented May 25, 2023

Fixes #396.

As noted in the originally reported issue, enabling debug logging when writing arrow data with compression can result in segfaults because the underlying CodecX package have debug logs, causing task switches/migration and thus making the pattern of using a single X_COMPRESSOR array indexed by Threads.threadid() unsafe since multiple threads may try using the same compressor at the same time.

We fix this by wrapping each compressor in a Lockable and ensuring the compress (or uncompress) operation holds the lock for the duration of the operation. We also:

  • Add a decompressor per thread to avoid recreating them over and over during reading
  • Lazily initialize compressors/decompressors in a way that is 1.9+ safe and only creates the object when needed by a specific thread
  • Switch from WorkerUtilities -> ConcurrentUtilities (the package was renamed)

Successor to #397; I've added @svilupp as a co-author here since they started the original movement for the code to go in this direction.

Fixes #396.

As noted in the originally reported issue, enabling debug logging when
writing arrow data with compression can result in segfaults because the
underlying CodecX package have debug logs, causing task switches/migration
and thus making the pattern of using a single `X_COMPRESSOR` array indexed
by `Threads.threadid()` unsafe since multiple threads may try using the
same compressor at the same time.

We fix this by wrapping each compressor in a `Lockable` and ensuring the
`compress` (or `uncompress`) operation holds the lock for the duration of
the operation. We also:
* Add a decompressor per thread to avoid recreating them over and over during reading
* Lazily initialize compressors/decompressors in a way that is 1.9+ safe and only
creates the object when needed by a specific thread
* Switch from WorkerUtilities -> ConcurrentUtilities (the package was renamed)

Co-authored-by: J S <49557684+svilupp@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented May 25, 2023

Codecov Report

Merging #445 (8c59f17) into main (94f7e37) will increase coverage by 0.05%.
The diff coverage is 96.29%.

@@            Coverage Diff             @@
##             main     #445      +/-   ##
==========================================
+ Coverage   87.25%   87.31%   +0.05%     
==========================================
  Files          26       26              
  Lines        3210     3256      +46     
==========================================
+ Hits         2801     2843      +42     
- Misses        409      413       +4     
Impacted Files Coverage Δ
src/write.jl 97.24% <75.00%> (-0.35%) ⬇️
src/Arrow.jl 97.43% <97.22%> (-2.57%) ⬇️
src/append.jl 89.28% <100.00%> (-0.49%) ⬇️
src/arraytypes/arraytypes.jl 90.00% <100.00%> (+0.37%) ⬆️
src/table.jl 92.82% <100.00%> (-0.08%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@baumgold baumgold left a comment

Choose a reason for hiding this comment

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

LGTM

@quinnj quinnj merged commit 6fe4ec0 into main May 30, 2023
@quinnj quinnj deleted the jq-compress-locks branch May 30, 2023 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error/Segfault when writing many partitions

3 participants