-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin for collecting and reporting indexing statistics #14
Draft
odisseus
wants to merge
1
commit into
main
Choose a base branch
from
reporter-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "3.20.1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<idea-plugin> | ||
<id>com.virtuslab.indexing.stats.reporter</id> | ||
<name>Indexing Statistics Reporter</name> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<description>A tool for collecting and reporting indexing statistics</description> | ||
<vendor>Virtus Lab sp. z o.o.</vendor> | ||
|
||
<idea-version since-build="233.0"/> | ||
|
||
<depends>com.intellij.modules.platform</depends> | ||
<depends>com.intellij.properties</depends> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<projectIndexingActivityHistoryListener | ||
implementation="com.virtuslab.indexing.listeners.IndexingStatsReporter"/> | ||
</extensions> | ||
|
||
</idea-plugin> |
11 changes: 11 additions & 0 deletions
11
reporter-plugin/src/main/scala/com/virtuslab/indexing/data/IndexingStats.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.virtuslab.indexing.data | ||
|
||
case class IndexingStats( | ||
startedAt: Long, | ||
finishedAt: Long, | ||
isSharedIndexesEnabled: Boolean, | ||
isIncremental: Boolean, | ||
sharedIndexKindsUsed: Seq[String], | ||
numberOfIndexedFiles: Int, | ||
numberOfFilesCoveredBySharedIndexes: Int | ||
) |
51 changes: 51 additions & 0 deletions
51
reporter-plugin/src/main/scala/com/virtuslab/indexing/listeners/IndexingStatsReporter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.virtuslab.indexing.listeners | ||
|
||
import com.intellij.openapi.util.registry.Registry | ||
import com.intellij.util.indexing.diagnostic.{ | ||
ProjectDumbIndexingHistory, | ||
ProjectIndexingActivityHistoryListener, | ||
ProjectScanningHistory, | ||
SharedIndexDiagnostic | ||
} | ||
import com.virtuslab.indexing.data.IndexingStats | ||
import com.virtuslab.indexing.publish.IndexingStatsLogPublisher | ||
import it.unimi.dsi.fastutil.longs.LongCollection | ||
|
||
import scala.collection.concurrent.TrieMap | ||
import scala.jdk.CollectionConverters._ | ||
|
||
class IndexingStatsReporter extends ProjectIndexingActivityHistoryListener { | ||
private val scanningRecord = new TrieMap[Long, ProjectScanningHistory]() | ||
|
||
override def onFinishedScanning(history: ProjectScanningHistory): Unit = { | ||
scanningRecord += history.getTimes.getScanningId -> history | ||
} | ||
|
||
override def onFinishedDumbIndexing(history: ProjectDumbIndexingHistory): Unit = { | ||
val histories = scanningRecord.view.filterKeys { id => | ||
history.getTimes.getScanningIds.asInstanceOf[LongCollection].contains(id) | ||
} | ||
val numberOfFilesCoveredBySharedIndexes = history.getProviderStatistics.asScala | ||
.map(_.getTotalNumberOfFilesFullyIndexedByExtensions).sum | ||
val numberOfIndexedFiles = history.getProviderStatistics.asScala | ||
.map(_.getTotalNumberOfIndexedFiles).sum | ||
// FIXME read info about shared index kinds | ||
// val sharedIndexEvents = SharedIndexDiagnostic.readEvents(project) | ||
|
||
val isIncremental = histories.values.exists { s => | ||
s.getTimes.getScanningType.name().toLowerCase == "partial" | ||
} | ||
val report: IndexingStats = IndexingStats( | ||
startedAt = history.getTimes.getUpdatingStart.toEpochSecond, | ||
finishedAt = history.getTimes.getUpdatingEnd.toEpochSecond, | ||
isSharedIndexesEnabled = Registry.is("shared.indexes.download"), | ||
isIncremental = isIncremental, | ||
sharedIndexKindsUsed = Seq.empty, | ||
numberOfIndexedFiles = numberOfIndexedFiles, | ||
numberOfFilesCoveredBySharedIndexes = numberOfFilesCoveredBySharedIndexes | ||
) | ||
// TODO add an extension point | ||
IndexingStatsLogPublisher.publish(report) | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
reporter-plugin/src/main/scala/com/virtuslab/indexing/publish/IndexingStatsPublisher.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.virtuslab.indexing.publish | ||
|
||
import com.intellij.openapi.diagnostic.Logger | ||
import com.virtuslab.indexing.data.IndexingStats | ||
|
||
trait IndexingStatsPublisher { | ||
def publish(stats: IndexingStats): Unit | ||
} | ||
|
||
object IndexingStatsLogPublisher extends IndexingStatsPublisher { | ||
|
||
private val logger = Logger.getInstance(classOf[IndexingStatsPublisher]) | ||
override def publish(stats: IndexingStats): Unit = { | ||
// TODO make sure the log format is reasonable | ||
logger.info(stats.toString) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put the duration and shared index utilization too, even though they can be computed. It will be easier to query.
Now that I am thinking, we might want to observe full indexing time (with sannings, as this also takes time and may change), and real indexing time (without pauses, it also shows in the report).