[K2] Move Analysis perf calculation inside corresponding fronted runner

This way it is easier to understand where `notifyAnalysis*`
methods were called. Also, in K1, we are not including
`checkKotlinPackageUsageFor*` in the analysis time.
This commit is contained in:
Ivan Kylchik
2024-03-04 18:57:52 +01:00
committed by Space Team
parent cbda22ab48
commit 8275c92cd4
3 changed files with 7 additions and 13 deletions
@@ -141,7 +141,6 @@ object FirKotlinToJvmBytecodeCompiler {
}
private fun CompilationContext.compileModule(): Pair<FirResult, GenerationState>? {
performanceManager?.notifyAnalysisStarted()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
if (!checkKotlinPackageUsageForPsi(configuration, allSources)) return null
@@ -149,9 +148,7 @@ object FirKotlinToJvmBytecodeCompiler {
val renderDiagnosticNames = configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
val diagnosticsReporter = createPendingReporter(messageCollector)
val firResult = runFrontend(allSources, diagnosticsReporter, module.getModuleName(), module.getFriendPaths()).also {
performanceManager?.notifyAnalysisFinished()
}
val firResult = runFrontend(allSources, diagnosticsReporter, module.getModuleName(), module.getFriendPaths())
if (firResult == null) {
FirDiagnosticsCompilerResultsReporter.reportToMessageCollector(diagnosticsReporter, messageCollector, renderDiagnosticNames)
return null
@@ -192,6 +189,9 @@ object FirKotlinToJvmBytecodeCompiler {
rootModuleName: String,
friendPaths: List<String>,
): FirResult? {
val performanceManager = configuration.get(CLIConfigurationKeys.PERF_MANAGER)
performanceManager?.notifyAnalysisStarted()
val syntaxErrors = ktFiles.fold(false) { errorsFound, ktFile ->
AnalyzerWithCompilerReport.reportSyntaxErrors(ktFile, messageCollector).isHasErrors or errorsFound
}
@@ -228,6 +228,7 @@ object FirKotlinToJvmBytecodeCompiler {
}
outputs.runPlatformCheckers(diagnosticsReporter)
performanceManager?.notifyAnalysisFinished()
return runUnless(syntaxErrors || scriptsInCommonSourcesErrors || diagnosticsReporter.hasErrors) { FirResult(outputs) }
}
@@ -111,9 +111,6 @@ fun compileModulesUsingFrontendIrAndLightTree(
val renderDiagnosticNames = moduleConfiguration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
val diagnosticsReporter = FirKotlinToJvmBytecodeCompiler.createPendingReporter(messageCollector)
performanceManager?.notifyAnalysisStarted()
val analysisResults = compileModuleToAnalyzedFir(
compilerInput,
projectEnvironment,
@@ -127,8 +124,6 @@ fun compileModulesUsingFrontendIrAndLightTree(
return false
}
performanceManager?.notifyAnalysisFinished()
val mainClassFqName = runIf(moduleConfiguration.get(JVMConfigurationKeys.OUTPUT_JAR) != null) {
findMainClass(analysisResults.outputs.last().fir)
}
@@ -273,6 +268,7 @@ fun compileModuleToAnalyzedFir(
diagnosticsReporter: BaseDiagnosticsCollector,
performanceManager: CommonCompilerPerformanceManager?
): FirResult {
performanceManager?.notifyAnalysisStarted()
val moduleConfiguration = input.configuration
var librariesScope = projectEnvironment.getSearchScopeForProjectLibraries()
@@ -317,6 +313,7 @@ fun compileModuleToAnalyzedFir(
}
outputs.runPlatformCheckers(diagnosticsReporter)
performanceManager?.notifyAnalysisFinished()
return FirResult(outputs)
}
@@ -213,8 +213,6 @@ open class IncrementalFirJvmCompilerRunner(
configuration
)
performanceManager?.notifyAnalysisStarted()
val analysisResults =
compileModuleToAnalyzedFir(
compilerInput,
@@ -225,8 +223,6 @@ open class IncrementalFirJvmCompilerRunner(
performanceManager
)
performanceManager?.notifyAnalysisFinished()
// TODO: consider what to do if many compilations find a main class
if (mainClassFqName == null && configuration.get(JVMConfigurationKeys.OUTPUT_JAR) != null) {
mainClassFqName = findMainClass(analysisResults.outputs.last().fir)