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

Issue 603143 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 593416



Sign in to add a comment

mojom() template should not generate all languages by default.

Project Member Reported by agrieve@chromium.org, Apr 13 2016

Issue description

My motivation for this change is from the .mojom.js that is added as a runtime_dep to every target. It's only necessary if the client uses the .js bindings *and* doesn't ship the bindings via a .pak file.

As suggested in https://codereview.chromium.org/1875213002/

It would be better to have:
mojom("foo") {
  sources=["foo.mojom"]
  language = ["cpp"]
}

So that mojom wouldn't generate unused bindings by default.
 

Comment 1 by yzshen@chromium.org, Apr 13 2016

Cc: sa...@chromium.org
+CC sammc.

Hi, Sam.

Do you think you have cycles to take a look at this issue? Since you have put a lot of thoughts into the build rules of mojom targets, it would be great if you could help with this. Thanks!

Comment 2 by sa...@chromium.org, Apr 14 2016

I would prefer generating a separate foo_js target containing the generated .mojom.js files. Then a target that needs the generated JS bindings would add that target as a data dependency. It probably would be nicer to have users of the JS bindings be explicit about their dependencies.
Owner: ----
Components: Internals>Mojo
Labels: Build
Looks like there are close to 100 android_library() targets that are not used by any android_apk() target. Most of these are from mojo. Our builders build all targets, so it'd be really nice to not generate these unused targets (hard to really say how much it's slowing us down without actually doing it.

With a call to action to have more things converted to Mojo, this will just keep getting worse :(.

Components: -Internals>Mojo Internals>Mojo>Bindings
This is now creating a lot of unused java targets, which are much more heavy-weight than native targets.

I added a print(target_name) to the android_library() within mojom(), and found there are 153 mojom java libraries that are defined.

I then guarded the android_library behind a crude whitelist:

      if (target_gen_dir == "$root_gen_dir/components/payments/mojom" ||
          target_gen_dir == "$root_gen_dir/media/mojo/interfaces" ||
          target_gen_dir == "$root_gen_dir/mojo/common" ||
          target_gen_dir == "$root_gen_dir/mojo/public/interfaces/bindings/tests" ||
          target_gen_dir == "$root_gen_dir/services/device/public/interfaces" ||
          target_gen_dir == "$root_gen_dir/services/service_manager/public/interfaces" ||
          target_gen_dir == "$root_gen_dir/services/shape_detection/public/interfaces" ||
          target_gen_dir == "$root_gen_dir/skia/public/interfaces" ||
          target_gen_dir == "$root_gen_dir/third_party/WebKit/public" ||
          target_gen_dir == "$root_gen_dir/ui/base/mojo" ||
          target_gen_dir == "$root_gen_dir/ui/gfx/geometry/mojo" ||
          target_gen_dir == "$root_gen_dir/ui/latency/mojo" ||
          target_gen_dir == "$root_gen_dir/ui/gfx/mojo" ||
          target_gen_dir == "$root_gen_dir/device/bluetooth/public/interfaces" ||
          target_gen_dir == "$root_gen_dir/device/screen_orientation/public/interfaces" ||
          target_gen_dir == "$root_gen_dir/cc/ipc" ||
          target_gen_dir == "$root_gen_dir/gpu/ipc/common" ||
          target_gen_dir == "$root_gen_dir/services/shape_detection/public/interfaces" ||
          target_gen_dir == "$root_gen_dir/url/mojo") {

And only 53 targets are defined (based on the crude whitelist, some of these may also be unused).

Furthermore, the status message went from:
Done. Made 16339 targets from 1246 files in 4050ms

To:
Done. Made 15339 targets from 1246 files in 4180ms

Somewhat easy math here :P. I trimmed exactly 100 targets, and that resulted in exactly 1000 fewer ninja targets.

Note that our bots build all defined targets, so these unused 1000 targets are also consuming compile time on the bots.

Comment 8 by yzshen@chromium.org, Jul 26 2017

+1 to only generate Java bindings when needed.
Project Member

Comment 9 by sheriffbot@chromium.org, Jul 27

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Fixed (was: Untriaged)
This was fixed quite a while ago. We only generate C++ bindings by default, and we have explicitly suffixed (e.g. _js, _java) target names for the other languages.
Status: Available (was: Fixed)
I don't think this is fixed:
https://cs.chromium.org/chromium/src/mojo/public/tools/bindings/mojom.gni?rcl=e7c85230ef5c8c4a9e11a1c0e8ba19f6af955239&l=1053

The template still generates _java targets for all mojom regardless of whether anyone uses them.

The ask here is essentially to have "cpp_only=true" be the default.
The bug was that the mojom build rules were generating actual *sources* for other languages. I don't see why generating the *targets* themselves is problematic if they aren't actually reachable in the build. This should have negligible overhead. Am I missing some reason why they are problematic?
There are two motivations that I see:
1. GN has to generated targets that are not needed. Because android_library() is a fairly complicated template, having a lot of unused targets can unnecessarily slow down "gn gen". 
Timings for "gn gen" with target_os = "linux" vs "android": 3535ms, 5387ms

2. Many builders build all targets, and so are slowed down a bit when there are unused templates that exist.

Personally I think #1 is the bigger issue, since #2 only affects bots. Neither one of them is super important, which is why that it's fine this bug has remained unfixed for so long.
Components: Build
Labels: OS-Android

Sign in to add a comment