Skip to content

Commit 7a1a1d6

Browse files
authored
feat: Better serialization and perf. (#133)
- Improve serialization of the DataClass type. It's now serialized as a simple string rather than a clumsy map. - USe serde_core instead of serde for improve build times. - Change the Classified trait's data_class method to return a &DataClass rather than a DataClass. This avoids the need to clone the DataClass in many places, improving performance (since DataClass has two Cow to clone). - Use FxHashMap to hold the redactors to get much better hash lookup perf. We don't need DoS protection since the hash keys are entirely internal.
1 parent 2acf771 commit 7a1a1d6

File tree

18 files changed

+382
-88
lines changed

18 files changed

+382
-88
lines changed

Cargo.lock

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ repository = "https://github.com/microsoft/oxidizer"
2525

2626
# local dependencies
2727
bytesbuf = { path = "crates/bytesbuf", default-features = false, version = "0.1.2" }
28-
data_privacy = { path = "crates/data_privacy", default-features = false, version = "0.9.0" }
29-
data_privacy_macros = { path = "crates/data_privacy_macros", default-features = false, version = "0.8.0" }
30-
data_privacy_macros_impl = { path = "crates/data_privacy_macros_impl", default-features = false, version = "0.8.0" }
28+
data_privacy = { path = "crates/data_privacy", default-features = false, version = "0.10.0" }
29+
data_privacy_macros = { path = "crates/data_privacy_macros", default-features = false, version = "0.9.0" }
30+
data_privacy_macros_impl = { path = "crates/data_privacy_macros_impl", default-features = false, version = "0.9.0" }
3131
fundle = { path = "crates/fundle", default-features = false, version = "0.3.0" }
3232
fundle_macros = { path = "crates/fundle_macros", default-features = false, version = "0.3.0" }
3333
fundle_macros_impl = { path = "crates/fundle_macros_impl", default-features = false, version = "0.3.0" }
@@ -68,8 +68,9 @@ quote = { version = "1.0.42", default-features = false }
6868
rand = { version = "0.9.2", default-features = false }
6969
rapidhash = { version = "4.1.1", default-features = false }
7070
regex = { version = "1.12.2", default-features = false }
71+
rustc-hash = { version = "2.1.0", default-features = false }
7172
serde = { version = "1.0.228", default-features = false }
72-
serde_core = { version = "1.0.224", default-features = false }
73+
serde_core = { version = "1.0.228", default-features = false }
7374
serde_json = { version = "1.0.145", default-features = false }
7475
smallvec = { version = "1.15.1", default-features = false }
7576
static_assertions = { version = "1.1.0", default-features = false }

crates/data_privacy/CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Changelog
22

3-
## [0.9.0] - 2025-12-16
3+
## [0.10.0] - 2025-12-16
4+
5+
- ✨ Features
6+
7+
- Better serialization and perf.
48

59
- 🧩 Miscellaneous
610

7-
- Make it to_redacted_string to avoid annoying downstream conflicts.
11+
- Make it to_redacted_string to avoid annoying downstream conflicts. ([#143](https://github.com/microsoft/oxidizer/pull/143))
812

913
## [0.8.0] - 2025-12-10
1014

crates/data_privacy/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[package]
55
name = "data_privacy"
66
description = "Data annotation and redaction system providing a robust way to manipulate sensitive information."
7-
version = "0.9.0"
7+
version = "0.10.0"
88
readme = "README.md"
99
keywords = ["oxidizer", "compliance", "privacy", "redaction", "scrubbing"]
1010
categories = ["data-structures"]
@@ -22,7 +22,6 @@ rustdoc-args = ["--cfg", "docsrs"]
2222

2323
[package.metadata.cargo_check_external_types]
2424
allowed_external_types = [
25-
"serde::*",
2625
"serde_core::de::*",
2726
"serde_core::ser::*",
2827
"data_privacy_macros::*",
@@ -31,21 +30,22 @@ allowed_external_types = [
3130

3231
[features]
3332
default = ["serde"]
34-
serde = ["dep:serde"]
35-
xxh3 = ["dep:xxhash-rust"]
3633
rapidhash = ["dep:rapidhash"]
34+
serde = ["dep:serde_core"]
35+
xxh3 = ["dep:xxhash-rust"]
3736

3837
[dependencies]
3938
data_privacy_macros.workspace = true
4039
rapidhash = { workspace = true, optional = true }
41-
serde = { workspace = true, optional = true, default-features = false, features = ["derive", "std"] }
40+
rustc-hash = { workspace = true, features = ["std"] }
41+
serde_core = { workspace = true, optional = true, default-features = false, features = ["std"] }
4242
xxhash-rust = { workspace = true, optional = true, features = ["xxh3"] }
4343

4444
[dev-dependencies]
4545
derive_more = { workspace = true, features = ["constructor", "from"] }
4646
mutants.workspace = true
4747
once_cell = { workspace = true, features = ["std"] }
48-
serde = { workspace = true, features = ["derive", "std"] }
48+
serde = { workspace = true, features = ["std", "derive"] }
4949
serde_json = { workspace = true, features = ["std"] }
5050

5151
[lints]

crates/data_privacy/src/classified.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ use crate::DataClass;
5151
/// }
5252
///
5353
/// impl Classified for ClassifiedPerson {
54-
/// fn data_class(&self) -> DataClass {
55-
/// DataClass::new("example_taxonomy", "classified_person")
54+
/// fn data_class(&self) -> &DataClass {
55+
/// static DATA_CLASS: DataClass = DataClass::new("example_taxonomy", "classified_person");
56+
/// &DATA_CLASS
5657
/// }
5758
/// }
5859
///
@@ -64,5 +65,5 @@ use crate::DataClass;
6465
pub trait Classified {
6566
/// Returns the data class of the classified data.
6667
#[must_use]
67-
fn data_class(&self) -> DataClass;
68+
fn data_class(&self) -> &DataClass;
6869
}

0 commit comments

Comments
 (0)