Improve graph build progress logging (fallback + 2s throttle)#3165
Improve graph build progress logging (fallback + 2s throttle)#3165lvca merged 1 commit intoArcadeData:mainfrom
Conversation
Summary of ChangesHello @tae898, 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 enhances the user experience during graph build operations by guaranteeing that progress updates are always visible, even when a custom callback isn't supplied. It implements a default, throttled logging mechanism that provides timely, yet not overly verbose, updates across all stages of the build process, from validation to persistence. This ensures users are kept informed without overwhelming the logs. 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. 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 introduces a fallback progress logger for graph builds, which is throttled to avoid spamming logs. This is a good improvement for observability. All progress reporting phases are now routed through this new mechanism. My review focuses on a potential concurrency issue in the implementation of the throttled logger.
| } else { | ||
| final long[] lastLogTimeMs = {System.currentTimeMillis()}; | ||
| final int[] lastLoggedProcessed = {-1}; | ||
| effectiveGraphCallback = (phase, processedNodes, totalNodes, vectorAccesses) -> { | ||
| if (totalNodes <= 0) | ||
| return; | ||
|
|
||
| final long now = System.currentTimeMillis(); | ||
| final boolean progressed = processedNodes != lastLoggedProcessed[0]; | ||
| final boolean timeElapsed = now - lastLogTimeMs[0] >= 2000; | ||
| final boolean reachedEnd = processedNodes >= totalNodes && lastLoggedProcessed[0] != totalNodes; | ||
| final boolean shouldLog = progressed && (timeElapsed || reachedEnd); | ||
|
|
||
| if (shouldLog) { | ||
| LogManager.instance().log(this, Level.INFO, | ||
| "Graph build %s: %d/%d (vector accesses=%d)", phase, processedNodes, totalNodes, vectorAccesses); | ||
| lastLogTimeMs[0] = now; | ||
| lastLoggedProcessed[0] = processedNodes; | ||
| } | ||
| }; | ||
| } |
There was a problem hiding this comment.
The use of long[] and int[] as mutable containers for lastLogTimeMs and lastLoggedProcessed is not thread-safe. The effectiveGraphCallback is invoked from both the main build thread (during validation) and a separate progress monitor thread (during building). This can lead to race conditions and incorrect throttling behavior. To ensure thread safety, you should use java.util.concurrent.atomic.AtomicLong and java.util.concurrent.atomic.AtomicInteger instead.
Additionally, the throttle duration 2000 is a magic number. It would be better to extract it into a named constant for improved readability and maintainability, for example private static final int BUILD_PROGRESS_LOG_THROTTLE_MS = 2000;.
} else {
final java.util.concurrent.atomic.AtomicLong lastLogTimeMs = new java.util.concurrent.atomic.AtomicLong(System.currentTimeMillis());
final java.util.concurrent.atomic.AtomicInteger lastLoggedProcessed = new java.util.concurrent.atomic.AtomicInteger(-1);
effectiveGraphCallback = (phase, processedNodes, totalNodes, vectorAccesses) -> {
if (totalNodes <= 0)
return;
final long now = System.currentTimeMillis();
final boolean progressed = processedNodes != lastLoggedProcessed.get();
final boolean timeElapsed = now - lastLogTimeMs.get() >= 2000;
final boolean reachedEnd = processedNodes >= totalNodes && lastLoggedProcessed.get() != totalNodes;
final boolean shouldLog = progressed && (timeElapsed || reachedEnd);
if (shouldLog) {
LogManager.instance().log(this, Level.INFO,
"Graph build %s: %d/%d (vector accesses=%d)", phase, processedNodes, totalNodes, vectorAccesses);
lastLogTimeMs.set(now);
lastLoggedProcessed.set(processedNodes);
}
};
}
🧪 CI InsightsHere's what we observed from your CI run for 7ea6a6b. 🟢 All jobs passed!But CI Insights is watching 👀 |
|
Great, thanks! |
(cherry picked from commit 6dbeec9)
#3163
GraphBuildCallback.