ktorm icon indicating copy to clipboard operation
ktorm copied to clipboard

ksp 编译速度很慢. KSP compilation speed is very slow.

Open JsonSong89 opened this issue 1 year ago • 3 comments

我按照 https://github.com/kotlin-orm/ktorm/releases/tag/v4.0.0 的配置,换成4.1.1去进行ksp实体代码生成. 8个实体,ksp编译花了 03:44 min ,Entity是独立项目,只有8个实体类的编译,不含其他业务代码和测试代码. 想问下这算是正常情况吗?

I followed the configuration at https://github.com/kotlin-orm/ktorm/releases/tag/v4.0.0 and switched to version 4.1.1 for KSP entity code generation. It took 03:44 min to compile 8 entities using KSP. The Entity is a standalone project with only 8 entity classes, excluding other business code and test code. I would like to ask if this is considered a normal situation?

pom config :

<properties>
    <ktorm.version>4.1.1</ktorm.version>
    <kotlin.version>1.9.23</kotlin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.test.skip>true</maven.test.skip>
</properties>
org.jetbrains.kotlin kotlin-stdlib ${kotlin.version} org.jetbrains.kotlin kotlin-reflect ${kotlin.version} org.ktorm ktorm-core ${ktorm.version} org.ktorm ktorm-support-mysql ${ktorm.version} org.ktorm ktorm-ksp-annotations ${ktorm.version}
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-annotation</artifactId>
        <version>3.5.7</version>
        <optional>true</optional>
    </dependency>

</dependencies>
       <sourceDirectory>src/main/kotlin</sourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <compilerPlugins>
                                <compilerPlugin>ksp</compilerPlugin>
                            </compilerPlugins>
                            <pluginOptions>
                                <option>ksp:apoption=ktorm.dbNamingStrategy=lower-snake-case</option>
                            </pluginOptions>
                        </configuration>
                    </execution>
                    <!--                    <execution>-->
                    <!--                        <id>test-compile</id>-->
                    <!--                        <phase>test-compile</phase>-->
                    <!--                        <goals>-->
                    <!--                            <goal>test-compile</goal>-->
                    <!--                        </goals>-->
                    <!--                        <configuration>-->
                    <!--                            <compilerPlugins>-->
                    <!--                                <compilerPlugin>ksp</compilerPlugin>-->
                    <!--                            </compilerPlugins>-->
                    <!--                            <pluginOptions>-->
                    <!--                                <option>ksp:apoption=ktorm.dbNamingStrategy=lower-snake-case</option>-->
                    <!--                            </pluginOptions>-->
                    <!--                        </configuration>-->
                    <!--                    </execution>-->
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.ktorm</groupId>
                        <artifactId>ktorm-ksp-compiler-maven-plugin</artifactId>
                        <version>${ktorm.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

JsonSong89 avatar Sep 04 '24 06:09 JsonSong89

可以提供下你的项目代码和机器配置

vincentlauvlwj avatar Sep 07 '24 16:09 vincentlauvlwj

31.entity.zip

原来是7个实体,我删到只剩2个,现在用时70s 35 * 7 , 和原来的速度也差不多对的上

JsonSong89 avatar Sep 08 '24 14:09 JsonSong89

机器配置是5600x 32g内存 固态硬盘 jdk21.0.4 win10系统

JsonSong89 avatar Sep 08 '24 14:09 JsonSong89

[INFO] --- kotlin:2.1.0:compile (compile) @ jsa-entity-demo ---
[INFO] Applied plugin: 'ksp'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.050 s
[INFO] Finished at: 2024-12-04T16:36:55+08:00
[INFO] ------------------------------------------------------------------------

切换成Kotlin 2.0 编译会快很多 配置:Ryzen7 5800H 40GB内存 其余配置和你一样

weifengze avatar Dec 04 '24 08:12 weifengze

切换成Kotlin 2.0 编译会快很多 配置:Ryzen7 5800H 40GB内存 其余配置和你一样

还真是 我现在只要 [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.879 s

从 70s 变到3.8s,那我只能理解是kotlin1.9的bug吧

entity一般都是独立项目,版本分开构建也不是啥问题,那这个issue我先关了吧

JsonSong89 avatar Dec 04 '24 09:12 JsonSong89