opt: redesign the truncate effect logic to reduce memory cost in text mode #718#775
Merged
Conversation
Contributor
Author
yuweizzz
reviewed
May 8, 2025
| truncateFlag := (tsize > 0 && ew.payload.Len() >= tsize) | ||
| // 输出包 | ||
| if ew.tickerCount > MaxTickerCount { | ||
| if truncateFlag || ew.tickerCount > MaxTickerCount { |
Contributor
There was a problem hiding this comment.
I think it is better to move this part into func (ew *eventWorker) writeEvent(e event.IEventStruct).
3638bb5 to
559c848
Compare
cfc4n
requested changes
May 10, 2025
| return | ||
| return false | ||
| } | ||
| ew.payload.Write(e.Payload()) |
Member
There was a problem hiding this comment.
为什么不放在这里获取tzise,而是通过外部传递呢?
建议还原所有代码,之后只保留一下更改。
tsize := int(ew.processor.truncateSize)
//terminal write when reach the truncate size
if tsize > 0 && ew.payload.Len() >= tsize {
ew.payload.Truncate(tsize)
_ = ew.writeToChan(fmt.Sprintf("Events truncated, size: %d bytes\n", tsize))
return true
}
return false
cfc4n
requested changes
May 12, 2025
Member
cfc4n
left a comment
There was a problem hiding this comment.
Do you confirm that clearing the payload, moving from parserEvents to writeEvent, can optimize memory usage?
Contributor
Author
Yes, the test steps are as follows
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#718