0cb6323bf1
The test allocates a lot of wasm memories. This got a low slower after https://crrev.com/c/3190476, because we can now allocate more than 102 memories, and do not explicitly trigger a GC any more to get rid of unused memories. We should figure out how to tell the GC about the external memory such that the memories get collected earlier. R=ahaas@chromium.org Bug: v8:12076, v8:12278 Change-Id: I9b8795a9999a806380d86f22e751de2727942648 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3196131 Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/main@{#77164}
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
function AllocMemory(pages, max = pages) {
|
|
let m =
|
|
new WebAssembly.Memory({initial : pages, maximum : max, shared : true});
|
|
let v = new Int32Array(m.buffer);
|
|
return {memory : m, view : v};
|
|
}
|
|
|
|
function RunSomeAllocs(total, retained, pages, max = pages) {
|
|
print(`-------iterations = ${total}, retained = ${retained} -------`);
|
|
var array = new Array(retained);
|
|
for (var i = 0; i < total; i++) {
|
|
if ((i % 25) == 0)
|
|
print(`iteration ${i}`);
|
|
let pair = AllocMemory(pages, max);
|
|
// For some iterations, retain the memory, view, or both.
|
|
switch (i % 3) {
|
|
case 0:
|
|
pair.memory = null;
|
|
break;
|
|
case 1:
|
|
pair.view = null;
|
|
break;
|
|
case 2:
|
|
break;
|
|
}
|
|
array[i % retained] = pair;
|
|
}
|
|
}
|
|
|
|
RunSomeAllocs(10, 1, 1, 1);
|
|
RunSomeAllocs(100, 3, 1, 1);
|
|
RunSomeAllocs(1000, 10, 1, 1);
|
|
// TODO(12278): Make this faster (by collection memories earlier?) and reenable.
|
|
// RunSomeAllocs(10000, 20, 1, 1);
|