-
Notifications
You must be signed in to change notification settings - Fork 1.5k
opt: redesign the truncate effect logic to reduce memory cost in text mode #718 #775
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
Conversation
pkg/event_processor/iworker.go
Outdated
// 输出包 | ||
if ew.tickerCount > MaxTickerCount { | ||
if truncateFlag || ew.tickerCount > MaxTickerCount { |
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 think it is better to move this part into func (ew *eventWorker) writeEvent(e event.IEventStruct)
.
3638bb5
to
559c848
Compare
pkg/event_processor/iworker.go
Outdated
if ew.status != ProcessStateInit { | ||
_ = ew.writeToChan("write events failed, unknow eventWorker status") | ||
return | ||
return false | ||
} | ||
ew.payload.Write(e.Payload()) |
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.
为什么不放在这里获取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
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.
Do you confirm that clearing the payload, moving from parserEvents
to writeEvent
, can optimize memory usage?
Yes, the test steps are as follows
|
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.
LGTM, Thanks.
#718