in_tcp: skip emitting an empty event stream when a read has no complete message
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- ruby
- 领域
- backend, performance
调研方向
Read the in_tcp input path and compare its handling with the existing <extract> path, which the issue says already avoids emitting for an empty stream. Check the relevant input tests and add or adjust coverage for a read that completes no message. Done means router.emit_stream is skipped for an empty event stream while completed messages still reach the router.
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem? Please describe.
Without <extract>, in_tcp calls router.emit_stream(@tag, es) after every read. It does this even when the read did not complete any message and es is empty. A long message arrives in many reads, so the router, the filters and the output are called many times with an empty stream. The output's emit_count counts these calls too.
With the configuration below, I sent one 1 MiB line in 64 writes of 16 KiB:
ruby -rsocket -e 's = TCPSocket.new("127.0.0.1", 5170); 64.times { s.write("x" * 16384); sleep 0.02 }; s.write("\n"); sleep 1'
monitor_agent then shows:
{"plugin_id":"in_tcp","emit_records":1}
{"plugin_id":"out_null","emit_records":1,"emit_count":66}
<source>
@type monitor_agent
bind 127.0.0.1
port 24220
</source>
<source>
@type tcp
@id in_tcp
tag test
port 5170
bind 127.0.0.1
<parse>
@type none
</parse>
</source>
<match test>
@type null
@id out_null
</match>
Describe the solution you'd like
Call router.emit_stream only when es is not empty. The <extract> code path already emits nothing for such a read.
Describe alternatives you've considered
Keep the current behavior. The empty streams do not create buffer chunks, because Buffer#write_once returns early for empty data. The cost is the extra calls and the larger emit_count.
Additional context
Tested with Fluentd 1.20.1 (master at 1d6b1129) and Ruby 4.0.9 on Linux.
- 主要语言
- Ruby
- 星标
- 13.6k
- 派生
- 1.4k
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 61
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fluent/fluentd 的其他 Issue
-
in_tcp, in_syslog: a non-ASCII delimiter closes the connection with Encoding::CompatibilityError可能已有人在做 @1AbdullahButt 于 2 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 42/100
维护者通常 1 天内回复
-
bug enhancement
难度 5/5 一周以上 新手友好度 35/100
fluent/fluentd#5494 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
BufferChunkOverflowError inside @ERROR loops forever - no buffer parameter can stop it可能重新可做 关联的 PR 已关闭且未合并。 未关闭bug
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
<system> umask` / `--umask` is not applied to worker-created files under a foreground supervisor可能重新可做 @mbmtbtbc 于 116 天前认领,目前没有进行中的 PR。 未关闭enhancement
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
activerecord-hackery/ransack#1799 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
rubys/roundhouse#1950 ·
-
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
fastlane/fastlane#30562 · 1 条评论 ·
维护者通常 1 天内回复