in_tcp: skip emitting an empty event stream when a read has no complete message

Đang mở Phù hợp với người mới
#5,602 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lbarrosby đang làm issue này rồi.

Từ ngày 7/11/2026.

  • #5608 của @lbarrosby — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
ruby
Lĩnh vực
backend, performance

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement
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.

Ngôn ngữ chính
Ruby
Star
13.6k
Fork
1.4k
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
61

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fluent/fluentd

Tất cả issue của fluent/fluentd

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.