Skip to content

Commit 25452f3

Browse files
yyuuttaaooCopilot
andauthored
refactor process cache management to handle out of order process ebpf events (#2232)
* add basic pod info for process * refactory process cache management to handle out of order events * format * fix * fix consume retry queue crash\nfix memleak due to inproper reuse in clone event * fix shrink size * fix format * fix containerId buffer * Add debug log * fix exit do not clear cache if k8s meta not exist * fix event lost for using circular buffer * fix ebpf_process_secure config reload problem * Use fixed sized common queue to control memory Improve tcmalloc release mem machanism Fix crash when FileFlusher has no permission to write * fix ut * Update core/common/TimeKeeper.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 102bf87 commit 25452f3

File tree

108 files changed

+5068
-1781
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+5068
-1781
lines changed

.clangd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ CompileFlags:
33
- -fgnuc-version=9.3.1
44
- -Wall
55
- -Wextra
6+
# - -fno-access-control # 允许UT访问私有成员
7+
# - -DAPSARA_UNIT_TEST_MAIN # 允许编译UT特殊方法
68
- -I/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/include
79
- -I/opt/logtail/deps/include
810
CompilationDatabase: build

core/_thirdparty/coolbpf

Submodule coolbpf updated from 447bc1f to ba4d1b1

core/application/Application.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "common/MachineInfoUtil.h"
3232
#include "common/RuntimeUtil.h"
3333
#include "common/StringTools.h"
34+
#include "common/TimeKeeper.h"
3435
#include "common/TimeUtil.h"
3536
#include "common/UUIDUtil.h"
3637
#include "common/version.h"
@@ -81,6 +82,7 @@ Application::Application() : mStartTime(time(nullptr)) {
8182
}
8283

8384
void Application::Init() {
85+
TimeKeeper::GetInstance();
8486
// change working dir to ./${ILOGTAIL_VERSION}/
8587
string processExecutionDir = GetProcessExecutionDir();
8688
AppConfig::GetInstance()->SetProcessExecutionDir(processExecutionDir);
@@ -267,9 +269,6 @@ void Application::Start() { // GCOVR_EXCL_START
267269
}
268270

269271
time_t curTime = 0, lastConfigCheckTime = 0, lastUpdateMetricTime = 0, lastCheckTagsTime = 0, lastQueueGCTime = 0;
270-
#ifndef LOGTAIL_NO_TC_MALLOC
271-
time_t lastTcmallocReleaseMemTime = 0;
272-
#endif
273272
while (true) {
274273
curTime = time(NULL);
275274
if (curTime - lastCheckTagsTime >= INT32_FLAG(file_tags_update_interval)) {
@@ -291,9 +290,9 @@ void Application::Start() { // GCOVR_EXCL_START
291290
lastConfigCheckTime = curTime;
292291
}
293292
#ifndef LOGTAIL_NO_TC_MALLOC
294-
if (curTime - lastTcmallocReleaseMemTime >= INT32_FLAG(tcmalloc_release_memory_interval)) {
293+
if (curTime - gLastTcmallocReleaseMemTime >= INT32_FLAG(tcmalloc_release_memory_interval)) {
295294
MallocExtension::instance()->ReleaseFreeMemory();
296-
lastTcmallocReleaseMemTime = curTime;
295+
gLastTcmallocReleaseMemTime = curTime;
297296
}
298297
#endif
299298
if (curTime - lastQueueGCTime >= INT32_FLAG(queue_check_gc_interval_sec)) {
@@ -378,7 +377,7 @@ void Application::Exit() {
378377
FlusherSLS::RecycleResourceIfNotUsed();
379378

380379
CollectionPipelineManager::GetInstance()->ClearAllPipelines();
381-
380+
TimeKeeper::GetInstance()->Stop();
382381
#if defined(_MSC_VER)
383382
ReleaseWindowsSignalObject();
384383
#endif

core/collection_pipeline/plugin/PluginRegistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
DEFINE_FLAG_BOOL(enable_processor_spl, "", true);
7272
DEFINE_FLAG_BOOL(enable_ebpf_network_observer, "", false);
73-
DEFINE_FLAG_BOOL(enable_ebpf_process_secure, "", false);
73+
DEFINE_FLAG_BOOL(enable_ebpf_process_secure, "", true);
7474
DEFINE_FLAG_BOOL(enable_ebpf_file_secure, "", false);
7575
DEFINE_FLAG_BOOL(enable_ebpf_network_secure, "", false);
7676

core/common/CapabilityUtil.cpp

Lines changed: 0 additions & 98 deletions
This file was deleted.

core/common/DynamicLibHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "DynamicLibHelper.h"
1616

17-
#include "Logger.h"
17+
#include "logger/Logger.h"
1818

1919
#if defined(__linux__)
2020
#include <dlfcn.h>

core/common/EncodingUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void Base64Encoding(istream& is, ostream& os, char makeupChar, const char
6565
}
6666
}
6767

68-
string Base64Enconde(const string& message) {
68+
string Base64Encode(const string& message) {
6969
istringstream iss(message);
7070
ostringstream oss;
7171
Base64Encoding(iss, oss, '=', "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");

core/common/EncodingUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020

2121
namespace logtail {
2222

23-
std::string Base64Enconde(const std::string& message);
23+
std::string Base64Encode(const std::string& message);
2424

2525
} // namespace logtail

core/common/LRUCache.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,10 @@ class Cache {
140140
bool tryGet(const Key& kIn, Value& vOut) { return tryGetCopy(kIn, vOut); }
141141

142142
bool tryGetCopy(const Key& kIn, Value& vOut) {
143-
Guard g(lock_);
144-
Value tmp;
145-
if (!tryGetRef_nolock(kIn, tmp)) {
146-
return false;
147-
}
148-
vOut = tmp;
149-
return true;
150-
}
151-
152-
bool tryGetRef(const Key& kIn, Value& vOut) {
153143
Guard g(lock_);
154144
return tryGetRef_nolock(kIn, vOut);
155145
}
146+
156147
/**
157148
* The const reference returned here is only
158149
* guaranteed to be valid till the next insert/delete

0 commit comments

Comments
 (0)