lz4rip 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Cargo.lock +20 -20
- data/ext/lz4rip/Cargo.toml +2 -2
- data/ext/lz4rip/src/lib.rs +7 -6
- data/ext/lz4rip/src/rb.rs +20 -25
- data/lib/lz4rip/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 67a8b9bf2a0abb6a7630773720ae606dc1729be0aa56bdf4b851bf523beb2d4f
|
|
4
|
+
data.tar.gz: 55a3745ca8e940589a6659d68c41f2af81d82b3edf6a6ca22d9f496d4c331fd4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b56524f4b6c057d47a31f5e4e411c7e155a70d4027cb9de42b54e61d2d97c10a6aa94f31473d4ec73afa282eaef786e10497d9d1b73e6db5142a322eec1c4820
|
|
7
|
+
data.tar.gz: 5e5a4186fcfbcfdfc254bc33768f63469868182ed898716ea7e6161f69ec744f9c285306810b982178e52d2d713b674a5fdd9b60f373607c29dceaf100b51961
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.2.2] - 2026-11-26
|
|
6
|
+
|
|
7
|
+
- Update the `lz4rip` crate dependency to 0.12.7. Block decompression caps
|
|
8
|
+
its output buffer at what the input can decode to, so a large
|
|
9
|
+
`decompressed_size:` no longer allocates that much up front. Dictionary
|
|
10
|
+
compression output differs from 0.2.1.
|
|
11
|
+
- `DictTrainer#train` no longer raises `RuntimeError` (native Rust panic)
|
|
12
|
+
for a `max_dict_size` of 4 to 31.
|
|
13
|
+
- Let several threads compress or decompress one mutable String at once.
|
|
14
|
+
Calls that release the GVL now borrow a frozen copy of the input instead
|
|
15
|
+
of locking it, so they no longer raise `RuntimeError` when another call
|
|
16
|
+
holds the same String, and the caller may modify it meanwhile.
|
|
17
|
+
- Check the LZ4 frame magic before releasing the GVL.
|
|
18
|
+
|
|
5
19
|
## [0.2.1] - 2026-10-11
|
|
6
20
|
|
|
7
21
|
- Update the `lz4rip` crate dependency to 0.11.10 and `rb-sys` to 0.9.130.
|
data/Cargo.lock
CHANGED
|
@@ -90,9 +90,9 @@ checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
|
|
|
90
90
|
|
|
91
91
|
[[package]]
|
|
92
92
|
name = "libc"
|
|
93
|
-
version = "0.2.
|
|
93
|
+
version = "0.2.191"
|
|
94
94
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
95
|
-
checksum = "
|
|
95
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
96
96
|
|
|
97
97
|
[[package]]
|
|
98
98
|
name = "libloading"
|
|
@@ -106,17 +106,17 @@ dependencies = [
|
|
|
106
106
|
|
|
107
107
|
[[package]]
|
|
108
108
|
name = "lz4rip"
|
|
109
|
-
version = "0.2.
|
|
109
|
+
version = "0.2.2"
|
|
110
110
|
dependencies = [
|
|
111
|
-
"lz4rip 0.
|
|
111
|
+
"lz4rip 0.12.7",
|
|
112
112
|
"rb-sys",
|
|
113
113
|
]
|
|
114
114
|
|
|
115
115
|
[[package]]
|
|
116
116
|
name = "lz4rip"
|
|
117
|
-
version = "0.
|
|
117
|
+
version = "0.12.7"
|
|
118
118
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
119
|
-
checksum = "
|
|
119
|
+
checksum = "ba714cda4452679bec0dd3910f3979a3a803d51dbb490c237aa15dcb95432dd1"
|
|
120
120
|
dependencies = [
|
|
121
121
|
"lz4rip-core",
|
|
122
122
|
"lz4rip-decode",
|
|
@@ -126,24 +126,24 @@ dependencies = [
|
|
|
126
126
|
|
|
127
127
|
[[package]]
|
|
128
128
|
name = "lz4rip-core"
|
|
129
|
-
version = "0.
|
|
129
|
+
version = "0.6.2"
|
|
130
130
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
131
|
-
checksum = "
|
|
131
|
+
checksum = "052afa89a977207a207f3e074b1518b0fb5767dab3274464fd1ee5fc7699a30b"
|
|
132
132
|
|
|
133
133
|
[[package]]
|
|
134
134
|
name = "lz4rip-decode"
|
|
135
|
-
version = "0.
|
|
135
|
+
version = "0.11.2"
|
|
136
136
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
137
|
-
checksum = "
|
|
137
|
+
checksum = "1b0652316d9108ecf75802ddc55f4174a836f2c93c3ab3b06ed009e211d9f9c7"
|
|
138
138
|
dependencies = [
|
|
139
139
|
"lz4rip-core",
|
|
140
140
|
]
|
|
141
141
|
|
|
142
142
|
[[package]]
|
|
143
143
|
name = "lz4rip-encode"
|
|
144
|
-
version = "0.10.
|
|
144
|
+
version = "0.10.17"
|
|
145
145
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
146
|
-
checksum = "
|
|
146
|
+
checksum = "ff6d1b221814509df4735ac32847dc169e6a8b0375683e6c5bc8139c4dd620c2"
|
|
147
147
|
dependencies = [
|
|
148
148
|
"lz4rip-core",
|
|
149
149
|
]
|
|
@@ -214,9 +214,9 @@ dependencies = [
|
|
|
214
214
|
|
|
215
215
|
[[package]]
|
|
216
216
|
name = "regex"
|
|
217
|
-
version = "1.13.
|
|
217
|
+
version = "1.13.2"
|
|
218
218
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
219
|
-
checksum = "
|
|
219
|
+
checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857"
|
|
220
220
|
dependencies = [
|
|
221
221
|
"aho-corasick",
|
|
222
222
|
"memchr",
|
|
@@ -226,9 +226,9 @@ dependencies = [
|
|
|
226
226
|
|
|
227
227
|
[[package]]
|
|
228
228
|
name = "regex-automata"
|
|
229
|
-
version = "0.4.
|
|
229
|
+
version = "0.4.19"
|
|
230
230
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
231
|
-
checksum = "
|
|
231
|
+
checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158"
|
|
232
232
|
dependencies = [
|
|
233
233
|
"aho-corasick",
|
|
234
234
|
"memchr",
|
|
@@ -237,9 +237,9 @@ dependencies = [
|
|
|
237
237
|
|
|
238
238
|
[[package]]
|
|
239
239
|
name = "regex-syntax"
|
|
240
|
-
version = "0.8.
|
|
240
|
+
version = "0.8.12"
|
|
241
241
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
242
|
-
checksum = "
|
|
242
|
+
checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
|
|
243
243
|
|
|
244
244
|
[[package]]
|
|
245
245
|
name = "rustc-hash"
|
|
@@ -278,9 +278,9 @@ checksum = "86a801b3cea342a06d468c8710662aa29e5e05e4f5c0d62f00bbb7f2ad7941c2"
|
|
|
278
278
|
|
|
279
279
|
[[package]]
|
|
280
280
|
name = "unicode-ident"
|
|
281
|
-
version = "1.0.
|
|
281
|
+
version = "1.0.27"
|
|
282
282
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
283
|
-
checksum = "
|
|
283
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
284
284
|
|
|
285
285
|
[[package]]
|
|
286
286
|
name = "windows-link"
|
data/ext/lz4rip/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "lz4rip"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.2"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
build = "build.rs"
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ name = "lz4rip"
|
|
|
9
9
|
crate-type = ["cdylib", "rlib"]
|
|
10
10
|
|
|
11
11
|
[dependencies]
|
|
12
|
-
lz4 = { version = "0.
|
|
12
|
+
lz4 = { version = "0.12.7", package = "lz4rip" }
|
|
13
13
|
rb-sys = "0.9.130"
|
|
14
14
|
|
|
15
15
|
[build-dependencies]
|
data/ext/lz4rip/src/lib.rs
CHANGED
|
@@ -51,7 +51,7 @@ where
|
|
|
51
51
|
F: FnOnce(&mut T, &[u8]) -> RbResult<R>,
|
|
52
52
|
{
|
|
53
53
|
if release_gvl {
|
|
54
|
-
input.
|
|
54
|
+
input.freeze_for_without_gvl(true)?;
|
|
55
55
|
return rb::maybe_without_gvl(true, || {
|
|
56
56
|
let mut guard = mutex
|
|
57
57
|
.lock()
|
|
@@ -64,7 +64,7 @@ where
|
|
|
64
64
|
Ok(mut guard) => func(&mut guard, input.as_slice()),
|
|
65
65
|
Err(TryLockError::WouldBlock) => {
|
|
66
66
|
// Even a small input needs protection when contention releases GVL.
|
|
67
|
-
input.
|
|
67
|
+
input.freeze_for_without_gvl(true)?;
|
|
68
68
|
rb::maybe_without_gvl(true, || {
|
|
69
69
|
let mut guard = mutex
|
|
70
70
|
.lock()
|
|
@@ -268,7 +268,7 @@ fn block_codec_compress_impl(rb_self: VALUE, rb_input: VALUE) -> RbResult<VALUE>
|
|
|
268
268
|
let rb_self = unsafe { block_codec_ref(rb_self)? };
|
|
269
269
|
let mut input = rb::input_bytes(rb_input)?;
|
|
270
270
|
let release_gvl = should_release_compress_gvl(input.len());
|
|
271
|
-
input.
|
|
271
|
+
input.freeze_for_without_gvl(release_gvl)?;
|
|
272
272
|
|
|
273
273
|
let out = match &rb_self.compressor {
|
|
274
274
|
None => rb::maybe_without_gvl(release_gvl, || block::compress(input.as_slice()))?,
|
|
@@ -366,7 +366,7 @@ fn frame_codec_compress_impl(rb_self: VALUE, rb_input: VALUE) -> RbResult<VALUE>
|
|
|
366
366
|
let rb_self = unsafe { frame_codec_ref(rb_self)? };
|
|
367
367
|
let mut input = rb::input_bytes(rb_input)?;
|
|
368
368
|
let release_gvl = should_release_compress_gvl(input.len());
|
|
369
|
-
input.
|
|
369
|
+
input.freeze_for_without_gvl(release_gvl)?;
|
|
370
370
|
|
|
371
371
|
let out = rb::maybe_without_gvl(release_gvl, || compress_frame(rb_self, input.as_slice()))?
|
|
372
372
|
.map_err(RubyErr::runtime)?;
|
|
@@ -403,8 +403,6 @@ fn frame_codec_decompress_impl(
|
|
|
403
403
|
let rb_self = unsafe { frame_codec_ref(rb_self)? };
|
|
404
404
|
let max_decompressed_size = rb::value_to_option_usize(max_decompressed_size)?;
|
|
405
405
|
let mut input = rb::input_bytes(rb_input)?;
|
|
406
|
-
let release_gvl = should_release_frame_decompress_gvl(input.len());
|
|
407
|
-
input.lock_for_without_gvl(release_gvl)?;
|
|
408
406
|
|
|
409
407
|
if input.len() < 4 || input.as_slice()[..4] != LZ4_FRAME_MAGIC {
|
|
410
408
|
return Err(RubyErr::new(
|
|
@@ -413,6 +411,9 @@ fn frame_codec_decompress_impl(
|
|
|
413
411
|
));
|
|
414
412
|
}
|
|
415
413
|
|
|
414
|
+
let release_gvl = should_release_frame_decompress_gvl(input.len());
|
|
415
|
+
input.freeze_for_without_gvl(release_gvl)?;
|
|
416
|
+
|
|
416
417
|
let out = rb::maybe_without_gvl(release_gvl, || {
|
|
417
418
|
decompress_frame(rb_self, input.as_slice(), max_decompressed_size)
|
|
418
419
|
})?
|
data/ext/lz4rip/src/rb.rs
CHANGED
|
@@ -6,13 +6,6 @@ use rb_sys::{rb_data_type_t, VALUE};
|
|
|
6
6
|
|
|
7
7
|
pub type RbResult<T = VALUE> = Result<T, RubyErr>;
|
|
8
8
|
|
|
9
|
-
#[cfg(ruby_engine = "mri")]
|
|
10
|
-
unsafe extern "C" {
|
|
11
|
-
fn rb_obj_frozen_p(obj: VALUE) -> VALUE;
|
|
12
|
-
fn rb_str_locktmp(str: VALUE) -> VALUE;
|
|
13
|
-
fn rb_str_unlocktmp(str: VALUE) -> VALUE;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
#[cfg(ruby_engine = "mri")]
|
|
17
10
|
type RbWithoutGvlFunc = unsafe extern "C" fn(*mut c_void) -> *mut c_void;
|
|
18
11
|
#[cfg(ruby_engine = "mri")]
|
|
@@ -185,7 +178,7 @@ where
|
|
|
185
178
|
output: None,
|
|
186
179
|
};
|
|
187
180
|
// Ruby checks interrupts before and after the callback. Protect the call
|
|
188
|
-
// so an exception still drops native output and
|
|
181
|
+
// so an exception still drops native output and borrowed strings.
|
|
189
182
|
protect_unit(|| unsafe {
|
|
190
183
|
rb_thread_call_without_gvl(
|
|
191
184
|
Some(without_gvl_trampoline::<F, R>),
|
|
@@ -277,19 +270,19 @@ pub fn value_to_bytes(value: VALUE) -> RbResult<Vec<u8>> {
|
|
|
277
270
|
bytes_from_string_value(string).map(|bytes| bytes.to_vec())
|
|
278
271
|
}
|
|
279
272
|
|
|
280
|
-
pub fn
|
|
273
|
+
pub fn value_to_option_usize(value: VALUE) -> RbResult<Option<usize>> {
|
|
281
274
|
if value == qnil() {
|
|
282
275
|
Ok(None)
|
|
283
276
|
} else {
|
|
284
|
-
|
|
277
|
+
value_to_usize(value).map(Some)
|
|
285
278
|
}
|
|
286
279
|
}
|
|
287
280
|
|
|
288
|
-
pub fn
|
|
281
|
+
pub fn value_to_option_bytes(value: VALUE) -> RbResult<Option<Vec<u8>>> {
|
|
289
282
|
if value == qnil() {
|
|
290
283
|
Ok(None)
|
|
291
284
|
} else {
|
|
292
|
-
|
|
285
|
+
value_to_bytes(value).map(Some)
|
|
293
286
|
}
|
|
294
287
|
}
|
|
295
288
|
|
|
@@ -314,14 +307,14 @@ impl InputBytes {
|
|
|
314
307
|
self.as_slice().len()
|
|
315
308
|
}
|
|
316
309
|
|
|
317
|
-
pub fn
|
|
310
|
+
pub fn freeze_for_without_gvl(&mut self, release_gvl: bool) -> RbResult<()> {
|
|
318
311
|
if !release_gvl {
|
|
319
312
|
return Ok(());
|
|
320
313
|
}
|
|
321
314
|
|
|
322
315
|
match self {
|
|
323
316
|
#[cfg(ruby_engine = "mri")]
|
|
324
|
-
Self::Borrowed(bytes) => bytes.
|
|
317
|
+
Self::Borrowed(bytes) => bytes.freeze(),
|
|
325
318
|
#[cfg(not(ruby_engine = "mri"))]
|
|
326
319
|
Self::Owned(_) => Ok(()),
|
|
327
320
|
}
|
|
@@ -333,7 +326,7 @@ pub struct BorrowedStringBytes {
|
|
|
333
326
|
value: VALUE,
|
|
334
327
|
ptr: *const u8,
|
|
335
328
|
len: usize,
|
|
336
|
-
|
|
329
|
+
frozen: bool,
|
|
337
330
|
}
|
|
338
331
|
|
|
339
332
|
#[cfg(ruby_engine = "mri")]
|
|
@@ -345,7 +338,7 @@ impl BorrowedStringBytes {
|
|
|
345
338
|
value: string,
|
|
346
339
|
ptr: bytes.as_ptr(),
|
|
347
340
|
len: bytes.len(),
|
|
348
|
-
|
|
341
|
+
frozen: false,
|
|
349
342
|
})
|
|
350
343
|
}
|
|
351
344
|
|
|
@@ -357,13 +350,20 @@ impl BorrowedStringBytes {
|
|
|
357
350
|
}
|
|
358
351
|
}
|
|
359
352
|
|
|
360
|
-
|
|
361
|
-
|
|
353
|
+
// Borrow from a frozen copy before releasing the GVL. The copy shares the
|
|
354
|
+
// heap buffer, and a write to the caller's String copies that buffer first,
|
|
355
|
+
// so other threads may mutate or borrow the caller's String meanwhile.
|
|
356
|
+
fn freeze(&mut self) -> RbResult<()> {
|
|
357
|
+
if self.frozen {
|
|
362
358
|
return Ok(());
|
|
363
359
|
}
|
|
364
360
|
|
|
365
|
-
protect_value(|| unsafe {
|
|
366
|
-
|
|
361
|
+
let frozen = protect_value(|| unsafe { rb_sys::rb_str_new_frozen(self.value) })?;
|
|
362
|
+
let bytes = bytes_from_string_value(frozen)?;
|
|
363
|
+
self.value = frozen;
|
|
364
|
+
self.ptr = bytes.as_ptr();
|
|
365
|
+
self.len = bytes.len();
|
|
366
|
+
self.frozen = true;
|
|
367
367
|
Ok(())
|
|
368
368
|
}
|
|
369
369
|
}
|
|
@@ -371,11 +371,6 @@ impl BorrowedStringBytes {
|
|
|
371
371
|
#[cfg(ruby_engine = "mri")]
|
|
372
372
|
impl Drop for BorrowedStringBytes {
|
|
373
373
|
fn drop(&mut self) {
|
|
374
|
-
if self.locked {
|
|
375
|
-
unsafe {
|
|
376
|
-
rb_str_unlocktmp(self.value);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
374
|
let _ = rb_sys::rb_gc_guard!(self.value);
|
|
380
375
|
}
|
|
381
376
|
}
|
data/lib/lz4rip/version.rb
CHANGED