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

use goderive to generate deepcopy code #636

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

ndeloof
Copy link
Collaborator

@ndeloof ndeloof commented Jun 6, 2024

This replaces copystructyre (based on reflection) with deepcopy code generated by goderive

compose project loading pipeline being a mess, we mutate the project in a few places and need a full copy of it. This has terrible impact when it comes to large compose project:

$ docker compose version
Docker Compose version v2.27.1

$ time docker compose ps nginx23
NAME             IMAGE          COMMAND                  SERVICE   CREATED       STATUS                PORTS
toti-nginx23-1   nginx:1.22.1   "/docker-entrypoint.…"   nginx23   7 hours ago   Up 7 hours (Paused)   80/tcp

real	0m2.638s
user	0m3.170s
sys	0m0.149s


# With this PR
$ docker compose version
Docker Compose version v2.27.1-4-g02f40eea6.m

$ time docker compose ps nginx23
NAME             IMAGE          COMMAND                  SERVICE   CREATED       STATUS                PORTS
toti-nginx23-1   nginx:1.22.1   "/docker-entrypoint.…"   nginx23   7 hours ago   Up 7 hours (Paused)   80/tcp

real	0m0.905s
user	0m0.210s
sys	0m0.082s

I had to fork the original project so Extensions can define a custom DeepCopy method and we are not stuck my interface{} not being a supported type

fixes docker/compose#11881

@ndeloof ndeloof marked this pull request as ready for review June 6, 2024 14:58
Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

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

@ndeloof ndeloof requested review from jhrotko and laurazard June 7, 2024 05:39
} else {
dst.Extensions = nil
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

damn

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm happy I didn't had to write this by hand :)

Copy link
Collaborator

@jhrotko jhrotko left a comment

Choose a reason for hiding this comment

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

LGTM

@ndeloof ndeloof merged commit 27c7848 into compose-spec:main Jun 7, 2024
8 checks passed
@ndeloof ndeloof deleted the goderive branch June 7, 2024 08:55
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.

[BUG] Massive performance degradation of "ps [SERVICE]" command since 2.24.0
3 participants