Skip to content

Commit c89684e

Browse files
committed
Remove rr-validate feature given minimal performance improvements
1 parent 2e4b712 commit c89684e

File tree

16 files changed

+79
-109
lines changed

16 files changed

+79
-109
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ pulley = ["wasmtime-cli-flags/pulley"]
526526
stack-switching = ["wasmtime/stack-switching", "wasmtime-cli-flags/stack-switching"]
527527
rr = ["wasmtime/rr", "wasmtime-cli-flags/rr"]
528528
rr-component = ["rr", "wasmtime/rr-component"]
529-
rr-validate = ["rr", "wasmtime/rr-validate", "wasmtime-cli-flags/rr-validate"]
530529

531530
# CLI subcommands for the `wasmtime` executable. See `wasmtime $cmd --help`
532531
# for more information on each subcommand.

crates/cli-flags/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ memory-protection-keys = ["wasmtime/memory-protection-keys"]
4141
pulley = ["wasmtime/pulley"]
4242
stack-switching = ["wasmtime/stack-switching"]
4343
rr = ["wasmtime/rr"]
44-
rr-validate = ["wasmtime/rr-validate"]

crates/cli-flags/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,11 +1022,6 @@ impl CommonOptions {
10221022
match_feature! {
10231023
["rr" : &record.path]
10241024
_path => {
1025-
match_feature! {
1026-
["rr-validate": record.validation_metadata]
1027-
_v => (),
1028-
_ => err,
1029-
}
10301025
config.rr(wasmtime::RRConfig::Recording);
10311026
},
10321027
_ => err,

crates/wasmtime/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,3 @@ rr-component = ["component-model", "rr"]
410410
# Enable support for the common base infrastructure of record/replay
411411
# By default, this supports core wasm `rr`. For components, enable `rr-component`
412412
rr = ["dep:embedded-io"]
413-
414-
# Enables record/replay with support for additional validation signatures/checks.
415-
rr-validate = ["rr"]
416-

crates/wasmtime/src/runtime/component/func/options.rs

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::rr::{ConstMemorySliceCell, MemorySliceCell};
1111
use crate::rr::{
1212
RREvent, RecordBuffer, ReplayError, Replayer, component_events::ReallocEntryEvent,
1313
};
14-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
14+
#[cfg(feature = "rr-component")]
1515
use crate::rr::{ResultEvent, Validate, component_events::ReallocReturnEvent};
1616
use crate::runtime::vm::component::{
1717
CallContexts, ComponentInstance, InstanceFlags, ResourceTable, ResourceTables,
@@ -403,7 +403,7 @@ impl<'a, T: 'static> LowerContext<'a, T> {
403403
new_size,
404404
})?;
405405
let result = self.realloc_inner(old, old_size, old_align, new_size);
406-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
406+
#[cfg(feature = "rr-component")]
407407
self.store.0.record_event_validation(|| {
408408
ReallocReturnEvent(ResultEvent::from_anyhow_result(&result))
409409
})?;
@@ -576,23 +576,19 @@ impl<'a, T: 'static> LowerContext<'a, T> {
576576
mut result_storage: Option<&mut [MaybeUninit<ValRaw>]>,
577577
phase: ReplayLoweringPhase,
578578
) -> Result<()> {
579-
// There is a lot of `rr-validate` feature gating here for optimal replay performance
580-
// and memory overhead in a non-validating scenario. If this proves to not produce a huge
581-
// overhead in practice, gating can be removed in the future in favor of readability
582579
if self.store.0.replay_buffer_mut().is_none() {
583580
return Ok(());
584581
}
585582
let mut complete = false;
586583
let mut lowering_error: Option<ReplayError> = None;
587584
// No nested expected; these depths should only be 1
588-
let mut _realloc_stack = Vec::<Result<usize>>::new();
585+
let mut realloc_stack = Vec::<Result<usize>>::new();
589586
// Lowering tracks is only for ordering entry/exit events
590-
let mut _lower_stack = Vec::<()>::new();
591-
let mut _lower_store_stack = Vec::<()>::new();
587+
let mut lower_stack = Vec::<()>::new();
588+
let mut lower_store_stack = Vec::<()>::new();
592589
while !complete {
593590
let buf = self.store.0.replay_buffer_mut().unwrap();
594591
let event = buf.next_event()?;
595-
#[cfg(feature = "rr-validate")]
596592
let run_validate = buf.settings().validate && buf.trace_settings().add_validation;
597593
match event {
598594
RREvent::HostFuncReturn(e) => {
@@ -624,27 +620,22 @@ impl<'a, T: 'static> LowerContext<'a, T> {
624620
complete = true;
625621
}
626622
RREvent::ComponentReallocEntry(e) => {
627-
let _result =
623+
let result =
628624
self.realloc_inner(e.old_addr, e.old_size, e.old_align, e.new_size);
629-
#[cfg(feature = "rr-validate")]
630625
if run_validate {
631-
_realloc_stack.push(_result);
626+
realloc_stack.push(result);
632627
}
633628
}
634629
// No return value to validate for lower/lower-store; store error and just check that entry happened before
635630
RREvent::ComponentLowerFlatReturn(e) => {
636-
#[cfg(feature = "rr-validate")]
637631
if run_validate {
638-
_lower_stack
639-
.pop()
640-
.ok_or(ReplayError::InvalidEventPosition)?;
632+
lower_stack.pop().ok_or(ReplayError::InvalidEventPosition)?;
641633
}
642634
lowering_error = e.0.ret().map_err(Into::into).err();
643635
}
644636
RREvent::ComponentLowerMemoryReturn(e) => {
645-
#[cfg(feature = "rr-validate")]
646637
if run_validate {
647-
_lower_store_stack
638+
lower_store_stack
648639
.pop()
649640
.ok_or(ReplayError::InvalidEventPosition)?;
650641
}
@@ -664,25 +655,21 @@ impl<'a, T: 'static> LowerContext<'a, T> {
664655
bail!("Cannot call into host during lowering")
665656
}
666657
// Unwrapping should never occur on valid executions since *Entry should be before *Return in trace
667-
RREvent::ComponentReallocReturn(_e) =>
668-
{
669-
#[cfg(feature = "rr-validate")]
658+
RREvent::ComponentReallocReturn(e) => {
670659
if run_validate {
671-
lowering_error = _e.0.validate(&_realloc_stack.pop().unwrap()).err()
660+
lowering_error = e.0.validate(&realloc_stack.pop().unwrap()).err()
672661
}
673662
}
674663
RREvent::ComponentLowerFlatEntry(_) => {
675664
// All we want here is ensuring Entry occurs before Return
676-
#[cfg(feature = "rr-validate")]
677665
if run_validate {
678-
_lower_stack.push(())
666+
lower_stack.push(())
679667
}
680668
}
681669
RREvent::ComponentLowerMemoryEntry(_) => {
682670
// All we want here is ensuring Entry occurs before Return
683-
#[cfg(feature = "rr-validate")]
684671
if run_validate {
685-
_lower_store_stack.push(())
672+
lower_store_stack.push(())
686673
}
687674
}
688675

crates/wasmtime/src/runtime/rr/core.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@ use wasmtime_environ::EntityIndex;
77
// Use component events internally even without feature flags enabled
88
// so that [`RREvent`] has a well-defined serialization format, but export
99
// it for other modules only when enabled
10-
#[cfg(all(feature = "rr-validate", feature = "rr-component"))]
11-
pub use events::RRFuncArgVals;
12-
#[cfg(any(feature = "rr-validate", feature = "rr-component"))]
1310
pub use events::Validate;
1411
#[cfg(feature = "rr-component")]
1512
pub use events::component_events;
16-
pub use events::{ResultEvent, core_events, marker_events};
17-
use events::{common_events, component_events as __component_events};
13+
use events::component_events as __component_events;
14+
pub use events::{RRFuncArgVals, ResultEvent, common_events, core_events, marker_events};
1815
pub use io::{IOError, RecordWriter, ReplayReader};
1916

2017
/// Settings for execution recording.
21-
#[cfg(feature = "rr")]
2218
#[derive(Debug, Clone, Serialize, Deserialize)]
2319
pub struct RecordSettings {
2420
/// Flag to include additional signatures for replay validation.
@@ -27,7 +23,6 @@ pub struct RecordSettings {
2723
pub event_window_size: usize,
2824
}
2925

30-
#[cfg(feature = "rr")]
3126
impl Default for RecordSettings {
3227
fn default() -> Self {
3328
Self {
@@ -38,7 +33,6 @@ impl Default for RecordSettings {
3833
}
3934

4035
/// Settings for execution replay.
41-
#[cfg(feature = "rr")]
4236
#[derive(Debug, Clone, Serialize, Deserialize)]
4337
pub struct ReplaySettings {
4438
/// Flag to include additional signatures for replay validation.
@@ -47,7 +41,6 @@ pub struct ReplaySettings {
4741
pub deser_buffer_size: usize,
4842
}
4943

50-
#[cfg(feature = "rr")]
5144
impl Default for ReplaySettings {
5245
fn default() -> Self {
5346
Self {
@@ -304,7 +297,6 @@ pub trait Recorder {
304297

305298
/// Record a event only when validation is requested
306299
#[inline]
307-
#[cfg(feature = "rr-validate")]
308300
fn record_event_validation<T, F>(&mut self, f: F) -> Result<()>
309301
where
310302
T: Into<RREvent>,
@@ -379,7 +371,6 @@ pub trait Replayer: Iterator<Item = Result<RREvent, ReplayError>> {
379371
/// In addition to errors in [`next_event_typed`](Replayer::next_event_typed),
380372
/// validation errors can be thrown
381373
#[inline]
382-
#[cfg(feature = "rr-validate")]
383374
fn next_event_validation<T, Y>(&mut self, expect: &Y) -> Result<(), ReplayError>
384375
where
385376
T: TryFrom<RREvent> + Validate<Y>,
@@ -568,11 +559,19 @@ impl Replayer for ReplayBuffer {
568559
}
569560

570561
#[inline]
562+
#[allow(
563+
unused,
564+
reason = "method only used for gated validation, but will be extended in the future"
565+
)]
571566
fn settings(&self) -> &ReplaySettings {
572567
&self.settings
573568
}
574569

575570
#[inline]
571+
#[allow(
572+
unused,
573+
reason = "method only used for gated validation, but will be extended in the future"
574+
)]
576575
fn trace_settings(&self) -> &RecordSettings {
577576
&self.trace_settings
578577
}

crates/wasmtime/src/runtime/rr/core/events.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#[cfg(any(feature = "rr-component", feature = "rr-validate"))]
21
use super::ReplayError;
32
use crate::rr::FlatBytes;
43
use crate::{AsContextMut, Val, prelude::*};
@@ -116,13 +115,11 @@ impl RRFuncArgVals {
116115
/// Trait signifying types that can be validated on replay
117116
///
118117
/// All `PartialEq` types are directly validatable with themselves.
119-
/// Note however that some [`Validate`] implementations are present even
120-
/// when feature `rr-validate` is disabled, when validation is needed
121-
/// for a faithful replay (e.g. [`component_events::InstantiationEvent`]).
118+
/// Note however that some [`Validate`] implementations are present and
119+
/// required for a faithful replay (e.g. [`component_events::InstantiationEvent`]).
122120
///
123121
/// In terms of usage, an event that implements `Validate` can call
124122
/// any RR validation methods on a `Store`
125-
#[cfg(any(feature = "rr-component", feature = "rr-validate"))]
126123
pub trait Validate<T: ?Sized> {
127124
/// Perform a validation of the event to ensure replay consistency
128125
fn validate(&self, expect: &T) -> Result<(), ReplayError>;
@@ -136,7 +133,6 @@ pub trait Validate<T: ?Sized> {
136133
}
137134
}
138135

139-
#[cfg(any(feature = "rr-component", feature = "rr-validate"))]
140136
impl<T> Validate<T> for T
141137
where
142138
T: PartialEq + fmt::Debug,

crates/wasmtime/src/runtime/rr/core/events/component_events.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
use super::*;
44
use crate::component::ComponentInstanceId;
55
use crate::vm::component::libcalls::ResourceDropRet;
6-
// Re-export common events from this module
7-
pub use common_events::*;
86
use wasmtime_environ::{
97
self,
108
component::{ExportIndex, InterfaceType},

crates/wasmtime/src/runtime/rr/core/events/core_events.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! Module comprising of core wasm events
22
use super::*;
33
use crate::{WasmFuncOrigin, store::InstanceId};
4-
// Re-export common events from this module
5-
pub use common_events::*;
64

75
/// A core Wasm instantiatation event
86
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Ord, PartialOrd)]

crates/wasmtime/src/runtime/rr/hooks/component_hooks.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ use crate::ValRaw;
22
#[cfg(feature = "component-model")]
33
use crate::component::func::LowerContext;
44
#[cfg(feature = "rr-component")]
5-
use crate::rr::ResultEvent;
6-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
5+
use crate::rr::common_events::WasmFuncReturnEvent;
6+
#[cfg(feature = "rr-component")]
77
use crate::rr::component_events::HostFuncEntryEvent;
88
#[cfg(feature = "rr-component")]
99
use crate::rr::component_events::{
10-
HostFuncReturnEvent, LowerFlatReturnEvent, LowerMemoryReturnEvent, WasmFuncEntryEvent,
10+
LowerFlatReturnEvent, LowerMemoryReturnEvent, WasmFuncEntryEvent,
1111
};
12-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
13-
use crate::rr::{RRFuncArgVals, component_events::WasmFuncReturnEvent};
12+
#[cfg(feature = "rr-component")]
13+
use crate::rr::{RRFuncArgVals, ResultEvent, common_events::HostFuncReturnEvent};
1414
use crate::store::StoreOpaque;
1515
use crate::{StoreContextMut, prelude::*};
1616
use alloc::sync::Arc;
@@ -52,7 +52,7 @@ where
5252
}
5353
})?;
5454
let result = wasm_call(store);
55-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
55+
#[cfg(feature = "rr-component")]
5656
{
5757
let flat_results = types.flat_types_storage(
5858
&InterfaceType::Tuple(types[type_idx].results),
@@ -70,7 +70,7 @@ where
7070
result?;
7171
return Ok(());
7272
}
73-
#[cfg(not(all(feature = "rr-component", feature = "rr-validate")))]
73+
#[cfg(not(feature = "rr-component"))]
7474
return result;
7575
}
7676

@@ -82,7 +82,7 @@ pub fn record_validate_host_func_entry(
8282
type_idx: &TypeFuncIndex,
8383
store: &mut StoreOpaque,
8484
) -> Result<()> {
85-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
85+
#[cfg(feature = "rr-component")]
8686
store.record_event_validation(|| create_host_func_entry_event(args, types, type_idx))?;
8787
let _ = (args, types, type_idx, store);
8888
Ok(())
@@ -96,7 +96,7 @@ pub fn replay_validate_host_func_entry(
9696
type_idx: &TypeFuncIndex,
9797
store: &mut StoreOpaque,
9898
) -> Result<()> {
99-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
99+
#[cfg(feature = "rr-component")]
100100
store.next_replay_event_validation::<HostFuncEntryEvent, _, _>(|| {
101101
create_host_func_entry_event(args, types, type_idx)
102102
})?;
@@ -134,7 +134,7 @@ pub fn record_lower_memory<F, T>(
134134
where
135135
F: FnOnce(&mut LowerContext<'_, T>, InterfaceType, usize) -> Result<()>,
136136
{
137-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
137+
#[cfg(feature = "rr-component")]
138138
{
139139
use crate::rr::component_events::LowerMemoryEntryEvent;
140140
cx.store
@@ -159,7 +159,7 @@ pub fn record_lower_flat<F, T>(
159159
where
160160
F: FnOnce(&mut LowerContext<'_, T>, InterfaceType) -> Result<()>,
161161
{
162-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
162+
#[cfg(feature = "rr-component")]
163163
{
164164
use crate::rr::component_events::LowerFlatEntryEvent;
165165
cx.store
@@ -174,7 +174,7 @@ where
174174
lower_result
175175
}
176176

177-
#[cfg(all(feature = "rr-component", feature = "rr-validate"))]
177+
#[cfg(feature = "rr-component")]
178178
#[inline(always)]
179179
fn create_host_func_entry_event(
180180
args: &mut [MaybeUninit<ValRaw>],

0 commit comments

Comments
 (0)