Skip to content

use goderive to generate deepcopy code#636

Merged
ndeloof merged 1 commit intocompose-spec:mainfrom
ndeloof:goderive
Jun 7, 2024
Merged

use goderive to generate deepcopy code#636
ndeloof merged 1 commit intocompose-spec:mainfrom
ndeloof:goderive

Conversation

@ndeloof
Copy link
Copy Markdown
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

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof marked this pull request as ready for review June 6, 2024 14:58
Copy link
Copy Markdown
Collaborator

@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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

damn

Copy link
Copy Markdown
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
Copy Markdown
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
@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