From 58fce33e0bc32ff5eec3b60f947730e2108729fb Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 9 Apr 2026 13:13:51 -0600 Subject: [PATCH] in_tail: drop redundant fstat on event collection The event collection path in in_tail_collect_event() performed an early fstat() only to remove the file on failure, then immediately called flb_tail_file_chunk(), which already reaches adjust_counters() and does its own fstat()-based validation and counter update. Removing the pre-check reduces one fstat() per event-driven collection cycle without changing truncation, rotation, deletion, or pending-byte handling. Those behaviors remain in the backend-specific handlers and in adjust_counters(). This change is intentionally narrow and is based on a conversation about Fluent Bit tail syscall cost with Fabian Ponce from OpenAI (@FabianPonce). Verification: - cmake -S . -B build -DFLB_TESTS_RUNTIME=On -DFLB_TESTS_INTERNAL=On - cmake --build build -j8 --target flb-rt-in_tail - ./build/bin/flb-rt-in_tail inotify_watcher_false - ./build/bin/flb-rt-in_tail db Signed-off-by: Eduardo Silva --- plugins/in_tail/tail.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/plugins/in_tail/tail.c b/plugins/in_tail/tail.c index 1128c120094..40373f5c184 100644 --- a/plugins/in_tail/tail.c +++ b/plugins/in_tail/tail.c @@ -340,15 +340,8 @@ static int in_tail_watcher_callback(struct flb_input_instance *ins, int in_tail_collect_event(void *file, struct flb_config *config) { int ret; - struct stat st; struct flb_tail_file *f = file; - ret = fstat(f->fd, &st); - if (ret == -1) { - flb_tail_file_remove(f); - return 0; - } - ret = flb_tail_file_chunk(f); switch (ret) { case FLB_TAIL_ERROR: