Skip to content

fix: optimization issues #125, #127, #126#439

Closed
justrach wants to merge 3 commits intomainfrom
fix/consolidated-optimization-issues
Closed

fix: optimization issues #125, #127, #126#439
justrach wants to merge 3 commits intomainfrom
fix/consolidated-optimization-issues

Conversation

@justrach
Copy link
Copy Markdown
Owner

Summary

Closes #125, Closes #127, Closes #126

…uadratic scans (#125)

- Add file_path_index and symbols_by_file HashMaps to CodeGraph for O(1) lookups
- Replace linear findFileId scan with file_path_index HashMap lookup
- Replace full-symbol scan in symbolAt with per-file symbolsInFile index
- Cache decoded graph in tools.zig across calls with mtime invalidation
- RebuildIndexes after deserialization for loaded graphs
…heState struct (#127)

- Extract all cache globals (g_mu, g_ready, g_has_data, g_labels, g_milestones, g_alloc)
  into a CacheState struct with explicit init/deinit/invalidate lifecycle
- CacheState methods are instance-based, making them testable without globals
- Thin wrapper functions (prefetch, getLabel, getMilestone, isReady, invalidate)
  delegate to a module-level CacheState for backward compatibility
- getState() returns pointer for callers that need direct access
- Tests now use local CacheState instances instead of modifying module globals
- appendLabel/appendMilestone now return errors instead of silently swallowing them
#126)

- Extract src/repo.zig: currentRepo, setCurrentRepo, detectAndUpdateRepo,
  detectViaGitRemote, parseGitHubSlug (110 lines)
- Extract src/graph_tools.zig: handleSymbolAt, handleFindCallers, handleFindCallees,
  handleFindDependents, loadGraph with mtime cache, writeSymbolResultJson,
  writeCallerResultJson (217 lines)
- Update tools.zig to import repo_mod and graph_tools, delegate graph dispatch
- tools.zig reduced from ~2894 to ~2617 lines, with clear domain boundaries
@justrach justrach closed this Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant