Closed abrown closed 3 years ago
sort
may be a problem. Using Weak Heap Sorting algorithm isn't stable while ECMAScript currently specify Array#sort should be stable. That's why we currently temporary fallback to simple insertion sort O(N^2) for all references. It may be a problem for huge size of entries (> 1k)
Also as-wasi uses push
for read/readAll. Recently we fixed some huge perf regression which relate to buffer's growing for Array#push
. So I recommend update to v0.18.31
@MaxGraey Thanks for the heads up, it does run several seconds faster with that fix.
sort may be a problem
this issue also will be fixed soon
@MaxGraey, just wanted to say thanks for tracking this project and looking into these AssemblyScript issues. Let us know if you have any suggestions anywhere! (E.g., hope we're doing "the right thing" to get pointers here).
(E.g., hope we're doing "the right thing" to get pointers here).
Arrays and TypedArrays have special property for point to started data called dataStart
so you could use this:
// @ts-ignore: decorator
@inline
function getArrayPtr<T>(data: T[]): usize {
return data.dataStart;
}
// @ts-ignore: decorator
@inline
function getTypedArrayPtr(data: ArrayBufferView): usize { // ArrayBufferView is base class for Uint8Array and etc
return data.dataStart; // it also take into account data.byteOffset
}
Good to know! I think had read somewhere (or deduced from https://github.com/AssemblyScript/assemblyscript/issues/743) that it was an unstable, undocumented thing. But now I actually see it in the the docs so it looks like we can simplify a bit.
Why is the AssemblyScript example slower than the Rust version? There may be additional things on the Wasm side that could make the execution time faster. E.g., I noticed that loading the big weights files with
readBytes
seemed to take 20-25 seconds (aas-wasi
issue?).