Skip to content

Re-use local build cache between dependency look-ups#2717

Merged
premun merged 1 commit intodotnet:mainfrom
premun:prvysoky/update-dependencies-perf
Jun 28, 2023
Merged

Re-use local build cache between dependency look-ups#2717
premun merged 1 commit intodotnet:mainfrom
premun:prvysoky/update-dependencies-perf

Conversation

@premun
Copy link
Copy Markdown
Member

@premun premun commented Jun 27, 2023

I took a sample problematic scenario from dotnet/sdk which takes a bit over 6 minutes to complete:

darc update-dependencies --channel ".NET Eng - Latest"

I noticed we burn a lot of time querying builds while the cache that we use is too local.
I don't want to make the cache even more long-lived than this PR does as I don't understand the life-cycle of the Remote class within Maestro so it would be too risky to store builds indefinitely.
However, even this change in this PR showed 5x speed-up to about 1 minute 15 seconds.

I think this change is not very invasive and safe to do so I would start with this and see where it gets us.
My reasoning was that the only input to this call is the ID so it's not like "give me only some assets for this ID" so I think it's safe to cache this API call result.

This could have a lot of perf impact across the board though.
We don't need to merge this yet and I could deploy this branch to staging from a branch and measure the E2E test validation duration. I suspect we might see a speed-up there already.

#2681

@premun
Copy link
Copy Markdown
Member Author

premun commented Jun 27, 2023

@riarenas I would appreciate if you could have a look at this one

/// <returns>Async task</returns>
public async Task AddAssetLocationToDependenciesAsync(IEnumerable<DependencyDetail> dependencies)
{
var buildCache = new Dictionary<int, Build>();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am only wondering if asset.BuildId in if (!buildCache.TryGetValue(asset.BuildId, out Build producingBuild)) is unique.. Besides that, seems you found the spot.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the BAR ID of the build that produced the asset. The IDs of the builds should be unique as I believe they come from an auto-increment SQL table column. But these are my guesses, I can confirm.

Copy link
Copy Markdown
Member

@andriipatsula andriipatsula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 1 question

@premun premun merged commit 83c3501 into dotnet:main Jun 28, 2023
@premun premun deleted the prvysoky/update-dependencies-perf branch June 28, 2023 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants