android-projects icon indicating copy to clipboard operation
android-projects copied to clipboard

bazel is slower than gradle?

Open vaneyli opened this issue 5 years ago • 2 comments

I can't find your email :) so i make a fake issue here. using this benchmark i found the bazel is slower than gradle?!

just like the folder of linear. when i run bazel build and gradlew build. the gradle run faster. is this a real fact? may be i make a mistake? what's your test result? thanks

vaneyli avatar Aug 10 '20 03:08 vaneyli

I wouldn't use linear as the benchmark. It's not representative of most projects, and doesn't exploit the parallelism of both build systems.

I'd suggest trying out connected or big_connected.

jin avatar Aug 10 '20 05:08 jin

i ran the big_connected. i found the bazel is slower than gradle. The gap is biggest at the cleanAndBuild.
iterations=3 warmups=1 gradle is 6.5.1 bazel is 3.4.1 MacBook Pro (16-inch, 2019) 2.6 GHz 6 Intel Core i7 16 GB 2667 MHz DDR4 Macintosh HD

scenario: ######## cleanAndBuild { title = "cleanAndBuild" tasks = [":androidAppModule0:assembleDebug"] cleanup-tasks = ["clean"] clear-build-cache-before = BUILD gradle-args = ["--no-build-cache","--parallel"] bazel { cmds = ["bazel", "clean"] # cmds is my own funtions which just run cmds on the shell targets = ["build", "//androidAppModule0"] } } ########

WORKSPACE: ######## android_sdk_repository( name = "androidsdk", )

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") RULES_JVM_EXTERNAL_TAG = "2.7" RULES_JVM_EXTERNAL_SHA = "f04b1466a00a2845106801e0c5cec96841f49ea4e7d1df88dc8e4bf31523df74" http_archive( name = "rules_jvm_external", sha256 = RULES_JVM_EXTERNAL_SHA, strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, urls = ["https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG], ) load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install( artifacts = ["com.android.support:appcompat-v7:28.0.0", "com.android.support.constraint:constraint-layout:1.1.3", "junit:junit:4.12", "com.android.support.test:runner:1.0.2", "com.android.support.test.espresso:espresso-core:3.0.2", "com.android.support:multidex:1.0.3",], repositories = ["https://jcenter.bintray.com/", "https://maven.google.com", "https://repo1.maven.org/maven2",], ) ########

androidAppModule0/BUILD.bazel ######## android_binary( name = "androidAppModule0", srcs = glob(["src/main/java//*.java"]), multidex = "native", resource_files = glob(["src/main/res//*"]), manifest = "src/main/AndroidManifest.xml", custom_package = "com.androidAppModule0", manifest_values = { "minSdkVersion" : "19", }, visibility = ["//visibility:public"], deps = [ "//module5", "//module3", "//module9", "//androidAppModule4", "//module6", "//module26", "//androidAppModule11", "//module4", "//androidAppModule1", "//androidAppModule15", "//module22", "//androidAppModule25", "//androidAppModule12", "//module21", "//androidAppModule3", "//module16", "//androidAppModule10", "//module20", "//androidAppModule27", "//module0", "//androidAppModule29", "//androidAppModule16", "//androidAppModule5", "//androidAppModule26", "//module19", "//androidAppModule23", "//androidAppModule24", "@maven//:com_android_support_appcompat_v7", "@maven//:com_android_support_constraint_constraint_layout", "@maven//:com_android_support_multidex", "@maven//:com_android_support_test_runner", "@maven//:com_android_support_test_espresso_espresso_core" , ], )

result:
Gradle 14422ms Bazel. 121784ms almost 10 times gap!

i also run the clean and build commands manually in the shell cmd, it produced the same results. any suggestion? thanks

vaneyli avatar Aug 23 '20 14:08 vaneyli