perf(watcher): reduce auth cache memory#2126
perf(watcher): reduce auth cache memory#2126ailuntz wants to merge 1 commit intorouter-for-me:mainfrom
Conversation
Summary of ChangesHello, 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 significantly improves the memory performance of the watcher component by strategically reducing the size of its authentication caches. It achieves this by only storing detailed authentication content when debug logging is active and by converting a map of authentication objects into a more memory-efficient set of authentication IDs. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request effectively reduces memory usage in the watcher by making the auth content cache conditional on the debug log level and by optimizing the storage of auth file paths to only store IDs instead of full auth objects. These are great performance improvements. I have one suggestion to further optimize memory usage in the new authIDSet function.
| func authIDSet(auths map[string]*coreauth.Auth) map[string]*coreauth.Auth { | ||
| set := make(map[string]*coreauth.Auth, len(auths)) | ||
| for id := range auths { | ||
| set[id] = nil | ||
| } | ||
| return set |
There was a problem hiding this comment.
This is a good memory optimization. For even better memory efficiency, consider using map[string]struct{}. An empty struct{} is zero-width, while a nil pointer still has a size (e.g., 8 bytes on 64-bit machines).
This would require changing the type of w.fileAuthsByPath to map[string]map[string]struct{} and updating this function to return map[string]struct{}. The call sites would also need to be adjusted.
luispater
left a comment
There was a problem hiding this comment.
Summary:
I did not find any blocking correctness issues in this change. The new ID-only fileAuthsByPath cache is still sufficient for add/delete detection, and full auth-content caching is now correctly limited to debug logging scenarios.
Key findings:
- Blocking: none.
- Non-blocking: there is no targeted regression test for the non-debug path where
lastAuthContentsstays nil andfileAuthsByPathstores ID-only entries. Existing watcher tests give indirect coverage, but a focused test would make this optimization safer to maintain.
Test plan:
go test ./...
Checks considered:
build: passedtranslator-path-guard: intentionally ignored per review instructions
This is an automated Codex review result and still requires manual verification by a human reviewer.
Summary
Testing