-
Notifications
You must be signed in to change notification settings - Fork 867
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
Replace lz4 with lz4_flex Allowing Compilation for WASM #4884
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a6e1df9
Use lz4_flex
tustvold 3cf9888
Fix features
tustvold 2681f31
Install clang for zlib
tustvold ff438a5
Update arrow-ipc
tustvold 9e139cc
Fix CI
tustvold 0fc9486
Use LZ4F
tustvold f6dbb41
Support LZ4F fallback
tustvold 710c47b
Restore support for LZ4F compressed CSV
tustvold 0b10493
Clippy
tustvold b61383f
Fix features
tustvold 3f2214e
Add benchmark
tustvold c1dd28e
Additional system dependencies
tustvold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use criterion::*; | ||
use parquet::basic::{BrotliLevel, Compression, GzipLevel, ZstdLevel}; | ||
use parquet::compression::create_codec; | ||
use rand::distributions::Alphanumeric; | ||
use rand::prelude::*; | ||
|
||
fn do_bench(c: &mut Criterion, name: &str, uncompressed: &[u8]) { | ||
let codecs = [ | ||
Compression::BROTLI(BrotliLevel::default()), | ||
Compression::GZIP(GzipLevel::default()), | ||
Compression::LZ4, | ||
Compression::LZ4_RAW, | ||
Compression::SNAPPY, | ||
Compression::GZIP(GzipLevel::default()), | ||
Compression::ZSTD(ZstdLevel::default()), | ||
]; | ||
|
||
for compression in codecs { | ||
let mut codec = create_codec(compression, &Default::default()) | ||
.unwrap() | ||
.unwrap(); | ||
|
||
c.bench_function(&format!("compress {compression} - {name}"), |b| { | ||
b.iter(|| { | ||
let mut out = Vec::new(); | ||
codec.compress(uncompressed, &mut out).unwrap(); | ||
out | ||
}); | ||
}); | ||
|
||
let mut compressed = Vec::new(); | ||
codec.compress(uncompressed, &mut compressed).unwrap(); | ||
println!( | ||
"{compression} compressed {} bytes of {name} to {} bytes", | ||
uncompressed.len(), | ||
compressed.len() | ||
); | ||
|
||
c.bench_function(&format!("decompress {compression} - {name}"), |b| { | ||
b.iter(|| { | ||
let mut out = Vec::new(); | ||
codec | ||
.decompress( | ||
black_box(&compressed), | ||
&mut out, | ||
Some(uncompressed.len()), | ||
) | ||
.unwrap(); | ||
out | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let mut rng = StdRng::seed_from_u64(42); | ||
let rng = &mut rng; | ||
const DATA_SIZE: usize = 1024 * 1024; | ||
|
||
let uncompressed: Vec<_> = rng.sample_iter(&Alphanumeric).take(DATA_SIZE).collect(); | ||
do_bench(c, "alphanumeric", &uncompressed); | ||
|
||
// Create a collection of 64 words | ||
let words: Vec<Vec<_>> = (0..64) | ||
.map(|_| { | ||
let len = rng.gen_range(1..12); | ||
rng.sample_iter(&Alphanumeric).take(len).collect() | ||
}) | ||
.collect(); | ||
|
||
// Build data by concatenating these words randomly together | ||
let mut uncompressed = Vec::with_capacity(DATA_SIZE); | ||
while uncompressed.len() < DATA_SIZE { | ||
let word = &words[rng.gen_range(0..words.len())]; | ||
uncompressed | ||
.extend_from_slice(&word[..word.len().min(DATA_SIZE - uncompressed.len())]) | ||
} | ||
assert_eq!(uncompressed.len(), DATA_SIZE); | ||
|
||
do_bench(c, "words", &uncompressed); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will decode lz4 data encoded without any framing, which is so niche that I struggle to conceive of people relying on this functionality. Further this is a utility CLI tool, and so I'm not too concerned about this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree -- We can update the CSV tool if eeded