perf(artifacts): use pageSize=1 when resolving prior artifacts (#2955) #2990
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.
This is a smaller-scoped attempt at
#2938, which relates to
spinnaker/spinnaker#4367.
ArtifactResolver.resolveArtifacts(Map)
currently attempts to loadall executions for a pipeline in order to find the most recent
execution in the course of resolving expected artifacts. This causes a
lot of unnecessary data to be loaded from Redis/SQL, only to be
discarded a few operations later.
This change makes use of the fact that the ExecutionRepository
implementations will respect the
executionCriteria.pageSize
argumentwhen retrieving Execitions for a pipelineId.
In the Redis-based implementation, the executions are stored in a sorted
set scored on
buildTime
(orcurrentTimeMillis()
ifbuildTime
isnull), so retrieving all of the executions for the pipelineId with a
pageSize=1 should load the Execution with the most recent
buildTime
.In the SQL-based implementation,
retrievePipelinesForPipelineConfigId(String, ExecutionCriteria)
sortsthe query results based on the
id
field.For both implementations, this is a small change from the existing
behavior of ArtifactResolver, which retrieves all executions and then
uses the one with the most recent
startTime
(orid
). This changeseems like it will lead to the same result in most cases though, since
buildTime is set when the Execution is stored, and the
id
field isascending based on the timestamp of when it is generated.
The
retrievePipelinesForPipelienConfigId
method in bothimplementations currently ignores the
executionCriteria.sortType
field, but I've added this in the call from ArtifactResolver to at
least document ArtifactResolver's desire.