Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cbor4ii = { version = "=1.0.0", features = [
], optional = true }
ciborium = { version = "=0.2.2", optional = true }
columnar = { version = "=0.11", optional = true }
compactly = { version = "=0.1.6", optional = true }
databuf = { version = "=0.5.0", optional = true }
dlhn = { version = "=0.1.7", optional = true }
flatbuffers = { version = "=25.12.19", optional = true }
Expand Down Expand Up @@ -118,6 +119,7 @@ default-encoding-set = [
"cbor4ii",
"ciborium",
"columnar",
"compactly",
"databuf",
"dlhn",
"flatbuffers",
Expand Down
14 changes: 14 additions & 0 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use rust_serialization_benchmark::bench_cbor4ii;
use rust_serialization_benchmark::bench_ciborium;
#[cfg(feature = "columnar")]
use rust_serialization_benchmark::bench_columnar;
#[cfg(feature = "compactly")]
use rust_serialization_benchmark::bench_compactly;
#[cfg(feature = "databuf")]
use rust_serialization_benchmark::bench_databuf;
#[cfg(feature = "dlhn")]
Expand Down Expand Up @@ -139,6 +141,9 @@ fn bench_log(c: &mut Criterion) {
#[cfg(feature = "columnar")]
bench_columnar::bench(BENCH, c, &data);

#[cfg(feature = "compactly")]
bench_compactly::bench(BENCH, c, &data);

#[cfg(feature = "databuf")]
bench_databuf::bench_borrowable(BENCH, c, &data);

Expand Down Expand Up @@ -365,6 +370,9 @@ fn bench_mesh(c: &mut Criterion) {
#[cfg(feature = "columnar")]
bench_columnar::bench(BENCH, c, &data);

#[cfg(feature = "compactly")]
bench_compactly::bench(BENCH, c, &data);

#[cfg(feature = "databuf")]
bench_databuf::bench(BENCH, c, &data);

Expand Down Expand Up @@ -575,6 +583,9 @@ fn bench_minecraft_savedata(c: &mut Criterion) {
#[cfg(feature = "columnar")]
bench_columnar::bench(BENCH, c, &data);

#[cfg(feature = "compactly")]
bench_compactly::bench(BENCH, c, &data);

#[cfg(feature = "databuf")]
bench_databuf::bench_borrowable(BENCH, c, &data);

Expand Down Expand Up @@ -795,6 +806,9 @@ fn bench_mk48(c: &mut Criterion) {
#[cfg(feature = "columnar")]
bench_columnar::bench(BENCH, c, &data);

#[cfg(feature = "compactly")]
bench_compactly::bench(BENCH, c, &data);

#[cfg(feature = "databuf")]
bench_databuf::bench(BENCH, c, &data);

Expand Down
29 changes: 29 additions & 0 deletions src/bench_compactly.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use compactly::Encode;
use criterion::{black_box, Criterion};

pub fn bench<T>(name: &'static str, c: &mut Criterion, data: &T)
where
T: Encode + PartialEq,
{
let mut group = c.benchmark_group(format!("{}/compactly", name));

group.bench_function("serialize", |b| {
b.iter(|| {
black_box(compactly::v2::Ans::encode(black_box(data)));
})
});

let encoded = compactly::v2::Ans::encode(data).to_vec();

group.bench_function("deserialize", |b| {
b.iter(|| {
black_box(compactly::v2::Ans::decode::<T>(black_box(&encoded)).unwrap());
})
});

crate::bench_size(name, "compactly", &encoded);

assert!(compactly::v2::Ans::decode::<T>(&encoded).unwrap() == *data);

group.finish();
}
5 changes: 5 additions & 0 deletions src/datasets/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::Generate;
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -236,6 +237,7 @@ impl From<log_protobuf::log::Address> for Address {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -269,10 +271,12 @@ pub struct Log {
#[cfg_attr(feature = "minicbor", b(1))]
pub identity: String,
#[cfg_attr(feature = "minicbor", b(2))]
#[cfg_attr(feature = "compactly", compactly(LowCardinality))]
pub userid: String,
#[cfg_attr(feature = "minicbor", b(3))]
pub date: String,
#[cfg_attr(feature = "minicbor", b(4))]
#[cfg_attr(feature = "compactly", compactly(LowCardinality))]
pub request: String,
#[cfg_attr(feature = "wiring", fixed)]
#[cfg_attr(feature = "minicbor", n(5))]
Expand Down Expand Up @@ -525,6 +529,7 @@ impl From<log_protobuf::log::Log> for Log {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down
3 changes: 3 additions & 0 deletions src/datasets/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::Generate;
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -175,6 +176,7 @@ impl From<mesh_protobuf::mesh::Vector3> for Vector3 {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -321,6 +323,7 @@ impl From<mesh_protobuf::mesh::Triangle> for Triangle {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down
14 changes: 14 additions & 0 deletions src/datasets/minecraft_savedata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use crate::{generate_vec, Generate};
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -205,6 +206,7 @@ impl From<rpb::minecraft_savedata::GameType> for GameType {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -241,6 +243,7 @@ pub struct Item {
#[cfg_attr(feature = "minicbor", n(1))]
pub slot: u8,
#[cfg_attr(feature = "minicbor", b(2))]
#[cfg_attr(feature = "compactly", compactly(LowCardinality))]
pub id: String,
}

Expand Down Expand Up @@ -406,6 +409,7 @@ impl From<rpb::minecraft_savedata::Item> for Item {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -578,6 +582,7 @@ impl From<rpb::minecraft_savedata::Abilities> for Abilities {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -607,6 +612,7 @@ impl From<rpb::minecraft_savedata::Abilities> for Abilities {
)]
pub struct Entity {
#[cfg_attr(feature = "minicbor", b(0))]
#[cfg_attr(feature = "compactly", compactly(LowCardinality))]
pub id: String,
#[cfg_attr(feature = "wiring", fixed(11))]
#[cfg_attr(feature = "minicbor", n(1))]
Expand All @@ -633,6 +639,7 @@ pub struct Entity {
#[cfg_attr(feature = "minicbor", n(11))]
pub uuid: [u32; 4],
#[cfg_attr(feature = "minicbor", n(12))]
#[cfg_attr(feature = "compactly", compactly(LowCardinality))]
pub custom_name: Option<String>,
#[cfg_attr(feature = "wiring", fixed)]
#[cfg_attr(feature = "minicbor", n(13))]
Expand Down Expand Up @@ -1048,6 +1055,7 @@ impl From<rpb::minecraft_savedata::Entity> for Entity {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -1078,9 +1086,11 @@ impl From<rpb::minecraft_savedata::Entity> for Entity {
pub struct RecipeBook {
#[cfg_attr(feature = "bilrost", bilrost(encoding(packed)))]
#[cfg_attr(feature = "minicbor", n(0))]
#[cfg_attr(feature = "compactly", compactly(Values<LowCardinality>))]
pub recipes: Vec<String>,
#[cfg_attr(feature = "bilrost", bilrost(encoding(packed)))]
#[cfg_attr(feature = "minicbor", n(1))]
#[cfg_attr(feature = "compactly", compactly(Values<LowCardinality>))]
pub to_be_displayed: Vec<String>,
#[cfg_attr(feature = "wiring", fixed)]
#[cfg_attr(feature = "minicbor", n(2))]
Expand Down Expand Up @@ -1384,6 +1394,7 @@ impl From<rpb::minecraft_savedata::RecipeBook> for RecipeBook {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -1420,12 +1431,14 @@ pub struct Player {
#[cfg_attr(feature = "minicbor", n(2))]
pub score: i64,
#[cfg_attr(feature = "minicbor", b(3))]
#[cfg_attr(feature = "compactly", compactly(LowCardinality))]
pub dimension: String,
#[cfg_attr(feature = "minicbor", b(4))]
pub selected_item_slot: u32,
#[cfg_attr(feature = "minicbor", n(5))]
pub selected_item: Item,
#[cfg_attr(feature = "minicbor", b(6))]
#[cfg_attr(feature = "compactly", compactly(LowCardinality))]
pub spawn_dimension: Option<String>,
#[cfg_attr(feature = "wiring", fixed(3))]
#[cfg_attr(feature = "minicbor", n(7))]
Expand Down Expand Up @@ -2087,6 +2100,7 @@ impl From<rpb::minecraft_savedata::Player> for Player {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down
7 changes: 7 additions & 0 deletions src/datasets/mk48/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use crate::{generate_vec, Generate};
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -351,6 +352,7 @@ fn generate_velocity(rng: &mut impl Rng) -> i16 {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -520,6 +522,7 @@ impl From<rpb::mk48::Transform> for Transform {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -652,6 +655,7 @@ impl From<rpb::mk48::Guidance> for Guidance {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -922,6 +926,7 @@ impl From<rpb::mk48::Contact> for Contact {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -1094,6 +1099,7 @@ impl From<rpb::mk48::TerrainUpdate> for TerrainUpdate {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down Expand Up @@ -1278,6 +1284,7 @@ impl From<rpb::mk48::Update> for Update {
derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)]
#[cfg_attr(feature = "columnar", derive(columnar::Columnar))]
#[cfg_attr(feature = "compactly", derive(compactly::Encode))]
#[cfg_attr(feature = "databuf", derive(databuf::Encode, databuf::Decode))]
#[cfg_attr(feature = "minicbor", derive(minicbor::Encode, minicbor::Decode))]
#[cfg_attr(feature = "msgpacker", derive(msgpacker::MsgPacker))]
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub mod bench_cbor4ii;
pub mod bench_ciborium;
#[cfg(feature = "columnar")]
pub mod bench_columnar;
#[cfg(feature = "compactly")]
pub mod bench_compactly;
#[cfg(feature = "databuf")]
pub mod bench_databuf;
#[cfg(feature = "dlhn")]
Expand Down