Closed Bug 1832296 Opened 2 years ago Closed 1 years ago

Improve performance of allocation of non-OOL wasm-gc structs

Categories

(Core :: JavaScript: WebAssembly, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: jseward, Assigned: jseward)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Now that the dust has settled a bit, it is possible to discern a couple of
inefficiencies in the path for struct allocation in the case where no OOL area
is needed:

  • In WasmStructObject::createStruct, there are two checks for
    outlineBytes > 0. We really ought to be doing that only once.

  • Also, the use of Rooted for structObj is needed only in the OOL case;
    and Rooted isn't cheap.

  • Instance::structNew{,Uninit} is a bit silly in that it does almost nothing
    and then tail-calls on to WasmStructObject::createStruct. It would be
    better if the latter could be inlined into the former.

Blocks: wasm-gc

This patch tunes the allocation path for non-OOL wasm-gc structs. Basically
it is a rework of WasmStructObject::createStruct. There are three changes:

  • The existing WasmStructObject::createStruct checks outlineBytes == 0 at
    least twice. The revised version tests just once, and has the entire
    allocation logic duplicated and then specialised in both the then- and else-
    branches.

  • Doing that makes the non-OOL logic somewhat simpler, and exposes the fact
    that the use of Rooted isn't needed, so it is removed.

  • Finally, the non-OOL logic is moved to the header file (so
    WasmStructObject::createStruct is actually in the header), with the OOL
    case being handed by a new MOZ_NEVER_INLINE function
    WasmStructObject::createStructOOL.

  • As a related ridealong fix, WasmStructObject::getDataByteSizes is
    rewritten to be a bit simpler and to avoid a potential aliasing-problem from
    causing Clang to generate a redundant load.

For unoptimised Barista-3 on Ion on x64-linux, this gives a 3.5% reduction in
first-frame time and a 4.5% reduction in frame-average time.

Pushed by jseward@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e77278b32db0 Improve performance of allocation of non-OOL wasm-gc structs. r=rhunt.

Backed out for causing build bustages.

[task 2023-05-11T06:38:35.563Z] 06:38:35     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/toolkit/library/gtest'
[task 2023-05-11T06:38:35.564Z] 06:38:35     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ -isysroot /builds/worker/fetches/MacOSX13.0.sdk -mmacosx-version-min=10.12 -stdlib=libc++ -Qunused-arguments --target=x86_64-apple-darwin -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-sized-deallocation -fno-aligned-new -fcrash-diagnostics-dir=/builds/worker/artifacts -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -gdwarf-4 -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O3 -fno-omit-frame-pointer -funwind-tables -Werror   -o XUL -Wl,-filelist,/builds/worker/workspace/obj-build/toolkit/library/gtest/XUL.list   -fuse-ld=lld -fstack-protector-strong '-Wl,-U,_OBJC_CLASS_$_NSTouchBar' '-Wl,-U,_OBJC_CLASS_$_NSSharingServicePickerTouchBarItem' '-Wl,-U,_OBJC_METACLASS_$_NSTouchBar' '-Wl,-U,_OBJC_CLASS_$_NSCustomTouchBarItem' '-Wl,-U,_OBJC_CLASS_$_NSPopoverTouchBarItem' -lresolv -Wl,-dead_strip  ../../../js/src/build/libjs_static.a /builds/worker/workspace/obj-build/x86_64-apple-darwin/release/libgkrust_gtest.a ../../../security/libnss3.dylib ../../../config/external/lgpllibs/liblgpllibs.dylib ../../../mozglue/build/libmozglue.dylib -dynamiclib -install_name @rpath/XUL -compatibility_version 1 -current_version 1  -framework AudioUnit -framework CoreAudio -lbsm -framework IOSurface -framework IOKit -framework AudioToolbox -framework CoreMedia -framework VideoToolbox -Wl,-U,_VTRegisterSupplementalVideoDecoderIfAvailable -Wl,-U,_VTIsHardwareDecodeSupported -framework Vision -framework LocalAuthentication -framework Security -lm -framework Foundation -framework CoreFoundation -framework CoreLocation -framework QuartzCore -framework Carbon -framework CoreVideo -framework AddressBook -framework OpenGL -framework ServiceManagement -framework CoreServices -framework ApplicationServices -framework AppKit -framework CoreMIDI -framework SystemConfiguration -framework AVFoundation -F/builds/worker/fetches/MacOSX13.0.sdk/System/Library/PrivateFrameworks -framework CoreUI -framework CoreSymbolication -weak_framework SidecarCore -lcups -weak_framework Metal -weak_framework MediaPlayer
[task 2023-05-11T06:38:35.564Z] 06:38:35    ERROR -  ld64.lld: error: undefined symbol: js::WasmGcObject::create(JSContext*, js::wasm::TypeDefInstanceData*, js::gc::InitialHeap)
[task 2023-05-11T06:38:35.564Z] 06:38:35     INFO -  >>> referenced by WasmGcObject.h:258 (/builds/worker/checkouts/gecko/js/src/wasm/WasmGcObject.h:258)
[task 2023-05-11T06:38:35.564Z] 06:38:35     INFO -  >>>               ../../../js/src/build/libjs_static.a(WasmInstance.o):(symbol js::wasm::Instance::structNew(js::wasm::Instance*, js::wasm::TypeDefInstanceData*)+0x32)
[task 2023-05-11T06:38:35.564Z] 06:38:35     INFO -  >>> referenced by WasmGcObject.h:258 (/builds/worker/checkouts/gecko/js/src/wasm/WasmGcObject.h:258)
[task 2023-05-11T06:38:35.564Z] 06:38:35     INFO -  >>>               ../../../js/src/build/libjs_static.a(WasmInstance.o):(symbol js::wasm::Instance::structNewUninit(js::wasm::Instance*, js::wasm::TypeDefInstanceData*)+0x2f)
[task 2023-05-11T06:38:35.565Z] 06:38:35     INFO -  >>> referenced by WasmGcObject.h:258 (/builds/worker/checkouts/gecko/js/src/wasm/WasmGcObject.h:258)
[task 2023-05-11T06:38:35.565Z] 06:38:35     INFO -  >>>               ../../../js/src/build/libjs_static.a(WasmInstance.o):(symbol js::wasm::Instance::constantStructNewDefault(JSContext*, unsigned int)+0x4d)
[task 2023-05-11T06:38:35.565Z] 06:38:35    ERROR -  clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
[task 2023-05-11T06:38:35.565Z] 06:38:35    ERROR -  gmake[4]: *** [/builds/worker/checkouts/gecko/config/rules.mk:535: XUL] Error 1
[task 2023-05-11T06:38:35.565Z] 06:38:35     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/toolkit/library/gtest'
[task 2023-05-11T06:38:35.565Z] 06:38:35     INFO -  gmake[4]: Target 'target' not remade because of errors.
[task 2023-05-11T06:38:35.565Z] 06:38:35     INFO -  gmake[4]: Target 'target' not remade because of errors.
[task 2023-05-11T06:38:35.565Z] 06:38:35    ERROR -  gmake[3]: *** [/builds/worker/checkouts/gecko/config/recurse.mk:72: toolkit/library/gtest/target] Error 2
[task 2023-05-11T06:44:06.871Z] 06:44:06     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/toolkit/library/rust'
Flags: needinfo?(jseward)
Pushed by jseward@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c17be5dddce8 Improve performance of allocation of non-OOL wasm-gc structs. r=rhunt.
Status: NEW → RESOLVED
Closed: 1 years ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
Flags: needinfo?(jseward)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: