Use isFull from ScanningType, not separate value in stats and diagnostic

GitOrigin-RevId: ee50604960b62b55fb457e74e61e6965473015a5
This commit is contained in:
Elena Shaverdova
2022-06-11 20:46:15 +00:00
committed by intellij-monorepo-bot
parent 6f90e03810
commit 18f193dd15
12 changed files with 30 additions and 31 deletions
@@ -11,6 +11,7 @@ import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
import com.intellij.util.SystemProperties
import com.intellij.util.indexing.diagnostic.IndexDiagnosticDumper
import com.intellij.util.indexing.diagnostic.IndexDiagnosticDumperUtils
import com.intellij.util.indexing.diagnostic.ScanningType
import com.intellij.util.indexing.diagnostic.dto.*
import com.intellij.util.indexing.diagnostic.dump.paths.PortableFilePath
import org.junit.Assert
@@ -74,7 +75,7 @@ class IndexDiagnosticTest : JavaCodeInsightFixtureTestCase() {
projectName = "projectName",
times = JsonProjectIndexingHistoryTimes(
"reason",
false,
ScanningType.PARTIAL,
JsonDuration(123),
JsonDuration(456),
JsonDuration(789),
@@ -93,7 +93,7 @@ public final class FileBasedIndexProjectHandler {
@NotNull Project project,
long refreshedFilesCalcDuration) {
ProjectIndexingHistoryImpl projectIndexingHistory =
new ProjectIndexingHistoryImpl(project, "On refresh of " + files.size() + " files", ScanningType.REFRESH, false);
new ProjectIndexingHistoryImpl(project, "On refresh of " + files.size() + " files", ScanningType.REFRESH);
IndexDiagnosticDumper.getInstance().onIndexingStarted(projectIndexingHistory);
((FileBasedIndexImpl)FileBasedIndex.getInstance()).fireUpdateStarted(project);
@@ -621,7 +621,7 @@ public class UnindexedFilesUpdater extends DumbModeTask {
protected @NotNull ProjectIndexingHistoryImpl performScanningAndIndexing(@NotNull ProgressIndicator indicator) {
ProjectIndexingHistoryImpl projectIndexingHistory =
new ProjectIndexingHistoryImpl(myProject, myIndexingReason, myScanningType, isFullIndexUpdate());
new ProjectIndexingHistoryImpl(myProject, myIndexingReason, myScanningType);
myIndex.loadIndexes();
myIndex.filesUpdateStarted(myProject, isFullIndexUpdate());
IndexDiagnosticDumper.getInstance().onIndexingStarted(projectIndexingHistory);
@@ -24,7 +24,6 @@ interface ProjectIndexingHistoryListener {
interface ProjectIndexingHistory {
val project: Project
val indexingReason: String?
val scanningType: ScanningType
val indexingSessionId: Long
val times: IndexingTimes
val scanningStatistics: List<JsonScanningStatistics>
@@ -34,10 +33,10 @@ interface ProjectIndexingHistory {
val visibleTimeToAllThreadsTimeRatio: Double
}
enum class ScanningType {
FULL_FORCED, FULL_ON_PROJECT_OPEN, FULL,
PARTIAL_FORCED, PARTIAL,
REFRESH;
enum class ScanningType(val isFull: Boolean) {
FULL_FORCED(true), FULL_ON_PROJECT_OPEN(true), FULL(true),
PARTIAL_FORCED(false), PARTIAL(false),
REFRESH(false);
companion object {
fun merge(first: ScanningType, second: ScanningType): ScanningType = returnFirstFound(first, second,
@@ -79,7 +78,7 @@ interface StatsPerIndexer {
interface IndexingTimes {
val indexingReason: String?
val wasFullRescanning: Boolean
val scanningType: ScanningType
val updatingStart: ZonedDateTime
val totalUpdatingTime: TimeNano
val updatingEnd: ZonedDateTime
@@ -50,8 +50,7 @@ class ProjectIndexingHistoryFusReporterListener : ProjectIndexingHistoryListener
ProjectIndexingHistoryFusReporter.reportIndexingFinished(
projectIndexingHistory.project,
projectIndexingHistory.indexingSessionId,
projectIndexingHistory.times.wasFullRescanning,
projectIndexingHistory.scanningType,
projectIndexingHistory.times.scanningType,
projectIndexingHistory.times.totalUpdatingTime.toMillis(),
projectIndexingHistory.times.indexingDuration.toMillis(),
scanningTime,
@@ -139,7 +138,6 @@ object ProjectIndexingHistoryFusReporter : CounterUsagesCollector() {
fun reportIndexingFinished(
project: Project,
indexingSessionId: Long,
wasFullIndexing: Boolean,
scanningType: ScanningType,
totalTime: Long,
indexingTime: Long,
@@ -156,7 +154,7 @@ object ProjectIndexingHistoryFusReporter : CounterUsagesCollector() {
indexingFinished.log(
project,
this.indexingSessionId.with(indexingSessionId),
this.isFullRescanning.with(wasFullIndexing),
this.isFullRescanning.with(scanningType.isFull),
this.scanningType.with(scanningType),
this.totalTime.with(totalTime),
this.indexingTime.with(indexingTime),
@@ -19,8 +19,7 @@ import kotlin.reflect.KMutableProperty1
@ApiStatus.Internal
data class ProjectIndexingHistoryImpl(override val project: Project,
override val indexingReason: String?,
override val scanningType: ScanningType,
private val wasFullRescanning: Boolean) : ProjectIndexingHistory {
private val scanningType: ScanningType) : ProjectIndexingHistory {
private companion object {
val indexingSessionIdSequencer = AtomicLong()
val log = thisLogger()
@@ -32,7 +31,7 @@ data class ProjectIndexingHistoryImpl(override val project: Project,
override val times: IndexingTimes by ::timesImpl
private val timesImpl = IndexingTimesImpl(indexingReason = indexingReason, wasFullRescanning = wasFullRescanning,
private val timesImpl = IndexingTimesImpl(indexingReason = indexingReason, scanningType = scanningType,
updatingStart = ZonedDateTime.now(ZoneOffset.UTC), totalUpdatingTime = System.nanoTime())
override val scanningStatistics = arrayListOf<JsonScanningStatistics>()
@@ -325,7 +324,7 @@ data class ProjectIndexingHistoryImpl(override val project: Project,
data class IndexingTimesImpl(
override val indexingReason: String?,
override val wasFullRescanning: Boolean,
override val scanningType: ScanningType,
override val updatingStart: ZonedDateTime,
override var totalUpdatingTime: TimeNano,
override var updatingEnd: ZonedDateTime = updatingStart,
@@ -84,7 +84,7 @@ fun IndexingFileSetStatistics.IndexedFile.toJson() = JsonFileProviderIndexStatis
fun IndexingTimes.toJson() =
JsonProjectIndexingHistoryTimes(
indexingReason = indexingReason,
wasFullRescanning = wasFullRescanning,
scanningType = scanningType,
totalUpdatingTime = JsonDuration(totalUpdatingTime),
indexingTime = JsonDuration(indexingDuration.toNanos()),
contentLoadingVisibleTime = JsonDuration(contentLoadingVisibleDuration.toNanos()),
@@ -3,12 +3,13 @@ package com.intellij.util.indexing.diagnostic.dto
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonInclude
import com.intellij.util.indexing.diagnostic.ScanningType
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
data class JsonProjectIndexingHistoryTimes(
val indexingReason: String? = null,
val wasFullRescanning: Boolean = false,
val scanningType: ScanningType = ScanningType.FULL,
val totalUpdatingTime: JsonDuration = JsonDuration(),
val indexingTime: JsonDuration = JsonDuration(),
val contentLoadingVisibleTime: JsonDuration = JsonDuration(),
@@ -14,6 +14,7 @@ import com.intellij.util.indexing.diagnostic.JsonSharedIndexDiagnosticEvent
import com.intellij.util.indexing.diagnostic.dto.*
import org.intellij.lang.annotations.Language
import org.jetbrains.annotations.Nls
import java.util.*
fun createAggregateHtml(
projectName: String,
@@ -95,7 +96,7 @@ fun createAggregateHtml(
td(diagnostic.appInfo.productCode + "-" + diagnostic.appInfo.build)
//Indexing type section
td(if (diagnostic.indexingTimes.wasFullRescanning) "Full" else "Partial")
td(diagnostic.indexingTimes.scanningType.name.lowercase(Locale.ENGLISH).replace('_', ' '))
}
}
}
@@ -378,7 +379,7 @@ fun JsonIndexDiagnostic.generateHtml(): String {
if (times.indexingReason != null) {
tr { td("Reason"); td(times.indexingReason) }
}
tr { td("Full or partial"); td(if (times.wasFullRescanning) "full" else "partial") }
tr { td("Type"); td(times.scanningType.name.lowercase(Locale.ENGLISH).replace('_', ' ')) }
tr { td("Finished at"); td(times.updatingEnd.presentableLocalDateTime()) }
tr { td("Cancelled?"); td(times.wasInterrupted.toString()) }
tr { td("Suspended time"); td(times.totalSuspendedTime.presentableDuration()) }
@@ -12,7 +12,7 @@ class ProjectIndexingHistoryImplTest {
@Test
fun `test observation missed the start of suspension (IDEA-281514)`() {
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true)
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL)
val time = Instant.now()
history.stopSuspendingStages(time)
history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time.plusNanos(1))
@@ -27,7 +27,7 @@ class ProjectIndexingHistoryImplTest {
@Test
fun `test there may be actions after suspension`() {
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true)
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL)
val time = Instant.now()
history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time)
history.suspendStages(time.plusNanos(1))
@@ -42,7 +42,7 @@ class ProjectIndexingHistoryImplTest {
@Test
fun `test there may be actions after suspension 2`() {
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true)
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL)
val time = Instant.now()
history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time)
history.suspendStages(time.plusNanos(1))
@@ -58,7 +58,7 @@ class ProjectIndexingHistoryImplTest {
@Test
fun `test there may be actions after suspension 3`() {
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true)
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL)
val time = Instant.now()
history.suspendStages(time)
history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time.plusNanos(1))
@@ -74,7 +74,7 @@ class ProjectIndexingHistoryImplTest {
@Test
fun `test there may be actions after suspension 4`() {
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true)
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL)
val time = Instant.now()
history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time)
history.stopSuspendingStages(time.plusNanos(1))
@@ -89,7 +89,7 @@ class ProjectIndexingHistoryImplTest {
@Test
fun `test there may be actions after suspension 5`() {
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true)
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL)
val time = Instant.now()
history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time.plusNanos(1))
history.stopSuspendingStages(time.plusNanos(2))
@@ -106,7 +106,7 @@ class ProjectIndexingHistoryImplTest {
@Test
fun `test basic workflow`() {
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true)
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL)
val instant = Instant.now()
history.startStage(ProjectIndexingHistoryImpl.Stage.PushProperties, instant)
history.stopStage(ProjectIndexingHistoryImpl.Stage.PushProperties, instant.plusNanos(1))
@@ -122,7 +122,7 @@ class ProjectIndexingHistoryImplTest {
@Test
fun `test stage with suspension inside`() {
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true)
val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL)
val instant = Instant.now()
history.startStage(ProjectIndexingHistoryImpl.Stage.PushProperties, instant)
history.suspendStages(instant.plusNanos(1))
@@ -172,7 +172,7 @@ class DumbServiceImplTest extends BasePlatformTestCase {
def index = FileBasedIndex.getInstance() as FileBasedIndexImpl
new IndexUpdateRunner(index, ConcurrencyUtil.newSameThreadExecutorService(), 1)
.indexFiles(project, Collections.singletonList(new IndexUpdateRunner.FileSet(project, "child", [child])),
indicator, new ProjectIndexingHistoryImpl(getProject(), "Testing", ScanningType.PARTIAL, false))
indicator, new ProjectIndexingHistoryImpl(getProject(), "Testing", ScanningType.PARTIAL))
}
}
catch (ProcessCanceledException e) {
@@ -109,7 +109,7 @@ public class PersistencePerformanceTest extends BasePlatformTestCase {
Thread.sleep(100);
new IndexUpdateRunner(index, UnindexedFilesUpdater.GLOBAL_INDEXING_EXECUTOR, UnindexedFilesUpdater.getNumberOfIndexingThreads())
.indexFiles(getProject(), Collections.singletonList(new IndexUpdateRunner.FileSet(getProject(), "test files", files)),
new EmptyProgressIndicator(), new ProjectIndexingHistoryImpl(getProject(), "Testing", ScanningType.PARTIAL, false));
new EmptyProgressIndicator(), new ProjectIndexingHistoryImpl(getProject(), "Testing", ScanningType.PARTIAL));
}
for (Future<Boolean> future : futures) {
assertTrue(future.get());