Translate

2016년 6월 11일 토요일

[Gradle] Gradle을 Daemon으로 띄워서 빌드 실행속도(성능)를 높여보자.



OS: ubuntu
Gradle ver: 2.13


Gradle을 알아보면서 실행할 때마다 Daemon 을 사용하면 더 빨라진다는 내용이 나오는데 계속 보고있자니 거슬려서 Deamon을 사용하도록 설정했다.


설정방법

셋팅 방법은 아래와 같이 gradle.properties 파일을 만들고 내용을 채워넣어준다.
$ vi ~/.gradle/gradle.properties
(윈도우7의 경우에는 "C:\Users\<username>\gradle.properties" 파일을 생성해 주면 된다.)

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.workers.max=3
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xms128m -Xmx256m

1004lucifer
위의 작업을 다 한 후 gradle 을 실행하면 데몬이 구동이 되고 이후에는 gradle 이 빠르게 작동된다.



PS.
한가지 유의해야 할 점은 위와같이 Gradle Daemon을 셋팅 했음에도 속도가 느리게 느껴질 수 있다.
Gradle은 JVM에서 동작하는데  Gradle Daemon을 사용하면 매전 JVM을 실행하거나 정지하지 않아도 된다.
그렇기 때문에 Daemon 셋팅 시 첫번째는 기존과 비슷한 속도로 수행이 될테며 두번째부터 빠른 속도를 체감 할 수 있다.
Gradle Daemon은 시간이 지나면 자동으로 종료를 한다.(기본 3시간)



데몬구동 설정하기 전


lucifer@lucifer-Vostro-V13:/source/gradle/160611/test01$ gradle task
:tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles test classes.

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'test01'.
components - Displays the components produced by root project 'test01'. [incubating]
dependencies - Displays all dependencies declared in root project 'test01'.
dependencyInsight - Displays the insight into a specific dependency in root project 'test01'.
help - Displays a help message.
model - Displays the configuration model of root project 'test01'. [incubating]
projects - Displays the sub-projects of root project 'test01'.
properties - Displays the properties of root project 'test01'.
tasks - Displays the tasks runnable from root project 'test01'.

Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.

Rules
-----
Pattern: clean<TaskName>: Cleans the output files of a task.
Pattern: build<ConfigurationName>: Assembles the artifacts of a configuration.
Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belonging to a configuration.

To see all tasks and more detail, run gradle tasks --all

To see more detail about a task, run gradle help --task <task>

BUILD SUCCESSFUL

Total time: 9.182 secs

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.13/userguide/gradle_daemon.html
lucifer@lucifer-Vostro-V13:/source/gradle/160611/test01$





데몬구동 설정 후 두번째 수행 시


lucifer@lucifer-Vostro-V13:/source/gradle/160611/test01$ gradle task
Parallel execution with configuration on demand is an incubating feature.
:tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles test classes.

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Documentation tasksIOException
-------------------
javadoc - Generates Javadoc API documentation for the main source code.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'test01'.
components - Displays the components produced by root project 'test01'. [incubating]
dependencies - Displays all dependencies declared in root project 'test01'.
dependencyInsight - Displays the insight into a specific dependency in root project 'test01'.
help - Displays a help message.
model - Displays the configuration model of root project 'test01'. [incubating]
projects - Displays the sub-projects of root project 'test01'.
properties - Displays the properties of root project 'test01'.
tasks - Displays the tasks runnable from root project 'test01'.

Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.

Rules
-----
Pattern: clean<TaskName>: Cleans the output files of a task.
Pattern: build<ConfigurationName>: Assembles the artifacts of a configuration.
Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belonging to a configuration.

To see all tasks and more detail, run gradle tasks --all

To see more detail about a task, run gradle help --task <task>

BUILD SUCCESSFUL

Total time: 2.147 secs
lucifer@lucifer-Vostro-V13:/source/gradle/160611/test01$





참조
http://knight76.tistory.com/entry/gradle-%EB%B9%8C%EB%93%9C-%EC%84%B1%EB%8A%A5-%EB%86%92%EC%9D%B4%EA%B8%B0
https://docs.gradle.org/2.13/userguide/gradle_daemon.html
https://docs.gradle.org/current/userguide/build_environment.html


댓글 없음 :

댓글 쓰기