Skip to content
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

Refactor builder and drivers info logic #1430

Merged
merged 3 commits into from
Dec 6, 2022

Conversation

crazy-max
Copy link
Member

@crazy-max crazy-max commented Nov 28, 2022

Moves builder and drivers info logic from commands pkg to a dedicated client pkg so we can easily interact with builders and drivers. Refactoring reduced latency for operations when loading drivers data or checking already validated endpoints:

# before
$ time docker buildx ls
...
real    0m5.396s
user    0m0.180s
sys     0m0.796s

# after
$ time docker buildx ls
real    0m3.460s
user    0m0.176s
sys     0m0.881s

Added some TODOs as there is still room for improvements.

Copy link
Collaborator

@jedevc jedevc left a comment

Choose a reason for hiding this comment

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

I like the refactor 🎉 - left a couple comments.

I'm curious, I can't quite see where the performance improvement has come from 👀

builder/driver.go Outdated Show resolved Hide resolved
builder/builder.go Show resolved Hide resolved
builder/driver.go Outdated Show resolved Hide resolved
@crazy-max

This comment was marked as resolved.

@crazy-max crazy-max changed the title [WIP] Refactor builder and drivers info logic Refactor builder and drivers info logic Nov 30, 2022
@crazy-max crazy-max force-pushed the builder-pkg branch 3 times, most recently from e4df400 to 1062c23 Compare November 30, 2022 14:02
@crazy-max crazy-max added this to the v0.10 milestone Nov 30, 2022
@crazy-max crazy-max marked this pull request as ready for review November 30, 2022 14:13
@crazy-max crazy-max added kind/enhancement New feature or request area/driver labels Dec 3, 2022
@crazy-max crazy-max requested a review from jedevc December 5, 2022 21:18
Copy link
Collaborator

@jedevc jedevc left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor function rename :)

build/build.go Outdated

func filterAvailableDrivers(drivers []DriverInfo) ([]DriverInfo, error) {
out := make([]DriverInfo, 0, len(drivers))
func filterAvailableDrivers(nodes []builder.Node) ([]builder.Node, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func filterAvailableDrivers(nodes []builder.Node) ([]builder.Node, error) {
func filterAvailableNodes(nodes []builder.Node) ([]builder.Node, error) {

Comment on lines +60 to +61
func(i int, n store.Node) {
eg.Go(func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

The code would be easier to read if at least one of these annonymous function was tunred into a mehtod.

Copy link
Member Author

@crazy-max crazy-max Dec 6, 2022

Choose a reason for hiding this comment

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

Copy link
Contributor

@errordeveloper errordeveloper left a comment

Choose a reason for hiding this comment

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

Thanks a lot, this is a significant improvement! I might follow up with a few more things, as I'm trying to use some of the same functions in another project.

@crazy-max crazy-max merged commit b242e32 into docker:master Dec 6, 2022
@crazy-max crazy-max deleted the builder-pkg branch December 6, 2022 11:41
if b.err == nil && err != nil {
b.err = err
}
_, _ = b.LoadNodes(timeoutCtx, true)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this ignoring the error instead of setting it to the builder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/driver kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants