Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove initialize and make finalize optional #71

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nhz2
Copy link
Member

@nhz2 nhz2 commented Sep 15, 2024

Fixes #70 by initializing on construction and finalizing in a finalizer.

Copy link

codecov bot commented Sep 15, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.64%. Comparing base (e7edfed) to head (fdb6ec9).

Files with missing lines Patch % Lines
src/compression.jl 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #71      +/-   ##
==========================================
- Coverage   61.55%   60.64%   -0.92%     
==========================================
  Files           5        5              
  Lines         372      371       -1     
==========================================
- Hits          229      225       -4     
- Misses        143      146       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nhz2

This comment was marked as resolved.

C_NULL,
)
ptr = ccall(
(:ZSTD_createCStream_advanced, libzstd),
Copy link
Member Author

Choose a reason for hiding this comment

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

ZSTD_createCStream_advanced is part of the experimental API though according to facebook/zstd#1734 these functions should not change much in the future.

I am using it because the regular ZSTD_createCStream leads to Julia not running the finalizer before being killed by OOM.

@nhz2 nhz2 marked this pull request as ready for review September 15, 2024 19:48
@nhz2 nhz2 requested a review from mkitti September 15, 2024 19:48
@mkitti
Copy link
Member

mkitti commented Sep 15, 2024

We should not rely on the GC to finalize external resources.

src/libzstd.jl Outdated Show resolved Hide resolved
@nhz2
Copy link
Member Author

nhz2 commented Sep 15, 2024

We should not rely on the GC to finalize external resources.

Should I try and support both explicit-free when we know the Codec cannot escape and automatic-free for more complex situations?

@nhz2 nhz2 marked this pull request as draft September 15, 2024 20:41
@nhz2 nhz2 changed the title Remove initialize and finalize Remove initialize and make finalize optional Sep 15, 2024
@nhz2 nhz2 marked this pull request as ready for review September 15, 2024 21:10
@@ -12,4 +12,4 @@ Zstd_jll = "3161d3a3-bdf6-5164-811a-617609db77b4"
[compat]
TranscodingStreams = "0.9, 0.10, 0.11"
Zstd_jll = "1.5.5"
julia = "1.3"
julia = "1.7"
Copy link
Member Author

Choose a reason for hiding this comment

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

atomics require 1.7

@nhz2 nhz2 mentioned this pull request Sep 15, 2024
@nhz2 nhz2 marked this pull request as draft September 16, 2024 16:11
@nhz2 nhz2 mentioned this pull request Sep 16, 2024
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.

Reusing a compressor
2 participants