This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Allow line-log circling #74
Open
typeless
wants to merge
1
commit into
drone:master
Choose a base branch
from
typeless:circ-log-buf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one issue is that this will not place any restrictions on the size of the logs that are streamed (in real time) to the server which stores the stream in memory. Storing the stream in memory (for dozens or even hundreds of concurrent builds) is not an issue because the size of the logs are limited (e.g. 100 concurrent builds cannot use more than 500mb ram on the server). When this limit is removed it presents an opportunity to overload the server memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bradrydzewski As I understand it, every time
append
needs more space than the slice current has, it will allocate a new one and copy the content of the old slice to it. Then the memory chunk of the old slice can be recycled. The lines (pointers) not copied to the new space are dead and can be recycled too. So thecap
of the slice keeps under the limit.https://play.golang.org/p/-3SZNMLs_5h
https://github.com/golang/go/blob/master/src/runtime/slice.go#L76-L191
That said, there might be something I am missing, and only actual measurement can make sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some simplified test:
As expected, the peak memory does not grow to 1GB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is testing the agent. I am speaking of the server-side package that stores the streams in-memory at https://github.com/drone/drone/tree/master/livelog.
The circular buffer does not restrict the size of logs pushed to the server (this line) and therefore allows unbounded log lines to accumulate. In 2013 (in a very early prototype of Drone) a single build generated 120mb log file and took down our server. With no limit to the stream, the server would be susceptible to this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand what you mean now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just had a look at it.
It seems that the stream logger has done something similar
(https://github.com/drone/drone/blob/master/livelog/stream.go#L43-L57) to avoid unbounded log lines.
About the channel subscribers, I can find only one in the live_log test.
https://github.com/drone/drone/blob/master/livelog/livelog.go#L79
I am not 100% confident, though.