Revert "IJPL-156308 Rewrite reopen.project.startup.performance:code.loaded.and.visible.in.editor on the base of new editor creation logic"

This reverts commit fa73317e

GitOrigin-RevId: d1766910387a8ad0be402a7c6564b91415f9c3ce
This commit is contained in:
Elena Shaverdova
2024-06-26 19:09:48 +02:00
committed by intellij-monorepo-bot
parent 76fe0d41fa
commit 36f521f2f2
2 changed files with 19 additions and 30 deletions

View File

@@ -1,7 +1,7 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.platform.ide.diagnostic.startUpPerformanceReporter
// import com.intellij.concurrency.currentThreadContext
import com.intellij.concurrency.currentThreadContext
import com.intellij.diagnostic.StartUpMeasurer
import com.intellij.ide.impl.ProjectUtilCore
import com.intellij.idea.IdeStarter
@@ -9,12 +9,12 @@ import com.intellij.internal.statistic.eventLog.EventLogGroup
import com.intellij.internal.statistic.eventLog.events.*
import com.intellij.internal.statistic.eventLog.events.EventFields.createDurationField
import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector
// import com.intellij.openapi.application.readAction
import com.intellij.openapi.application.readAction
import com.intellij.openapi.components.Service
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileWithId
import com.intellij.util.containers.ComparatorUtil
// import com.intellij.util.containers.ContainerUtil
import com.intellij.util.containers.ContainerUtil
import it.unimi.dsi.fastutil.ints.IntOpenHashSet
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
@@ -89,14 +89,13 @@ object FUSProjectHotStartUpMeasurer {
}
class MarkupRestoredEvent(val fileId: Int) : Event
/*
class FirstEditorEvent(
val sourceOfSelectedEditor: SourceOfSelectedEditor,
val file: VirtualFile,
val time: Long
) : Event
class NoMoreEditorsEvent(val time: Long) : Event*/
class NoMoreEditorsEvent(val time: Long) : Event
data object ResetProjectPathEvent : Event
data object IdeStarterStartedEvent : Event
@@ -199,32 +198,28 @@ object FUSProjectHotStartUpMeasurer {
channel.trySend(Event.MarkupRestoredEvent(file.id))
}
@Suppress("unused")
fun firstOpenedEditor(file: VirtualFile) {
/*if (!currentThreadContext().isProperContext()) {
if (!currentThreadContext().isProperContext()) {
return
}
channel.trySend(Event.FirstEditorEvent(SourceOfSelectedEditor.TextEditor, file, System.nanoTime()))*/
channel.trySend(Event.FirstEditorEvent(SourceOfSelectedEditor.TextEditor, file, System.nanoTime()))
}
@Suppress("unused", "RedundantSuspendModifier")
suspend fun firstOpenedUnknownEditor(file: VirtualFile, nanoTime: Long) {
/* if (!isProperContext()) return
channel.trySend(Event.FirstEditorEvent(SourceOfSelectedEditor.UnknownEditor, file, nanoTime))*/
if (!isProperContext()) return
channel.trySend(Event.FirstEditorEvent(SourceOfSelectedEditor.UnknownEditor, file, nanoTime))
}
@Suppress("unused", "RedundantSuspendModifier")
suspend fun openedReadme(readmeFile: VirtualFile, nanoTime: Long) {
/* if (!isProperContext()) return
channel.trySend(Event.FirstEditorEvent(SourceOfSelectedEditor.FoundReadmeFile, readmeFile, nanoTime))*/
if (!isProperContext()) return
channel.trySend(Event.FirstEditorEvent(SourceOfSelectedEditor.FoundReadmeFile, readmeFile, nanoTime))
}
@Suppress("unused")
fun reportNoMoreEditorsOnStartup(nanoTime: Long) {
/*if (!currentThreadContext().isProperContext()) {
if (!currentThreadContext().isProperContext()) {
return
}
channel.trySend(Event.NoMoreEditorsEvent(nanoTime))*/
channel.trySend(Event.NoMoreEditorsEvent(nanoTime))
}
private data class LastHandledEvent(val event: Event.FUSReportableEvent, val durationReportedToFUS: Duration)
@@ -292,7 +287,7 @@ object FUSProjectHotStartUpMeasurer {
}
return null
}
/*
private suspend fun applyEditorEventIfPossible(
firstEditorEvent: Event.FirstEditorEvent?,
noEditorEvent: Event.NoMoreEditorsEvent?,
@@ -331,7 +326,7 @@ object FUSProjectHotStartUpMeasurer {
CODE_LOADED_AND_VISIBLE_IN_EDITOR_EVENT.log(data)
throw CancellationException()
}*/
}
suspend fun startWritingStatistics() {
try {
@@ -357,8 +352,8 @@ object FUSProjectHotStartUpMeasurer {
var frameBecameInteractiveEvent: Event.FrameBecameInteractiveEvent? = null
var projectPathReportEvent: Event.ProjectPathReportEvent? = null
var projectTypeReportEvent: Event.ProjectTypeReportEvent? = null
// var firstEditorEvent: Event.FirstEditorEvent? = null
// var noEditorEvent: Event.NoMoreEditorsEvent? = null
var firstEditorEvent: Event.FirstEditorEvent? = null
var noEditorEvent: Event.NoMoreEditorsEvent? = null
for (event in channel) {
yield()
@@ -388,8 +383,8 @@ object FUSProjectHotStartUpMeasurer {
Event.ResetProjectPathEvent -> projectPathReportEvent = null
is Event.ProjectTypeReportEvent -> if (projectTypeReportEvent == null) projectTypeReportEvent = event
is Event.ViolationEvent -> reportViolation(event.violation, event.time, ideStarterStartedEvent, lastHandledEvent)
// is Event.FirstEditorEvent -> if (firstEditorEvent == null) firstEditorEvent = event
// is Event.NoMoreEditorsEvent -> if (noEditorEvent == null) noEditorEvent = event
is Event.FirstEditorEvent -> if (firstEditorEvent == null) firstEditorEvent = event
is Event.NoMoreEditorsEvent -> if (noEditorEvent == null) noEditorEvent = event
}
while (true) {
@@ -402,8 +397,7 @@ object FUSProjectHotStartUpMeasurer {
projectPathReportEvent, ideStarterStartedEvent, lastHandledEvent)
is Event.FrameBecameVisibleEvent -> applyFrameInteractiveEventIfPossible(frameBecameInteractiveEvent, lastHandledEvent)
is Event.FrameBecameInteractiveEvent -> {
//applyEditorEventIfPossible(firstEditorEvent, noEditorEvent, markupResurrectedFileIds, projectPathReportEvent, lastHandledEvent)
throw CancellationException()
applyEditorEventIfPossible(firstEditorEvent, noEditorEvent, markupResurrectedFileIds, projectPathReportEvent, lastHandledEvent)
break
}
}
@@ -462,7 +456,6 @@ private val FRAME_BECAME_VISIBLE_EVENT = GROUP.registerVarargEvent("frame.became
private val FRAME_BECAME_INTERACTIVE_EVENT = GROUP.registerEvent("frame.became.interactive", DURATION)
@Suppress("unused")
private enum class SourceOfSelectedEditor {
TextEditor,
UnknownEditor,
@@ -473,7 +466,6 @@ private val LOADED_CACHED_MARKUP_FIELD = EventFields.Boolean("loaded_cached_mark
private val SOURCE_OF_SELECTED_EDITOR_FIELD: EnumEventField<SourceOfSelectedEditor> =
EventFields.Enum("source_of_selected_editor", SourceOfSelectedEditor::class.java)
private val NO_EDITORS_TO_OPEN_FIELD = EventFields.Boolean("no_editors_to_open")
@Suppress("unused")
private val CODE_LOADED_AND_VISIBLE_IN_EDITOR_EVENT = GROUP.registerVarargEvent("code.loaded.and.visible.in.editor",
DURATION,
EventFields.FileType,

View File

@@ -61,9 +61,6 @@ internal class WaitForFinishedCodeAnalysis(text: String, line: Int) : Performanc
delay(500)
}
else {
// added delay to ensure time till opening editors is covered because `isHandlingFinished`
// now happens on the frame becoming interactive or all events written: IJPL-156308
delay(500)
return@launch
}
}