Skip to content

Commit

Permalink
Merge #2666
Browse files Browse the repository at this point in the history
2666: fix(windows) Fix slow memory grow handling (fix #2260) r=Amanieu a=ptitSeb

# Description
Fix slowiness on Windows plateforms with "memory grow".

Will fix #2260 and should speedup Windows use in general.

Co-authored-by: ptitSeb <[email protected]>
  • Loading branch information
bors[bot] and ptitSeb authored Nov 8, 2021
2 parents 04a4758 + 3af8b12 commit 0569267
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHANGELOG.md merge=union
*.wast linguist-vendored
*.wat linguist-vendored
* -text
tests/wasi-wast/wasi/test_fs -text
12 changes: 2 additions & 10 deletions lib/api/src/sys/tunables.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::sys::{MemoryType, Pages, TableType};
use loupe::MemoryUsage;
use std::cmp::min;
use std::ptr::NonNull;
use std::sync::Arc;
use target_lexicon::{OperatingSystem, PointerWidth};
use target_lexicon::PointerWidth;
use wasmer_compiler::Target;
use wasmer_engine::Tunables;
use wasmer_vm::MemoryError;
Expand Down Expand Up @@ -37,7 +36,7 @@ impl BaseTunables {
pub fn for_target(target: &Target) -> Self {
let triple = target.triple();
let pointer_width: PointerWidth = triple.pointer_width().unwrap();
let (mut static_memory_bound, mut static_memory_offset_guard_size): (Pages, u64) =
let (static_memory_bound, static_memory_offset_guard_size): (Pages, u64) =
match pointer_width {
PointerWidth::U16 => (0x400.into(), 0x1000),
PointerWidth::U32 => (0x4000.into(), 0x1_0000),
Expand All @@ -60,13 +59,6 @@ impl BaseTunables {
#[cfg(not(target_os = "windows"))]
let dynamic_memory_offset_guard_size: u64 = 0x1_0000;

if let OperatingSystem::Windows = triple.operating_system {
// For now, use a smaller footprint on Windows so that we don't
// outstrip the paging file.
static_memory_bound = min(static_memory_bound, 0x100.into());
static_memory_offset_guard_size = min(static_memory_offset_guard_size, 0x20000);
}

Self {
static_memory_bound,
static_memory_offset_guard_size,
Expand Down

0 comments on commit 0569267

Please sign in to comment.