New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 863205 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 1
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Feature



Sign in to add a comment

Profiling WebAssembly code isn't useful because of "<WASM UNNAMED>"

Project Member Reported by evan....@gmail.com, Jul 12

Issue description

Chrome Version: 67.0.3396.99 (Official Build) (64-bit)
OS: macOS 10.13.6

What steps will reproduce the problem?

(1) Profile https://webassembly.org/demo/Tanks/ in Chrome Developer Tools

What is the expected result?

I expected function names of the form "wasm-function[\d+]". That's the format that Chrome uses for stack traces (i.e. Error.prototype.stack). It's also the format that Firefox uses for its profiler.

What happens instead?

Every WebAssembly function in Chrome shows up as "<WASM UNNAMED>" instead. This makes it impossible for us to debug the performance of our WebAssembly app.

We have been getting by so far by compiling C++ to JavaScript instead and profiling that, but obviously the performance characteristics are pretty different and we'd like to be able to measure the real thing. For example, the start of JavaScript execution is warped by JIT overhead, which sometimes causes us to mis-prioritize optimizations.

From a tooling perspective, it'd be really straightforward for us to convert the "wasm-function[\d+]" format back to C++ function names since we already have to do that for stack traces anyway.

It seems like this would be really straightforward to do. I think this is the code that causes this:

    Handle<String> WasmModuleObject::GetFunctionName(
        Isolate* isolate, Handle<WasmModuleObject> module_object,
        uint32_t func_index) {
      MaybeHandle<String> name =
          GetFunctionNameOrNull(isolate, module_object, func_index);
      if (!name.is_null()) return name.ToHandleChecked();
      return isolate->factory()->NewStringFromStaticChars("<WASM UNNAMED>");
    }

Just returning "wasm-function[" + func_index + "]" here would make profiling WebAssembly code infinitely more useful in Chrome.

 
Cc: nattestad@chromium.org herhut@chromium.org
Labels: -Type-Bug -Pri-3 Pri-2 Type-Feature
Status: Available (was: Untriaged)
Stephan/Ben, would the suggested change work? Seems like an easy DevX win?
Project Member

Comment 2 by bugdroid1@chromium.org, Jul 31

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/bf066d858466ce225b62a27b02e74196ac9c5ba4

commit bf066d858466ce225b62a27b02e74196ac9c5ba4
Author: Ben L. Titzer <titzer@chromium.org>
Date: Tue Jul 31 11:20:44 2018

[wasm] Use "wasm-function[i]" for wasm function name

BUG= chromium:863205 
R=clemensh@chromium.org

Change-Id: I15f3a09e15210a80b155def5761d9aead95d19b7
Reviewed-on: https://chromium-review.googlesource.com/1156386
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54811}
[modify] https://crrev.com/bf066d858466ce225b62a27b02e74196ac9c5ba4/src/wasm/wasm-objects.cc
[modify] https://crrev.com/bf066d858466ce225b62a27b02e74196ac9c5ba4/src/wasm/wasm-objects.h
[modify] https://crrev.com/bf066d858466ce225b62a27b02e74196ac9c5ba4/test/mjsunit/wasm/function-names.js

Owner: titzer@chromium.org
Status: Fixed (was: Available)
I've implemented the suggested change (thanks!). Closing as fixed, since "wasm-function[i]" is the best that we can do without the names section.
Thanks so much! That's super helpful.

Sign in to add a comment