Fix determinism of compiled modules (#3229)
* Fix determinism of compiled modules Currently wasmtime's compilation artifacts are not deterministic due to the usage of `HashMap` during serialization which has randomized order of its elements. This commit fixes that by switching to a sorted `BTreeMap` for various maps. A test is also added to ensure determinism. If in the future the performance of `BTreeMap` is not as good as `HashMap` for some of these cases we can implement a fancier `serialize_with`-style solution where we sort keys during serialization, but only during serialization and otherwise use a `HashMap`. * fix lightbeam
This commit is contained in:
@@ -9,7 +9,7 @@ use anyhow::Result;
|
||||
use cranelift_codegen::binemit;
|
||||
use cranelift_codegen::ir::{self, ExternalName};
|
||||
use std::any::Any;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
use wasmtime_environ::{
|
||||
BuiltinFunctionIndex, CompileError, Compiler, FlagValue, FunctionBodyData, FunctionInfo,
|
||||
Module, ModuleTranslation, PrimaryMap, TrapInformation, Tunables, TypeTables, VMOffsets,
|
||||
@@ -96,11 +96,11 @@ impl Compiler for Lightbeam {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn flags(&self) -> HashMap<String, FlagValue> {
|
||||
fn flags(&self) -> BTreeMap<String, FlagValue> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn isa_flags(&self) -> HashMap<String, FlagValue> {
|
||||
fn isa_flags(&self) -> BTreeMap<String, FlagValue> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user