Skip to content

Commit

Permalink
Merge branch 'master' into dynamic-reflection-pog
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekkonot committed Dec 17, 2024
2 parents 99171cb + 8e750dc commit d1eeac4
Show file tree
Hide file tree
Showing 86 changed files with 4,960 additions and 2,442 deletions.
6 changes: 3 additions & 3 deletions docs/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This document describes the Attribute binary format. In this format there is no
- [Vector2](#vector2)
- [Vector3](#vector3)
- [CFrame](#cframe)
- [EnumItem](#EnumItem)
- [EnumItem](#enumitem)
- [NumberSequence](#numbersequence)
- [ColorSequence](#colorsequence)
- [NumberRange](#numberrange)
Expand All @@ -27,7 +27,7 @@ This document describes the Attribute binary format. In this format there is no

## Document Conventions

This document assumes a basic understanding of Rust's convention for numeric types. For example:
This document assumes a basic understanding of Rust's convention for numeric types. For example:

- `u32` is an unsigned 32-bit integer
- `f32` is a 32-bit floating point
Expand Down Expand Up @@ -189,7 +189,7 @@ Demonstrating the axis-aligned rotation matrix case, a `CFrame` with the value `
### EnumItem
**Type ID `0x15`**

The `EnumItem` type is composed of two parts:
The `EnumItem` type is composed of two parts:

| Field Name | Format | Value |
|:-----------|:--------------------|:-------------------------------------------------------|
Expand Down
14 changes: 10 additions & 4 deletions patches/instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ Change:
DefaultValue:
Bool: true

# DefinesCapabilities is exposed as `Sandboxed` in Roblox Studio, so we want
# it as an alias.
DefinesCapabilities:
AliasFor: Sandboxed
Sandboxed:
Serialization:
Type: SerializesAs
As: DefinesCapabilities

# Attributes serialize as a BinaryString with a strange name, but we want to
# refer to them with a different name.
Attributes:
Expand All @@ -33,10 +42,7 @@ Change:
AttributesSerialize:
AliasFor: Attributes

className:
AliasFor: ClassName

Tags:
DataType:
Value: "Tags"
Scriptability: Custom
Scriptability: Custom
2 changes: 2 additions & 0 deletions patches/model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Change:
Scriptability: Custom
WorldPivotData:
Scriptability: Custom
DefaultValue:
OptionalCFrame: ~
4 changes: 4 additions & 0 deletions patches/object.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Change:
Object:
className:
AliasFor: ClassName
8 changes: 8 additions & 0 deletions rbx_binary/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# rbx_binary Changelog

## Unreleased
* Dramatically improved performance of serializer and deserializer by using `Ustr` to represent property and class names ([#462]).
* Added the ability to specify what type of compression to use for serializing. This takes the form of `Serializer::compression_type`. ([#446])
* Added support for ZSTD compressed files ([#446])
* Implicit lossy conversion of non-UTF-8 `Instance.Name` and `*Script.Source` properties when decoding. The previous behaviour was returning an error. ([#380])

[#462]: https://github.com/rojo-rbx/rbx-dom/pull/462
[#446]: https://github.com/rojo-rbx/rbx-dom/pull/446
[#380]: https://github.com/rojo-rbx/rbx-dom/pull/380

## 0.7.7 (2024-08-22)
* Updated rbx-dom dependencies
Expand Down
10 changes: 4 additions & 6 deletions rbx_binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,21 @@ rbx_dom_weak = { version = "2.9.0", path = "../rbx_dom_weak" }
rbx_reflection = { version = "4.7.0", path = "../rbx_reflection" }
rbx_reflection_database = { version = "0.2.12", path = "../rbx_reflection_database" }

ahash = "0.8.11"
log = "0.4.17"
lz4 = "1.23.3"
thiserror = "1.0.31"
serde = { version = "1.0.137", features = ["derive"], optional = true }
profiling = "1.0.6"
zstd = "0.13.2"

[dev-dependencies]
criterion = "0.3.5"
criterion = "0.5.1"
env_logger = "0.9.0"
heck = "0.4.0"
insta = { version = "1.14.1", features = ["yaml"] }
serde = { version = "1.0.137", features = ["derive"] }

[[bench]]
name = "deserializer"
harness = false

[[bench]]
name = "serializer"
name = "suite"
harness = false
39 changes: 39 additions & 0 deletions rbx_binary/benches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# `rbx_binary` Benchmark Suite

This directory contains a suite of benchmarks used to measure the performance of the `rbx_binary` serializer and deserializer.

### Adding a new benchmark

To add a new benchmark, first add the file you'd like to measure performance against to the `files` directory. Then, add a new benchmark function to `suite/main.rs`, like this:
```rust
pub fn my_benchmark(c: &mut Criterion) {
bench(
&mut c.benchmark_group("My Benchmark")
include_bytes!("../files/bench-file.rbxl"),
)
}
```
and also make sure to add your benchmark function to the `criterion_group!` macro invocation.

Benchmark groups provide a number of configuration options which are useful under different circumstances. See the [Criterion.rs benchmark configuration documentation](https://bheisler.github.io/criterion.rs/book/user_guide/advanced_configuration.html) for details.

### Running the benchmarks

To run all benchmarks, run the following command somewhere in the `rbx_binary` crate directory:
```bash
cargo bench
```

To run a specific benchmark, run the following command somewhere in the `rbx_binary` crate directory, subsituting `My Benchmark` with the name of the benchmark group:
```bash
cargo bench "My Benchmark"
```

To measure only serialization or deserialization, add `/Serialize` or `/Deserialize` to the end of the benchmark name, like this:
```bash
cargo bench "My Benchmark/Serialize"
```

Once the benchmark is complete, an HTML report will be generated at `rbx-dom/target/criterion/reports/index.html` that contains detailed statistics collected during the run. This file can be opened in a web browser.

For more information, see the [Criterion.rs documentation](https://bheisler.github.io/criterion.rs/book/).
44 changes: 0 additions & 44 deletions rbx_binary/benches/deserializer.rs

This file was deleted.

File renamed without changes.
Binary file added rbx_binary/benches/files/miners-haven.rbxl
Binary file not shown.
Binary file added rbx_binary/benches/files/parts-1000.rbxm
Binary file not shown.
31 changes: 0 additions & 31 deletions rbx_binary/benches/serializer.rs

This file was deleted.

52 changes: 52 additions & 0 deletions rbx_binary/benches/suite/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
mod util;

use crate::util::bench;
use criterion::{criterion_group, criterion_main, Criterion, SamplingMode};

pub fn folders_100(c: &mut Criterion) {
bench(
&mut c.benchmark_group("100 Folders"),
include_bytes!("../files/folders-100.rbxm"),
)
}

pub fn deep_folders_100(c: &mut Criterion) {
bench(
&mut c.benchmark_group("100 Deep Folders"),
include_bytes!("../files/deep-folders-100.rbxm"),
)
}

pub fn modulescripts_100_lines_100(c: &mut Criterion) {
bench(
&mut c.benchmark_group("100 100-line ModuleScripts"),
include_bytes!("../files/modulescripts-100-lines-100.rbxm"),
)
}

pub fn parts_1000(c: &mut Criterion) {
bench(
c.benchmark_group("1,000 Parts")
.sampling_mode(SamplingMode::Flat),
include_bytes!("../files/parts-1000.rbxm"),
)
}

pub fn miners_haven(c: &mut Criterion) {
bench(
c.benchmark_group("Miner's Haven")
.sampling_mode(SamplingMode::Flat),
include_bytes!("../files/miners-haven.rbxl"),
)
}

criterion_group!(
bench_suite,
folders_100,
deep_folders_100,
modulescripts_100_lines_100,
parts_1000,
miners_haven,
);

criterion_main!(bench_suite);
42 changes: 42 additions & 0 deletions rbx_binary/benches/suite/util.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use criterion::{measurement::Measurement, BatchSize, BenchmarkGroup, Throughput};

pub(crate) fn bench<T: Measurement>(group: &mut BenchmarkGroup<T>, bench_file: &'static [u8]) {
serialize_bench(group, bench_file);
deserialize_bench(group, bench_file);
}

fn serialize_bench<T: Measurement>(group: &mut BenchmarkGroup<T>, buffer: &[u8]) {
let tree = rbx_binary::from_reader(buffer).unwrap();
let root_ref = tree.root_ref();
let mut buffer = Vec::new();

rbx_binary::to_writer(&mut buffer, &tree, &[root_ref]).unwrap();
let buffer_len = buffer.len();
let batch_size = if buffer_len > 1024 {
BatchSize::LargeInput
} else {
BatchSize::SmallInput
};

group
.throughput(Throughput::Bytes(buffer_len as u64))
.bench_function("Serialize", |b| {
b.iter_batched(
|| Vec::with_capacity(buffer_len),
|mut buffer: Vec<u8>| {
rbx_binary::to_writer(&mut buffer, &tree, &[root_ref]).unwrap();
},
batch_size,
)
});
}

fn deserialize_bench<T: Measurement>(group: &mut BenchmarkGroup<T>, buffer: &[u8]) {
group
.throughput(Throughput::Bytes(buffer.len() as u64))
.bench_function("Deserialize", |bencher| {
bencher.iter(|| {
rbx_binary::from_reader(buffer).unwrap();
});
});
}
Loading

0 comments on commit d1eeac4

Please sign in to comment.