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
feat: cache incomplete line in memory to avoid repeat read from disk #1142
Conversation
@@ -371,7 +374,8 @@ void LogFileReader::adjustParametersByRangeCheckpoints() { | |||
return lhs->data.read_offset() < rhs->data.read_offset(); | |||
}); | |||
auto& firstCpt = uncommittedCheckpoints.front()->data; | |||
mLastReadPos = mLastFilePos = firstCpt.read_offset(); | |||
mLastFilePos = firstCpt.read_offset(); |
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.
ExactlyOnce是否有测试保证?
APSARA_TEST_FALSE_FATAL(moreData); | ||
APSARA_TEST_EQUAL_FATAL(0UL, reader2.mCache.size()); | ||
reader1.DumpMetaToMem(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.
配置变更场景模拟下用例,在checkpoint中,恢复后继续能够读取,保证数据连续性
reader.ReadGBK(logBuffer, fileSize, moreData); | ||
APSARA_TEST_TRUE_FATAL(moreData); | ||
std::string expectedPart(expectedContent.get()); | ||
expectedPart.resize(expectedPart.rfind("iLogtail") - 1); | ||
APSARA_TEST_STREQ_FATAL(expectedPart.c_str(), logBuffer.rawBuffer.data()); | ||
// second read | ||
APSARA_TEST_GE_FATAL(reader.mCache.size(), 0UL); |
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.
第一次读有缓存,第二次读续上这种是不是没有用例?
活跃的磁盘缓存会被容器记入内存占用。ilogtail原来重复读取一个位置的行为会将缓存标记活跃,从而使被采集的容器内存上涨,该补丁应该可以大幅减缓这一现象。
TEST: