Instgo recompiles instrumentation code on every build, even when source files have not changed. Enable the built-in build cache to skip redundant compilation and reduce build time by more than 50%.
Prerequisites
Before you begin, make sure that you have:
Instgo 1.4.6 or later. For download details, see Instgo tool overview
A local machine or Elastic Compute Service (ECS) instance. You cannot compile in a container
Enable the build cache
Step 1: Download Instgo
Download the Instgo binary for your runtime environment. The following example downloads the Linux AMD64 binary. For other platforms, see Instgo tool overview.
wget "http://arms-apm-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/instgo/instgo-linux-amd64" -O instgoStep 2: Make the binary executable
chmod +x instgoStep 3: Set the cache directory
Specify a directory where Instgo stores compiled artifacts.
# Store cached artifacts in /tmp/go-cache
./instgo set --goCache=/tmp/go-cacheStep 4: Build your Go application
Run the first build. Instgo populates the cache during this build.
./instgo go build main.goAll subsequent builds on the same machine automatically reuse the cached artifacts, reducing total compilation time by more than 50%.
Verify the cache
After the first build completes, run a second build and compare the build times. The second build should finish noticeably faster because Instgo reuses the cached artifacts.
What's next
Instgo tool overview -- Learn about Instgo features and download options for other platforms.