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

lazy Value (remain a tape until it is mutated) #377

Merged
merged 8 commits into from
Aug 3, 2024
Merged

lazy Value (remain a tape until it is mutated) #377

merged 8 commits into from
Aug 3, 2024

Conversation

Licenser
Copy link
Member

@Licenser Licenser commented Jul 6, 2024

This draft adds a lazy value type that starts out as a tape and upgrades to a borrowed value when mutated.

use simd_json::{prelude::*, value::lazy::Value};

let mut json = br#"{"key": "value", "snot": 42}"#.to_vec();
let tape = simd_json::to_tape( json.as_mut_slice()).unwrap();
let value = tape.as_value();
let mut lazy = Value::from_tape(value);

assert_eq!(lazy.get("key").unwrap(), "value");

assert!(lazy.is_tape());
lazy.insert("new", 42);
assert!(lazy.is_value());
assert_eq!(lazy.get("key").unwrap(), "value");
assert_eq!(lazy.get("new").unwrap(), 42);

Signed-off-by: Heinz N. Gies <heinz@licenser.net>
Copy link

github-actions bot commented Jul 6, 2024

Benchmark for 423cab7

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 91.5±2.10µs 92.0±2.96µs +0.55%
canada/simd_json::to_tape_with_buffers 3.8±0.12ms 3.7±0.16ms -2.63%
citm_catalog/simd_json::to_tape_with_buffers 1120.3±80.61µs 1131.8±77.52µs +1.03%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.8±0.24µs 3.7±0.25µs -2.63%
github_events/simd_json::to_tape_with_buffers 40.3±1.17µs 40.4±1.19µs +0.25%
log/simd_json::to_tape_with_buffers 1564.6±92.20ns 1532.0±80.51ns -2.08%
twitter/simd_json::to_tape_with_buffers 441.7±29.29µs 439.0±26.26µs -0.61%

Signed-off-by: Heinz N. Gies <heinz@licenser.net>
Copy link

github-actions bot commented Jul 6, 2024

Benchmark for f2ef614

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 93.8±4.33µs 94.8±3.67µs +1.07%
canada/simd_json::to_tape_with_buffers 3.8±0.12ms 3.8±0.17ms 0.00%
citm_catalog/simd_json::to_tape_with_buffers 1148.2±84.65µs 1142.0±84.92µs -0.54%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 4.0±0.27µs 4.0±0.29µs 0.00%
github_events/simd_json::to_tape_with_buffers 41.4±1.41µs 41.4±1.62µs 0.00%
log/simd_json::to_tape_with_buffers 1630.7±115.35ns 1603.8±104.94ns -1.65%
twitter/simd_json::to_tape_with_buffers 448.2±29.56µs 444.2±31.00µs -0.89%

Signed-off-by: Heinz N. Gies <heinz@licenser.net>
Copy link

github-actions bot commented Jul 6, 2024

Benchmark for 0de96d0

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 90.9±3.87µs 91.1±2.73µs +0.22%
canada/simd_json::to_tape_with_buffers 3.7±0.14ms 3.7±0.16ms 0.00%
citm_catalog/simd_json::to_tape_with_buffers 1116.8±79.36µs 1114.5±80.08µs -0.21%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.7±0.27µs 3.7±0.23µs 0.00%
github_events/simd_json::to_tape_with_buffers 39.8±1.09µs 39.8±1.05µs 0.00%
log/simd_json::to_tape_with_buffers 1548.7±81.05ns 1551.2±80.80ns +0.16%
twitter/simd_json::to_tape_with_buffers 437.4±27.84µs 440.0±22.70µs +0.59%

Signed-off-by: Heinz N. Gies <heinz@licenser.net>
Copy link

github-actions bot commented Jul 7, 2024

Benchmark for aed921d

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 93.0±3.02µs 91.4±2.45µs -1.72%
canada/simd_json::to_tape_with_buffers 3.7±0.19ms 3.7±0.21ms 0.00%
citm_catalog/simd_json::to_tape_with_buffers 1133.2±82.30µs 1125.3±81.54µs -0.70%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.8±0.26µs 3.7±0.25µs -2.63%
github_events/simd_json::to_tape_with_buffers 40.8±1.49µs 40.7±1.33µs -0.25%
log/simd_json::to_tape_with_buffers 1587.2±94.52ns 1567.1±90.02ns -1.27%
twitter/simd_json::to_tape_with_buffers 441.2±27.67µs 438.0±27.61µs -0.73%

Signed-off-by: Heinz N. Gies <heinz@licenser.net>
@Licenser Licenser changed the title Draft of lazy Value lazy Value (remain a tape until it is mutated) Jul 7, 2024
Copy link

github-actions bot commented Jul 7, 2024

Benchmark for 0e9c9f3

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 90.5±1.92µs 90.9±2.59µs +0.44%
canada/simd_json::to_tape_with_buffers 3.7±0.13ms 3.7±0.14ms 0.00%
citm_catalog/simd_json::to_tape_with_buffers 1128.4±80.10µs 1129.1±81.09µs +0.06%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.7±0.21µs 3.7±0.22µs 0.00%
github_events/simd_json::to_tape_with_buffers 40.3±1.31µs 40.2±1.06µs -0.25%
log/simd_json::to_tape_with_buffers 1619.5±74.57ns 1558.4±66.29ns -3.77%
twitter/simd_json::to_tape_with_buffers 439.4±29.18µs 439.5±27.39µs +0.02%

Licenser added 2 commits July 9, 2024 20:31
Signed-off-by: Heinz N. Gies <heinz@licenser.net>
Signed-off-by: Heinz N. Gies <heinz@licenser.net>
@Licenser Licenser marked this pull request as ready for review August 3, 2024 12:21
Signed-off-by: Heinz N. Gies <heinz@licenser.net>
Copy link

github-actions bot commented Aug 3, 2024

Benchmark for b268639

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 90.4±2.48µs 90.0±2.83µs -0.44%
canada/simd_json::to_tape_with_buffers 3.7±0.12ms 3.7±0.15ms 0.00%
citm_catalog/simd_json::to_tape_with_buffers 1128.0±79.32µs 1119.8±76.57µs -0.73%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.7±0.21µs 3.6±0.20µs -2.70%
github_events/simd_json::to_tape_with_buffers 40.4±1.44µs 39.9±1.21µs -1.24%
log/simd_json::to_tape_with_buffers 1555.8±77.08ns 1518.2±81.87ns -2.42%
twitter/simd_json::to_tape_with_buffers 441.3±26.24µs 435.2±25.76µs -1.38%

Copy link

github-actions bot commented Aug 3, 2024

Benchmark for e01ddb1

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 92.4±3.64µs 91.6±2.42µs -0.87%
canada/simd_json::to_tape_with_buffers 3.8±0.12ms 3.7±0.17ms -2.63%
citm_catalog/simd_json::to_tape_with_buffers 1121.4±77.19µs 1122.4±78.58µs +0.09%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.8±0.23µs 3.8±0.27µs 0.00%
github_events/simd_json::to_tape_with_buffers 40.3±1.10µs 40.1±1.44µs -0.50%
log/simd_json::to_tape_with_buffers 1577.2±91.89ns 1567.8±93.71ns -0.60%
twitter/simd_json::to_tape_with_buffers 438.0±26.73µs 442.9±28.40µs +1.12%

@Licenser Licenser merged commit 19ddf6c into main Aug 3, 2024
23 of 26 checks passed
@Licenser Licenser deleted the lazy-value branch August 3, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant