Skip to content

Add actions job log buffer and profiler #866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Aug 19, 2025
Merged

Conversation

mattdholloway
Copy link
Contributor

@mattdholloway mattdholloway commented Aug 13, 2025

Extends the get_job_logs tool and other parts of the MCP server that rely on downloading Actions job log data. The new functionality ensures memory leaks do not occur by using a 'sliding window' buffer to only have 5MB of the log in memory at a time as it reads the entire log. This then allows for a tail step after this that retains the correct amount of lines within the final window before completion.

Closes: https://github.com/github/copilot-agent-services/issues/375

@mattdholloway mattdholloway marked this pull request as ready for review August 13, 2025 12:56
@mattdholloway mattdholloway requested a review from a team as a code owner August 13, 2025 12:56
@Copilot Copilot AI review requested due to automatic review settings August 13, 2025 12:56
Copilot

This comment was marked as outdated.

@mattdholloway mattdholloway requested a review from Copilot August 15, 2025 14:16
Copilot

This comment was marked as outdated.

@mattdholloway mattdholloway changed the title Add actions job log buffer Add actions job log buffer and profiler Aug 15, 2025
@mattdholloway mattdholloway requested a review from Copilot August 15, 2025 15:52
Copilot

This comment was marked as outdated.

mattdholloway and others added 3 commits August 15, 2025 16:53
@mattdholloway mattdholloway requested a review from Copilot August 18, 2025 10:45
Copilot

This comment was marked as outdated.

Copy link
Member

@omgitsads omgitsads left a comment

Choose a reason for hiding this comment

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

Are the content_window_size underscores intentionally, or should they be - instead?

@mattdholloway mattdholloway requested a review from Copilot August 18, 2025 14:53
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends the get_job_logs tool with a sliding window buffer mechanism to prevent memory leaks when processing large Actions job log files. The implementation uses a ring buffer that maintains only the last 5MB (configurable) of log data in memory at any time, significantly reducing memory usage while preserving functionality.

Key changes:

  • Added configurable content window size parameter throughout the system
  • Implemented ring buffer log processing to handle large files efficiently
  • Added performance profiling capabilities to measure memory usage improvements

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/github/tools.go Added contentWindowSize parameter to DefaultToolsetGroup and updated GetJobLogs tool instantiation
pkg/github/actions_test.go Updated test calls to include contentWindowSize parameter and added comprehensive memory usage comparison tests
pkg/github/actions.go Modified log processing functions to use ring buffer and added profiling integration
pkg/buffer/buffer.go New ring buffer implementation for efficient log processing with sliding window
internal/profiler/profiler.go New profiling system for measuring memory usage and performance metrics
internal/ghmcp/server.go Added ContentWindowSize configuration field and passed it through server initialization
cmd/github-mcp-server/main.go Added CLI flag for content-window-size configuration
cmd/github-mcp-server/generate_docs.go Updated calls to include default contentWindowSize value

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

if err != nil {
return "", 0, httpResp, fmt.Errorf("failed to read log content: %w", err)
if tailLines <= 0 {
tailLines = 1000
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

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

The magic number 1000 should be defined as a named constant to improve maintainability and make the default value explicit throughout the codebase.

Suggested change
tailLines = 1000
tailLines = DefaultTailLines

Copilot uses AI. Check for mistakes.

return -int64(diff)
}

return int64(after) - int64(before)
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

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

This condition checks if either value exceeds MaxInt64, but since these are uint64 values, they can legitimately be larger than MaxInt64. The logic should handle the conversion more clearly by checking if the difference itself would overflow int64 bounds.

Suggested change
return int64(after) - int64(before)
if after >= before {
diff := after - before
if diff > math.MaxInt64 {
return math.MaxInt64
}
return int64(diff)
}
diff := before - after
if diff > math.MaxInt64 {
return -math.MaxInt64
}
return -int64(diff)

Copilot uses AI. Check for mistakes.

@mattdholloway mattdholloway merged commit 2621dbe into main Aug 19, 2025
16 checks passed
@mattdholloway mattdholloway deleted the actions-job-log-buffer branch August 19, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy