XPerf
LanguagesKotlin

kotlinperf corpus targets

Large trees are not vendored, and the corpus is not shipped with the repo: clone it into any local directory outside the repo and pass that path to the linter.

Pins

TreeURLCommitSizeLint scope
kotlinx.coroutineshttps://github.com/Kotlin/kotlinx.coroutines.git7e0d1b3e9ca83652427ae00dda7d1673f058a743~27Mwhole tree
okhttphttps://github.com/square/okhttp.git2657315344316ba5bd1292d2fe9ca12636ae2290~15Mwhole tree (Kotlin sources)
kotlinx.serializationhttps://github.com/Kotlin/kotlinx.serialization.git4c28c3e33c145da536f1f4a671f70e5eb5b62b9c~13Mwhole tree

Shallow clones (--depth 1).

Dogfood (2026-10-21 Asia/Shanghai)

TreeRaw (--raw-paths)After reverse-opt
kotlinx.coroutines84 (kt-list-add-hot:2 kt-string-plus-hot:6 kt-println-hot:76)6 (1/5/0)
okhttp29 (11/1/17)8 (5/0/3)
kotlinx.serialization4 (2/0/2)1 (1/0/0)

Rule order: kt-list-add-hot / kt-string-plus-hot / kt-println-hot.

Reverse-opt (kotlinperf-lint)

  1. --raw-paths: baseline toggle.
  2. Path skips: test/ tests/ androidTest/ jvmTest/ commonTest/ nativeTest/ benchmarks/ samples/ sample/ examples/ example/ docs/ (plus always .git/build/.gradle/vendor/fixtures).
  3. Path suffixes: *Test.kt / *Tests.kt / /src/test/.
  4. kt-list-add-hot: suppress bare empty listOf() under reverse-opt (keep mutableListOf / arrayListOf / ArrayList()).
  5. kt-println-hot: skip KDoc/block-comment continuation lines (* … println); skip Debug/Demo filenames and DEBUG tokens.

Residual

  • coroutines: a few real += string builders in guidance/examples that live outside skipped dirs.
  • okhttp: list allocs in hot decoder paths (signal).

Do not commit corpus sources into packages/kotlinperf.

G3 TP/FP triage (2026-10-22 Asia/Shanghai)

r1 sample n=15r2 sample n=3
TP0%0%
FP40%0%
OK-idiom46.7%100%
SKIP-path13.3%0%
FP+DOC+SKIP53.3%0%

Corpus-ready? no — r1 noise >40%; r2 all OK-idiom (lazy lists / rare-race). Keep rules hint.

Fixes landed

  • kt-string-plus-hot collection += suppression; kt-println-hot bare println only; kt-list-add-hot lazy/constant listOf
  • Path skips: test-utils/, testing-support/, rules-integration-tests/, okcurl/
  • r2 counts: coroutines 1, okhttp 2, serialization 0

Redesign → corpus-ready (2026-10-22 Asia/Shanghai)

Treer2r3 (defaults)corpus-ready?
kotlinx.coroutines12
okhttp29
kotlinx.serialization01

Verdict: corpus-ready yes. Sample n=12: TP 58.3% / OK-idiom 41.7% / FP+DOC+SKIP 0%. Defaults: kt-list-add-hot–kt-println-hot off. KT004 removed (jitter; it covered empty list + add in size-hinted loop). No G4 escalate / no invented JSONL.