Skip to content

Conversation

@Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Dec 3, 2025

This commit optimizes Docker cache mounting for the linter with a CI-aware strategy:

Local development (macOS/Windows): Uses Docker named volumes which keep data inside Docker's native Linux filesystem, avoiding the slow host-syncing overhead of bind mounts. This yields ~21x faster linting on warm cache.

CI (GitHub Actions): Uses bind mounts to host paths (~/.cache/go-build, ~/go/pkg/mod) that GitHub Actions already caches via the setup-go action. This ensures CI benefits from cached dependencies across runs.

The Makefile detects CI mode via the CI environment variable that GitHub Actions sets automatically.

Local benchmark results:

  • Cold run (empty cache): ~2m 28s
  • Warm run (cached): ~11s (~21x faster)

Key improvements in warm runs:

  • Go packages loading: 1m 58s → 5.6s
  • Linters execution: 20.5s → 2.7s
  • Total execution: 2m 20s → 8.6s

This should keep CI the same, while dramatically speeding up lint time locally (at least on mac).

@Roasbeef Roasbeef added the golang/build system Related to the go language and compiler label Dec 3, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @Roasbeef, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a strategic optimization to the Docker-based linting process, significantly improving the local development experience on macOS and Windows by leveraging Docker named volumes for caching. This change drastically reduces linting times for warm caches without impacting the efficiency of CI pipelines, which continue to utilize existing GitHub Actions caching mechanisms. The Makefile has been updated to dynamically apply the correct caching strategy based on the execution environment.

Highlights

  • Optimized Docker Cache Mounting: Implemented a dual-strategy for Docker cache mounting in the linter, differentiating between CI and local development environments to maximize performance.
  • Significant Local Performance Boost: Switched local linting to use Docker named volumes, resulting in approximately 21x faster warm cache linting on macOS/Windows by avoiding slow host-syncing overhead.
  • CI Cache Preservation: Maintained existing CI performance by continuing to use bind mounts to host paths that GitHub Actions already caches, ensuring no regression in CI build times.
  • CI Detection: The Makefile now intelligently detects the CI environment using the CI environment variable to apply the appropriate caching strategy automatically.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a smart caching strategy for the Docker-based linter, using named volumes for faster local builds and bind mounts for CI environments to leverage existing caching mechanisms. The implementation is clean and well-commented. My review includes one suggestion to add a make target for cleaning up the newly introduced Docker named volumes, which would help developers manage disk space and ensure a clean build environment when needed.

Comment on lines +88 to +90
-v lnd-go-build-cache:/tmp/build/.cache \
-v lnd-go-mod-cache:/tmp/build/.modcache \
-v lnd-go-lint-cache:/root/.cache/golangci-lint \

Choose a reason for hiding this comment

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

medium

With the introduction of named Docker volumes for local development, it would be beneficial to also add a make target to clean them up. These volumes will persist on the user's machine and can grow in size over time. A developer might want to clear them to start from a clean slate or to free up disk space.

You could add a new target like this:

.PHONY: clean-docker-volumes
clean-docker-volumes:
	@$(call print, "Removing Docker cache volumes.")
	docker volume rm lnd-go-build-cache lnd-go-mod-cache lnd-go-lint-cache || true

This would improve the developer experience by providing a managed way to handle these new resources.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think adding this cleanup also makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will addd

@Roasbeef Roasbeef changed the title make: use Docker named volumes for ~21x faster local linting make: use Docker named volumes for ~21x faster local linting (Mac OS) Dec 3, 2025
Copy link
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

LGTM, my mac is generally super fast so I did not immediately saw the improvement but also not deterioration therefore if it works for other people let's use named volumes.

This commit optimizes Docker cache mounting for the linter with a
CI-aware strategy:

**Local development (macOS/Windows)**: Uses Docker named volumes which
keep data inside Docker's native Linux filesystem, avoiding the slow
host-syncing overhead of bind mounts. This yields ~21x faster linting
on warm cache.

**CI (GitHub Actions)**: Uses bind mounts to host paths (`~/.cache/go-build`,
`~/go/pkg/mod`) that GitHub Actions already caches via the setup-go
action. This ensures CI benefits from cached dependencies across runs.

The Makefile detects CI mode via the `CI` environment variable that
GitHub Actions sets automatically.

Local benchmark results:
- Cold run (empty cache): ~2m 28s
- Warm run (cached): ~11s (~21x faster)

Key improvements in warm runs:
- Go packages loading: 1m 58s → 5.6s
- Linters execution: 20.5s → 2.7s
- Total execution: 2m 20s → 8.6s
@Roasbeef Roasbeef merged commit ea5466a into lightningnetwork:master Dec 10, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

golang/build system Related to the go language and compiler no-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants