-
Notifications
You must be signed in to change notification settings - Fork 38
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
Measure cache hits and misses #169
Measure cache hits and misses #169
Conversation
Attach BuildOperationListener to the Gradle and measure cache hits and misses. This covers local and remote cache. BuildCacheOperationListener listen for two events: ExecuteTaskBuildOperationType (task was executed) and BuildCacheRemoteLoadBuildOperationType (attempt to download remote cache). Summarized information is exposed as ExecutedTasksInfo entity. This information is used by TalaiotPublisherImpl in order to attach cache usage summary to ExecutionReport.Environment and to every task. Inspired by: https://github.com/runningcode/gradle-doctor/blob/321f4d09856aa07ddb2541e205b7684c467d5779/doctor-plugin/src/main/java/com/osacky/doctor/BuildCacheConnectionMeasurer.kt
what do you need in terms of the E2E? |
I want to verify that event I guess that Remote Cache Instance is needed for that. |
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.
Great, excellent work.
Just a couple of minor comments.
I created #171 as we discussed in the issue.
import com.cdsap.talaiot.entities.CacheInfo | ||
import com.cdsap.talaiot.metrics.base.ExecutedTasksMetric | ||
|
||
class CacheHitMetric : ExecutedTasksMetric<BuildCacheUsageStats>( |
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.
name of the file is TaskMetrics, can we change?
} | ||
} | ||
|
||
when (it.remoteCacheInfo) { |
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.
Nice! I have seen cases when there is bad connectivity Gradle disabled the cache mechanism. Is covered in the when +1
/** | ||
* [Metric] that operates on [ExecutedTasksInfo] | ||
*/ | ||
abstract class ExecutedTasksMetric<T>(provider: (ExecutedTasksInfo) -> T, assigner: (ExecutionReport, T) -> Unit): Metric<T, ExecutedTasksInfo>(provider, assigner) |
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.
Can we use ExecutedTasksMetric
as File name?
Attach
BuildOperationListener
to the Gradle build and measure cache hits and misses. This covers both local and remote cache.How it works
BuildCacheOperationListener
listens for two events:ExecuteTaskBuildOperationType
(task was executed) andBuildCacheRemoteLoadBuildOperationType
(attempt to download remote cache). Summarised information is exposed asExecutedTasksInfo
entity. This information is used byTalaiotPublisherImpl
in order to attach cache usage summary toExecutionReport.Environment
and to every task.Inspired by: BuildCacheConnectionMeasurer from gradle-doctor plugin
Automated tests
I covered major parts with unit tests. Unfortunately, I couldn't come up with a proper e2e test. I think it's very important to have such e2e because this functionality relies on Gradle internal implementation. If you can help me and create an e2e test as a separate PR, that would be nice.