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

Make build-image use local environment #553

Open
XAMPPRocky opened this issue Aug 3, 2022 · 3 comments
Open

Make build-image use local environment #553

XAMPPRocky opened this issue Aug 3, 2022 · 3 comments
Labels
area/build-tools Development tooling. kind/cleanup Refactoring code, fixing up documentation, etc priority/low Issues that don't need to be addressed in the near term.

Comments

@XAMPPRocky
Copy link
Collaborator

Currently make's build-image steps does everything required to produce a full release image for Quilkin. This process can be quite long for development work (being optimistic it can be like 20–30 minutes on a i9-9900K with 64GB of RAM, and fresh runs are much longer). I think we should split build-image into build-image and build-release-image. build-image would only build the Quilkin executable and use the local environment instead of a quilkin-build image to reduce overhead of running through docker, and build-release-image would behave like build-image currently does.

@XAMPPRocky XAMPPRocky added kind/cleanup Refactoring code, fixing up documentation, etc area/build-tools Development tooling. priority/low Issues that don't need to be addressed in the near term. labels Aug 3, 2022
@markmandel
Copy link
Contributor

The removal of the debug image building should help with this as well (once #552 is merged, we can tackle that) - but sounds like you are getting dinged by the mac + docker tax (which also sounds like it's worse on a M1? if you are emulating to a x86 architecture.)

It doesn't hit me as much running Docker on Linux (I feel like it doesn't take me nearly as long to build a Docker image on my machine - I should time it though).

Another option from a whole new set of targets is to have dynamic commands that get changed based on a build flag.

For example, in Agones (admittedly I haven't tested this in a while), we have a LOCAL_GO flag that switches out all commands to use the local Go version, rather than go through the build image:

https://github.com/googleforgames/agones/blob/36e97233d65d2ac0024d03a3e90102f0c6650d29/build/Makefile#L172-L182

ifdef LOCAL_GO
	# use local Go tooling, which greatly speeds up incremental rebuilds, in particular on macOS
	# Note that agones.dev must be in GOPATH
	GO_BUILD_LINUX_AMD64=CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(gomod_on) $(go_build_cmd)
	GO_BUILD_WINDOWS_AMD64=GOOS=windows GOARCH=amd64 $(gomod_on) $(go_build_cmd)
	GO_BUILD_DARWIN_AMD64=GOOS=darwin GOARCH=amd64 $(gomod_on) $(go_build_cmd)
	GO_TEST=$(go_test_cmd) -v
	GO_E2E_TEST_ARGS=
	PERF_OUTPUT_DIR=$(build_path)/.perf
	go_build_base_path=$(agones_path)
endif

This can be useful as the dynamic commands can traverse multiple targets.

@XAMPPRocky
Copy link
Collaborator Author

XAMPPRocky commented Aug 3, 2022

but sounds like you are getting dinged by the mac + docker tax (which also sounds like it's worse on a M1? if you are emulating to a x86 architecture.)

FWIW that time measurement was on a x86 Windows 10 machine. For reasons when I'm making deployments it's easier to do it on my Windows machine.

Another thing that should be changed is that build-image builds Quilkin twice, once in debug and once in release. For dev deployments just building release should be enough.

@markmandel
Copy link
Contributor

Another thing that should be changed is that build-image builds Quilkin twice, once in debug and once in release. For dev deployments just building release should be enough.

I think we don't need the debug image anymore and it can be removed entirely - we discussed this a bit in #541 but the debug version was there primarily to enable debug logging since the previous logging library looked at build level for log levels. Since we don't have that as a thing anymore, I think the debug image (and binary?) can be dropped entirely.

markmandel added a commit to markmandel/quilkin that referenced this issue Aug 9, 2022
Several improvements to workflows that flow through the build-image to
improve build and iteration times.

This includes:

We don't need this anymore, so no reason to build it for each
architecture.

I realised that when mixing the `build-image` workflow with local rust
tools, that going between them, they would invalidate each other's
incremental cache, since it was fingerprinted on absolute directories -
drastically expanding build times between iterations.

This drastically improves both the incremental build times of images,
and every other workflow through `build-image`, such as e2e testing.
(`make test-agones` can be used iteratively now).

We only use a few files for the Docker image, so let's ignore everything
else. Took the docker context down from 1GB+ to < 50MB.

On a linux machine all this brings incremental builds down from 10's of
minutes to a minute or less, since only what has changed is compiled and
pushed as we can now take advantage of rust incremental build and
docker image caching.

Work on googleforgames#553
markmandel added a commit to markmandel/quilkin that referenced this issue Aug 9, 2022
Several improvements to workflows that flow through the build-image to
improve build and iteration times.

This includes:

We don't need this anymore, so no reason to build it for each
architecture.

I realised that when mixing the `build-image` workflow with local rust
tools, that going between them, they would invalidate each other's
incremental cache, since it was fingerprinted on absolute directories -
drastically expanding build times between iterations.

This drastically improves both the incremental build times of images,
and every other workflow through `build-image`, such as e2e testing.
(`make test-agones` can be used iteratively now).

We only use a few files for the Docker image, so let's ignore everything
else. Took the docker context down from 1GB+ to < 50MB.

On a linux machine all this brings incremental builds down from 10's of
minutes to a minute or less, since only what has changed is compiled and
pushed as we can now take advantage of rust incremental build and
docker image caching.

Work on googleforgames#553
markmandel added a commit that referenced this issue Aug 9, 2022
* Improve build-image incremental workflow

Several improvements to workflows that flow through the build-image to
improve build and iteration times.

This includes:

We don't need this anymore, so no reason to build it for each
architecture.

I realised that when mixing the `build-image` workflow with local rust
tools, that going between them, they would invalidate each other's
incremental cache, since it was fingerprinted on absolute directories -
drastically expanding build times between iterations.

This drastically improves both the incremental build times of images,
and every other workflow through `build-image`, such as e2e testing.
(`make test-agones` can be used iteratively now).

We only use a few files for the Docker image, so let's ignore everything
else. Took the docker context down from 1GB+ to < 50MB.

On a linux machine all this brings incremental builds down from 10's of
minutes to a minute or less, since only what has changed is compiled and
pushed as we can now take advantage of rust incremental build and
docker image caching.

Work on #553

* Fix issue with site generation.
markmandel added a commit to markmandel/quilkin that referenced this issue Aug 9, 2022
Sometimes it's just faster and easier to build locally and create images
and binaries that way, rather than use the build image.

This could potentially be extended to running tests as well, but limited
it to building artifacts for now.

Work on googleforgames#553
markmandel added a commit to markmandel/quilkin that referenced this issue Aug 9, 2022
Sometimes it's just faster and easier to build locally and create images
and binaries that way, rather than use the build image.

This could potentially be extended to running tests as well, but limited
it to building artifacts for now.

Work on googleforgames#553
XAMPPRocky added a commit that referenced this issue Aug 12, 2022
Sometimes it's just faster and easier to build locally and create images
and binaries that way, rather than use the build image.

This could potentially be extended to running tests as well, but limited
it to building artifacts for now.

Work on #553

Co-authored-by: XAMPPRocky <4464295+XAMPPRocky@users.noreply.github.com>
XAMPPRocky pushed a commit that referenced this issue Aug 22, 2022
* Improve build-image incremental workflow

Several improvements to workflows that flow through the build-image to
improve build and iteration times.

This includes:

We don't need this anymore, so no reason to build it for each
architecture.

I realised that when mixing the `build-image` workflow with local rust
tools, that going between them, they would invalidate each other's
incremental cache, since it was fingerprinted on absolute directories -
drastically expanding build times between iterations.

This drastically improves both the incremental build times of images,
and every other workflow through `build-image`, such as e2e testing.
(`make test-agones` can be used iteratively now).

We only use a few files for the Docker image, so let's ignore everything
else. Took the docker context down from 1GB+ to < 50MB.

On a linux machine all this brings incremental builds down from 10's of
minutes to a minute or less, since only what has changed is compiled and
pushed as we can now take advantage of rust incremental build and
docker image caching.

Work on #553

* Fix issue with site generation.
XAMPPRocky added a commit that referenced this issue Aug 22, 2022
Sometimes it's just faster and easier to build locally and create images
and binaries that way, rather than use the build image.

This could potentially be extended to running tests as well, but limited
it to building artifacts for now.

Work on #553

Co-authored-by: XAMPPRocky <4464295+XAMPPRocky@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build-tools Development tooling. kind/cleanup Refactoring code, fixing up documentation, etc priority/low Issues that don't need to be addressed in the near term.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants