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

minor improve for compression dir #5755

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions crates/primitives/src/compression/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
mod receipt_dictionary;
mod transaction_dictionary;

pub use receipt_dictionary::RECEIPT_DICTIONARY;
pub use transaction_dictionary::TRANSACTION_DICTIONARY;

use std::{cell::RefCell, thread_local};
use zstd::bulk::{Compressor, Decompressor};

/// Compression/Decompression dictionary for `Receipt`.
pub static RECEIPT_DICTIONARY: [u8; 100000] = include!("./receipt_dictionary.in");
/// Compression/Decompression dictionary for `Transaction`.
pub static TRANSACTION_DICTIONARY: [u8; 100000] = include!("./transaction_dictionary.in");

// Reason for using static compressors is that dictionaries can be quite big, and zstd-rs
// recommends to use one context/compressor per thread. Thus the usage of `thread_local`.
thread_local! {
Expand All @@ -25,4 +24,4 @@ thread_local! {
/// Thread receipt decompressor.
pub static RECEIPT_DECOMPRESSOR: RefCell<Decompressor<'static>> = RefCell::new(Decompressor::with_dictionary(&RECEIPT_DICTIONARY)
.expect("Failed to initialize decompressor."));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// Compression/Decompression dictionary for `Receipt`.
pub static RECEIPT_DICTIONARY: [u8; 100000] = [
[
55, 164, 48, 236, 252, 66, 105, 97, 34, 16, 48, 92, 7, 241, 177, 245, 27, 152, 184, 38, 111, 9,
213, 108, 137, 172, 90, 25, 120, 100, 212, 93, 89, 5, 57, 190, 223, 171, 242, 231, 222, 91,
166, 131, 5, 32, 0, 6, 136, 193, 101, 2, 8, 76, 164, 28, 169, 7, 4, 128, 0, 131, 132, 3, 3,
Expand Down Expand Up @@ -3950,4 +3949,4 @@ pub static RECEIPT_DICTIONARY: [u8; 100000] = [
0, 0, 20, 82, 8, 0, 0, 20, 164, 16, 0, 0, 20, 246, 24, 0, 0, 28, 1, 72, 32, 0, 0, 20, 82, 8, 0,
0, 20, 164, 16, 0, 0, 20, 246, 24, 0, 0, 28, 1, 72, 32, 0, 0, 28, 1, 154, 40, 0, 0, 28, 1, 236,
48, 0, 0, 28, 2, 62, 56, 0, 0, 28, 2,
];
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// Compression/Decompression dictionary for `Transaction`.
pub static TRANSACTION_DICTIONARY: [u8; 100000] = [
[
55, 164, 48, 236, 228, 195, 180, 19, 23, 16, 24, 221, 1, 51, 63, 225, 72, 97, 70, 2, 203, 116,
147, 152, 246, 253, 59, 253, 143, 14, 45, 83, 179, 4, 72, 0, 6, 133, 66, 193, 128, 56, 32, 20,
160, 203, 245, 0, 4, 192, 64, 134, 7, 10, 20, 10, 5, 4, 10, 3, 130, 130, 4, 3, 130, 4, 17, 7,
Expand Down Expand Up @@ -4539,4 +4538,4 @@ pub static TRANSACTION_DICTIONARY: [u8; 100000] = [
80, 85, 83, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
85, 83, 68, 74, 80, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 88, 65, 85, 85, 83, 68, 0, 0, 0,
];
]
Loading