Skip to content

Commit

Permalink
release: 0.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Jan 21, 2024
2 parents 5477c81 + e7253c2 commit b487032
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 105 deletions.
1 change: 0 additions & 1 deletion .righteous-sandbox.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"rust_update": true,
"just_init": "_init",
"just_list": true
}
18 changes: 9 additions & 9 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Project Dependencies
Package: channelz
Version: 0.8.1
Generated: 2023-12-28 19:11:09 UTC
Version: 0.8.2
Generated: 2024-01-21 07:03:07 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.6 | [Tom Kaitchuck](mailto:[email protected]) | Apache-2.0 or MIT |
| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.7 | [Tom Kaitchuck](mailto:[email protected]) | Apache-2.0 or MIT |
| [alloc-no-stdlib](https://github.com/dropbox/rust-alloc-no-stdlib) | 2.0.4 | [Daniel Reiter Horn](mailto:[email protected]) | BSD-3-Clause |
| [alloc-stdlib](https://github.com/dropbox/rust-alloc-no-stdlib) | 0.2.2 | [Daniel Reiter Horn](mailto:[email protected]) | BSD-3-Clause |
| [argyle](https://github.com/Blobfolio/argyle) | 0.6.8 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [argyle](https://github.com/Blobfolio/argyle) | 0.7.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [brotli](https://github.com/dropbox/rust-brotli) | 3.4.0 | [Daniel Reiter Horn](mailto:[email protected]) and The Brotli Authors | BSD-3-Clause or MIT |
| [brotli-decompressor](https://github.com/dropbox/rust-brotli-decompressor) | 2.5.1 | [Daniel Reiter Horn](mailto:[email protected]) and The Brotli Authors | BSD-3-Clause or MIT |
| [bytecount](https://github.com/llogiq/bytecount) | 0.6.7 | [Andre Bogus](mailto:[email protected]) and [Joshua Landau](mailto:[email protected]) | Apache-2.0 or MIT |
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [crossbeam-deque](https://github.com/crossbeam-rs/crossbeam) | 0.8.4 | | Apache-2.0 or MIT |
| [crossbeam-epoch](https://github.com/crossbeam-rs/crossbeam) | 0.9.17 | | Apache-2.0 or MIT |
| [crossbeam-utils](https://github.com/crossbeam-rs/crossbeam) | 0.8.18 | | Apache-2.0 or MIT |
| [crossbeam-deque](https://github.com/crossbeam-rs/crossbeam) | 0.8.5 | | Apache-2.0 or MIT |
| [crossbeam-epoch](https://github.com/crossbeam-rs/crossbeam) | 0.9.18 | | Apache-2.0 or MIT |
| [crossbeam-utils](https://github.com/crossbeam-rs/crossbeam) | 0.8.19 | | Apache-2.0 or MIT |
| [ctrlc](https://github.com/Detegr/rust-ctrlc.git) | 3.4.2 | [Antti Keränen](mailto:[email protected]) | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.6.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dowser](https://github.com/Blobfolio/dowser) | 0.8.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
Expand All @@ -24,8 +24,8 @@
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.11.8 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [libdeflate-sys](https://github.com/adamkewley/libdeflater) | 1.19.0 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
| [libdeflater](https://github.com/adamkewley/libdeflater) | 1.19.0 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
| [rayon](https://github.com/rayon-rs/rayon) | 1.8.0 | [Niko Matsakis](mailto:[email protected]) and [Josh Stone](mailto:[email protected]) | Apache-2.0 or MIT |
| [rayon-core](https://github.com/rayon-rs/rayon) | 1.12.0 | [Niko Matsakis](mailto:[email protected]) and [Josh Stone](mailto:[email protected]) | Apache-2.0 or MIT |
| [rayon](https://github.com/rayon-rs/rayon) | 1.8.1 | [Niko Matsakis](mailto:[email protected]) and [Josh Stone](mailto:[email protected]) | Apache-2.0 or MIT |
| [rayon-core](https://github.com/rayon-rs/rayon) | 1.12.1 | [Niko Matsakis](mailto:[email protected]) and [Josh Stone](mailto:[email protected]) | Apache-2.0 or MIT |
| [tempfile](https://github.com/Stebalien/tempfile) | 3.9.0 | [Steven Allen](mailto:[email protected]), The Rust Project Developers, [Ashley Mannix](mailto:[email protected]), and [Jason White](mailto:[email protected]) | Apache-2.0 or MIT |
| [term_size](https://github.com/kbknapp/term_size-rs.git) | 0.3.2 | [Kevin K.](mailto:[email protected]) and [Benjamin Sago](mailto:[email protected]) | Apache-2.0 or MIT |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | 0.1.11 | [kwantam](mailto:[email protected]) and [Manish Goregaokar](mailto:[email protected]) | Apache-2.0 or MIT |
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "channelz"
version = "0.8.1"
version = "0.8.2"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
Expand All @@ -12,7 +12,7 @@ publish = false

[package.metadata.deb]
maintainer = "Josh Stoik <[email protected]>"
copyright = "2022, Blobfolio, LLC <[email protected]>"
copyright = "2024, Blobfolio, LLC <[email protected]>"
license-file = ["./LICENSE", "0"]
revision = "1"
depends = "$auto"
Expand All @@ -26,7 +26,7 @@ appcache; atom; bmp; css; csv; doc(x); eot; geojson; htc; htm(l); ico; ics; js;\
json; jsonld; manifest; md; mjs; otf; pdf; rdf; rss; svg; ttf; txt; vcard; vcs;\n\
vtt; wasm; webmanifest; xhtm(l); xls(x); xml; xsl; y(a)ml"""
assets = [
["./target/x86_64-unknown-linux-gnu/release/channelz", "usr/bin/", "755"],
["./target/release/channelz", "usr/bin/", "755"],
["./release/completions/channelz.bash", "etc/bash_completion.d/", "644"],
["./release/man/channelz.1.gz", "usr/share/man/man1/", "644"],
]
Expand Down Expand Up @@ -68,7 +68,7 @@ description = "Print version information and exit."
short = "-l"
long = "--list"
label = "<FILE>"
description = "Read (absolute) file and/or directory paths from this text file, one entry per line."
description = "Read (absolute) file and/or directory paths to compress from this text file — or STDIN if '-' — one entry per line, instead of or in addition to specifying <PATH(S)> directly at the end of the command."
path = true

[[package.metadata.bashman.arguments]]
Expand All @@ -89,7 +89,7 @@ lines = [
dactyl = "0.6.*"

[dependencies]
argyle = "0.6.*"
argyle = "0.7.*"
ctrlc = "3.4.*"
dactyl = "0.6.*"
dowser = "0.8.*"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ These benchmarks were performed on a Intel® Core™ i7-10610U with four discret

See also: [CREDITS.md](CREDITS.md)

Copyright © 2023 [Blobfolio, LLC](https://blobfolio.com) &lt;[email protected]&gt;
Copyright © 2024 [Blobfolio, LLC](https://blobfolio.com) &lt;[email protected]&gt;

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.

Expand Down
43 changes: 4 additions & 39 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ pkg_id := "channelz"
pkg_name := "ChannelZ"

cargo_dir := "/tmp/" + pkg_id + "-cargo"
cargo_bin := cargo_dir + "/x86_64-unknown-linux-gnu/release/" + pkg_id
cargo_bin := cargo_dir + "/release/" + pkg_id
data_dir := "/tmp/bench-data"
doc_dir := justfile_directory() + "/doc"
release_dir := justfile_directory() + "/release"

export RUSTFLAGS := "-C target-cpu=x86-64-v3"



# Build Release!
Expand All @@ -32,7 +34,6 @@ release_dir := justfile_directory() + "/release"
cargo build \
--bin "{{ pkg_id }}" \
--release \
--target x86_64-unknown-linux-gnu \
--target-dir "{{ cargo_dir }}"


Expand All @@ -52,30 +53,6 @@ release_dir := justfile_directory() + "/release"
mv "{{ justfile_directory() }}/target" "{{ cargo_dir }}"


@build-pgo: clean
[ ! -d "/tmp/pgo-data" ] || rm -rf /tmp/pgo-data

RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" cargo build \
--bin "{{ pkg_id }}" \
--release \
--target x86_64-unknown-linux-gnu \
--target-dir "{{ cargo_dir }}"

just _bench-reset
"{{ cargo_bin }}" -p "{{ data_dir }}/test"
"{{ cargo_bin }}" -p --force "{{ justfile_directory() }}/Cargo.lock" "{{ justfile_directory() }}/Cargo.toml"
rm Cargo*.gz Cargo*.br

/usr/local/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata \
merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data

RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata -Cllvm-args=-pgo-warn-missing-function" cargo build \
--bin "{{ pkg_id }}" \
--release \
--target x86_64-unknown-linux-gnu \
--target-dir "{{ cargo_dir }}"


@clean:
# Most things go here.
[ ! -d "{{ cargo_dir }}" ] || rm -rf "{{ cargo_dir }}"
Expand All @@ -91,7 +68,6 @@ release_dir := justfile_directory() + "/release"
cargo clippy \
--release \
--all-features \
--target x86_64-unknown-linux-gnu \
--target-dir "{{ cargo_dir }}"


Expand All @@ -108,12 +84,11 @@ release_dir := justfile_directory() + "/release"
cargo doc \
--release \
--no-deps \
--target x86_64-unknown-linux-gnu \
--target-dir "{{ cargo_dir }}"

# Move the docs and clean up ownership.
[ ! -d "{{ doc_dir }}" ] || rm -rf "{{ doc_dir }}"
mv "{{ cargo_dir }}/x86_64-unknown-linux-gnu/doc" "{{ justfile_directory() }}"
mv "{{ cargo_dir }}/doc" "{{ justfile_directory() }}"
just _fix-chown "{{ doc_dir }}"

exit 0
Expand All @@ -124,7 +99,6 @@ release_dir := justfile_directory() + "/release"
cargo run \
--bin "{{ pkg_id }}" \
--release \
--target x86_64-unknown-linux-gnu \
--target-dir "{{ cargo_dir }}" \
-- {{ ARGS }}

Expand All @@ -133,11 +107,9 @@ release_dir := justfile_directory() + "/release"
@test:
clear
cargo test \
--target x86_64-unknown-linux-gnu \
--target-dir "{{ cargo_dir }}"
cargo test \
--release \
--target x86_64-unknown-linux-gnu \
--target-dir "{{ cargo_dir }}"


Expand Down Expand Up @@ -204,13 +176,6 @@ _bench-init:
cp -aR "{{ data_dir }}/raw" "{{ data_dir }}/test"
# Init dependencies.
@_init:
# We need beta until 1.51 is stable.
# env RUSTUP_PERMIT_COPY_RENAME=true rustup default beta
# env RUSTUP_PERMIT_COPY_RENAME=true rustup component add clippy
# Fix file/directory permissions.
@_fix-chmod PATH:
[ ! -e "{{ PATH }}" ] || find "{{ PATH }}" -type f -exec chmod 0644 {} +
Expand Down
6 changes: 3 additions & 3 deletions release/man/channelz.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "CHANNELZ" "1" "December 2023" "ChannelZ v0.8.1" "User Commands"
.TH "CHANNELZ" "1" "January 2024" "ChannelZ v0.8.2" "User Commands"
.SH NAME
ChannelZ \- Manual page for channelz v0.8.1.
ChannelZ \- Manual page for channelz v0.8.2.
.SH DESCRIPTION
Fast, multi\-threaded static Gzip/Brotli encoding tool for the CLI.
.SS USAGE:
Expand Down Expand Up @@ -28,7 +28,7 @@ Print version information and exit.
.SS OPTIONS:
.TP
\fB\-l\fR, \fB\-\-list\fR <FILE>
Read (absolute) file and/or directory paths from this text file, one entry per line.
Read (absolute) file and/or directory paths to compress from this text file — or STDIN if '\-' — one entry per line, instead of or in addition to specifying <PATH(S)> directly at the end of the command.
.SS <PATH(S)…>:
.TP
One or more file and/or directory paths to compress and/or (recursively) crawl.
Expand Down
90 changes: 47 additions & 43 deletions src/enc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
# ChannelZ: Encoding
*/

use brotli::enc::{
BrotliCompress,
backward_references::BrotliEncoderParams,
};
use libdeflater::{
CompressionLvl,
Compressor,
};
use std::{
io::Cursor,
path::Path,
path::{
Path,
PathBuf,
},
};


Expand All @@ -26,27 +37,30 @@ pub(super) fn encode(src: &Path) -> Option<(u64, u64, u64)> {
let len = raw.len();

#[cfg(target_pointer_width = "128")]
if 0 == len || len > 18_446_744_073_709_551_615 { return None; }
if 0 == len || len > u128::from(u64::MAX) { return None; }

#[cfg(not(target_pointer_width = "128"))]
if len == 0 { return None; }

// Do Gzip first because it will likely be bigger than Brotli, saving us
// the trouble of allocating additional buffer space down the road.
// A shared buffer for our encoded copies.
let mut buf: Vec<u8> = Vec::new();
let mut src = src.to_path_buf(); // Own it for later.

// The output path.
let gz_dst = {
let mut tmp = src.clone();
tmp.as_mut_os_string().push(".gz");
tmp
};
let len_gz = encode_gzip(&gz_dst, &raw, &mut buf).unwrap_or(len);

// Change the output path, then do Brotli.
src.as_mut_os_string().push(".br");
let len_br = encode_brotli(&src, &raw, &mut buf).unwrap_or(len);
// Start with gzip since it will likely be larger, saving us the trouble
// of having to increase the buffer size a second time.
let dst_gz = join_ext(src, ".gz");
let len_gz = encode_gzip(&dst_gz, &raw, &mut buf)
.unwrap_or_else(|| {
remove_if(&dst_gz);
len
});

// Now brotli!
let dst_br = join_ext(src, ".br");
let len_br = encode_brotli(&dst_br, &raw, &mut buf)
.unwrap_or_else(|| {
remove_if(&dst_br);
len
});

// Done!
Some((len as u64, len_br as u64, len_gz as u64))
Expand All @@ -57,49 +71,39 @@ pub(super) fn encode(src: &Path) -> Option<(u64, u64, u64)> {
/// This will attempt to encode `raw` using Brotli, writing the result to disk
/// if it is smaller than the original.
fn encode_brotli(path: &Path, raw: &[u8], buf: &mut Vec<u8>) -> Option<usize> {
use brotli::enc::{
BrotliCompress,
backward_references::BrotliEncoderParams,
};

buf.truncate(0);
let config = BrotliEncoderParams::default();
let size = BrotliCompress(&mut Cursor::new(raw), buf, &config).ok()?;
if size != 0 && size < raw.len() {
if write_atomic::write_file(path, &buf[..size]).is_ok() {
return Some(size);
}
remove_if(path);
let len = BrotliCompress(&mut Cursor::new(raw), buf, &config).ok()?;
if len != 0 && len < raw.len() && write_atomic::write_file(path, &buf[..len]).is_ok() {
Some(len)
}

None
else { None }
}

/// # Encode Gzip.
///
/// This will attempt to encode `raw` using Gzip, writing the result to disk
/// if it is smaller than the original.
fn encode_gzip(path: &Path, raw: &[u8], buf: &mut Vec<u8>) -> Option<usize> {
use libdeflater::{
CompressionLvl,
Compressor,
};

// Set up the buffer/writer.
let old_len = raw.len();
let mut writer = Compressor::new(CompressionLvl::best());
buf.resize(writer.gzip_compress_bound(old_len), 0);
buf.resize(writer.gzip_compress_bound(raw.len()), 0);

// Encode!
if let Ok(len) = writer.gzip_compress(raw, buf) {
if 0 < len && len < old_len && write_atomic::write_file(path, &buf[..len]).is_ok() {
return Some(len);
}
let len = writer.gzip_compress(raw, buf).ok()?;
if len != 0 && len < raw.len() && write_atomic::write_file(path, &buf[..len]).is_ok() {
Some(len)
}
else { None }
}

// Clean up.
remove_if(path);
None
/// # Push Extension.
///
/// Create a new path by appending .gz/.br to it.
fn join_ext(src: &Path, ext: &str) -> PathBuf {
let mut dst = src.to_path_buf();
dst.as_mut_os_string().push(ext);
dst
}

/// # Remove If It Exists.
Expand Down
10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ fn helper() {
`-( / -=`\ |
.==`=( -= = _/ /`--.
(M==M=M==M=M==M==M==M==M)
\=N=N==N=N==N=N==N=NN=/ ", "\x1b[38;5;199mChannelZ\x1b[0;38;5;69m v", env!("CARGO_PKG_VERSION"), "\x1b[0m", r"
\=N=N==N=N==N=N==N=NN=/ ", "\x1b[38;5;199mChannelZ\x1b[0;38;5;69m v", env!("CARGO_PKG_VERSION"), "\x1b[0m", r#"
\M==M=M==M=M==M===M=/ Fast, recursive, multi-threaded
\N=N==N=N==N=NN=N=/ static Brotli and Gzip encoding.
\M==M==M=M==M==M/
Expand All @@ -226,8 +226,10 @@ FLAGS:
-V, --version Print version information and exit.
OPTIONS:
-l, --list <FILE> Read (absolute) file and/or directory paths from this
text file, one entry per line.
-l, --list <FILE> Read (absolute) file and/or directory paths to compress
from this text file — or STDIN if "-" — one entry per
line, instead of or in addition to specifying <PATH(S)>
directly at the end of the command.
ARGS:
<PATH(S)>... One or more file and/or directory paths to compress
Expand All @@ -240,7 +242,7 @@ Note: static copies will only be generated for files with these extensions:
appcache; atom; bmp; css; csv; doc(x); eot; geojson; htc; htm(l); ico; ics;
js; json; jsonld; manifest; md; mjs; otf; pdf; rdf; rss; svg; ttf; txt;
vcard; vcs; vtt; wasm; webmanifest; xhtm(l); xls(x); xml; xsl; y(a)ml
"
"#
));
}

Expand Down

0 comments on commit b487032

Please sign in to comment.