Skip to content

Instantly share code, notes, and snippets.

@ganmacs
Created August 14, 2019 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ganmacs/a620be919851d49bff3bf2de58da2052 to your computer and use it in GitHub Desktop.
Save ganmacs/a620be919851d49bff3bf2de58da2052 to your computer and use it in GitHub Desktop.
require 'socket'
HOST = 'localost'
N1 = 2
N2 = 10
MSG = "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest\n"
def run
@stop = false
Signal.trap("INT") do
@stop = true
end
ts = N1.times.map do |i|
Thread.new do
s = TCPSocket.new(HOST, 10000)
begin
loop do
50.times do
s.write(MSG)
end
s.sync
sleep 0.01
if @stop
break
end
end
ensure
s.close
end
end
end
ts.each(&:join)
end
run
<source>
@type tcp
format none
bind 0.0.0.0
port 10000
tag test
</source>
<source>
@type stackprof
</source>
<match test>
@type null
<buffer>
@type memory
</buffer>
</match>
==================================
Mode: cpu(1000)
Samples: 9422 (0.32% miss rate)
GC: 442 (4.69%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
4597 (48.8%) 790 (8.4%) Fluent::Plugin::Buffer#write
1052 (11.2%) 787 (8.4%) Fluent::EventStream#to_msgpack_stream
6422 (68.2%) 652 (6.9%) Fluent::Plugin::Output#handle_stream_simple
534 (5.7%) 534 (5.7%) MonitorMixin#mon_enter
2992 (31.8%) 456 (4.8%) Fluent::Plugin::Buffer#write_once
442 (4.7%) 442 (4.7%) (garbage collection)
573 (6.1%) 420 (4.5%) Fluent::EventTime.now
358 (3.8%) 358 (3.8%) MonitorMixin#mon_enter
300 (3.2%) 300 (3.2%) BasicSocket#read_nonblock
277 (2.9%) 277 (2.9%) MonitorMixin#mon_enter
258 (2.7%) 258 (2.7%) Fluent::EventTime#to_msgpack_ext
8299 (88.1%) 257 (2.7%) Fluent::Plugin::TcpInput#start
255 (2.7%) 255 (2.7%) MonitorMixin#mon_check_owner
211 (2.2%) 211 (2.2%) Fluent::Plugin::OwnedByMixin#log
574 (6.1%) 192 (2.0%) Fluent::Plugin::Buffer#add_metadata
182 (1.9%) 182 (1.9%) Fluent::Plugin::Buffer::MemoryChunk#commit
221 (2.3%) 178 (1.9%) Fluent::Plugin::Buffer::MemoryChunk#concat
167 (1.8%) 167 (1.8%) Fluent::OneEventStream#size
417 (4.4%) 162 (1.7%) MonitorMixin#mon_exit
160 (1.7%) 160 (1.7%) Fluent::Plugin::Buffer#new_metadata
893 (9.5%) 151 (1.6%) Fluent::Plugin::Output#metadata
147 (1.6%) 147 (1.6%) Fluent::Plugin::Buffer::MemoryChunk#bytesize
141 (1.5%) 141 (1.5%) Fluent::EventTime#initialize
137 (1.5%) 137 (1.5%) Fluent::EventRouter::MatchCache#get
136 (1.4%) 136 (1.4%) MonitorMixin#mon_check_owner
135 (1.4%) 135 (1.4%) #<Module:0x00005648564ad8d8>.thread_local_msgpack_packer
133 (1.4%) 133 (1.4%) MonitorMixin#mon_check_owner
8723 (92.6%) 122 (1.3%) Coolio::Loop#run
84 (0.9%) 84 (0.9%) Fluent::OneEventStream#initialize
123 (1.3%) 81 (0.9%) Fluent::Plugin::Buffer#chunk_size_full?
210 (2.2%) 74 (0.8%) MonitorMixin#mon_exit
71 (0.8%) 71 (0.8%) Fluent::Plugin::Buffer::Chunk#staged?
68 (0.7%) 68 (0.7%) Fluent::Plugin::Output#generate_format_proc
190 (2.0%) 57 (0.6%) MonitorMixin#mon_exit
56 (0.6%) 56 (0.6%) Fluent::Log#on_trace
76 (0.8%) 54 (0.6%) Fluent::Plugin::Output#submit_flush_once
7395 (78.5%) 47 (0.5%) Fluent::EventRouter#emit
46 (0.5%) 46 (0.5%) Fluent::Plugin::Buffer#storable?
7119 (75.6%) 45 (0.5%) #<Fluent::Plugin::NullOutput:0x0000564856a3b8b8>.emit_buffered
45 (0.5%) 45 (0.5%) #<Module:0x0000564855f2c3c8>.generate
43 (0.5%) 43 (0.5%) Fluent::Plugin::Buffer::Chunk#writable?
78 (0.8%) 42 (0.4%) Fluent::Plugin::Buffer#dequeue_chunk
282 (3.0%) 39 (0.4%) Fluent::Plugin::Buffer#queued?
37 (0.4%) 37 (0.4%) Fluent::PluginHelper::Extract#extract_tag_from_record
34 (0.4%) 34 (0.4%) Fluent::PluginHelper::EventEmitter#router
255 (2.7%) 34 (0.4%) Fluent::Plugin::Output#flush_thread_run
24 (0.3%) 24 (0.3%) Fluent::Plugin::Buffer::MemoryChunk#empty?
23 (0.2%) 23 (0.2%) Fluent::Plugin::Buffer::Chunk#unstaged?
190 (2.0%) 22 (0.2%) Fluent::Plugin::Output#try_flush
56 (0.6%) 21 (0.2%) Fluent::Plugin::Buffer#chunk_size_over?
19 (0.2%) 19 (0.2%) #<Module:0x000056485638c5d0>.now_raw
17 (0.2%) 17 (0.2%) #<Module:0x0000564855f2c3c8>.hex
35 (0.4%) 17 (0.2%) Fluent::Plugin::Buffer#enqueue_chunk
17 (0.2%) 17 (0.2%) Fluent::Plugin::Output::FlushThreadState#next_clock=
46 (0.5%) 15 (0.2%) Fluent::Plugin::Buffer#purge_chunk
15 (0.2%) 15 (0.2%) MonitorMixin#mon_initialize
20 (0.2%) 13 (0.1%) Fluent::Plugin::Output#next_flush_time
153 (1.6%) 12 (0.1%) Fluent::EventTime.from_time
10 (0.1%) 10 (0.1%) Fluent::Log#trace
1837 (19.5%) 8 (0.1%) MonitorMixin#mon_synchronize
742 (7.9%) 8 (0.1%) Fluent::Plugin::Buffer#metadata
122 (1.3%) 8 (0.1%) Fluent::EventStream#empty?
8 (0.1%) 8 (0.1%) Fluent::Config::Section#method_missing
938 (10.0%) 7 (0.1%) Fluent::OneEventStream#each
6 (0.1%) 6 (0.1%) Fluent::Plugin::Buffer::Chunk#purge
2181 (23.1%) 5 (0.1%) MonitorMixin#mon_synchronize
6427 (68.2%) 5 (0.1%) Fluent::Plugin::Output#execute_chunking
11 (0.1%) 5 (0.1%) Fluent::Plugin::Buffer::MemoryChunk#purge
7264 (77.1%) 4 (0.0%) Fluent::EventRouter#emit_stream
141 (1.5%) 4 (0.0%) Fluent::EventRouter#match
50 (0.5%) 4 (0.0%) Fluent::Plugin::Output#commit_write
4 (0.0%) 4 (0.0%) Fluent::Plugin::Buffer::Chunk#enqueued!
5110 (54.2%) 3 (0.0%) Fluent::Plugin::Output#write_guard
8109 (86.1%) 3 (0.0%) Fluent::Plugin::NoneParser#parse
535 (5.7%) 3 (0.0%) MonitorMixin#mon_synchronize
63 (0.7%) 3 (0.0%) Fluent::Plugin::Buffer::Chunk#initialize
1189 (12.6%) 2 (0.0%) block in <class:Output>
65 (0.7%) 2 (0.0%) Fluent::Plugin::Buffer::MemoryChunk#initialize
2 (0.0%) 2 (0.0%) Fluent::Plugin::Buffer::Chunk#staged!
1 (0.0%) 1 (0.0%) #<Module:0x0000564856a57130>.getservername
8601 (91.3%) 1 (0.0%) Coolio::IO#on_readable
8 (0.1%) 1 (0.0%) Fluent::Plugin::Output#check_slow_flush
1 (0.0%) 1 (0.0%) Fluent::Plugin::Buffer#del_timekey
1 (0.0%) 1 (0.0%) Fluent::EngineClass#run
1 (0.0%) 1 (0.0%) Coolio::IO#close
1 (0.0%) 0 (0.0%) block in <module:Config>
1 (0.0%) 0 (0.0%) #<Module:0x0000564856a804b8>.setup_params
1 (0.0%) 0 (0.0%) WEBrick::HTTPServer#access_log
1 (0.0%) 0 (0.0%) WEBrick::HTTPServer#run
1 (0.0%) 0 (0.0%) WEBrick::GenericServer#start_thread
4178 (44.3%) 0 (0.0%) #<Fluent::PluginHelper::Server::EventHandler::TCPServer:0x0000564856ceb428>.on_read_with_connection
8601 (91.3%) 0 (0.0%) Coolio::IO::Watcher#on_readable
8723 (92.6%) 0 (0.0%) Fluent::PluginHelper::EventLoop#start
8723 (92.6%) 0 (0.0%) Fluent::PluginHelper::Thread#thread_create
4121 (43.7%) 0 (0.0%) #<Fluent::PluginHelper::Server::EventHandler::TCPServer:0x0000564856cd40e8>.on_read_with_connection
255 (2.7%) 0 (0.0%) Fluent::Plugin::Output#start
255 (2.7%) 0 (0.0%) Fluent::PluginHelper::Thread#thread_create
16 (0.2%) 0 (0.0%) Fluent::UniqueId::Mixin#dump_unique_id_hex
19 (0.2%) 0 (0.0%) #<Module:0x000056485638c5d0>.now
45 (0.5%) 0 (0.0%) Fluent::UniqueId::Mixin#generate_unique_id
==================================
Mode: cpu(1000)
Samples: 8014 (0.26% miss rate)
GC: 621 (7.75%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
621 (7.7%) 621 (7.7%) (garbage collection)
3746 (46.7%) 570 (7.1%) Fluent::Plugin::Buffer#write
5313 (66.3%) 565 (7.1%) Fluent::Plugin::Output#handle_stream_simple
1080 (13.5%) 561 (7.0%) Fluent::EventStream#to_msgpack_stream
439 (5.5%) 439 (5.5%) MonitorMixin#mon_enter
518 (6.5%) 385 (4.8%) Fluent::EventTime.now
2446 (30.5%) 326 (4.1%) Fluent::Plugin::Buffer#write_once
6900 (86.1%) 244 (3.0%) Fluent::Plugin::TcpInput#start
241 (3.0%) 241 (3.0%) MonitorMixin#mon_enter
296 (3.7%) 227 (2.8%) Fluent::MessagePackFactory::Mixin#msgpack_packer
219 (2.7%) 219 (2.7%) IO#read_nonblock
210 (2.6%) 210 (2.6%) Fluent::OneEventStream#size
208 (2.6%) 208 (2.6%) Fluent::EventTime#to_msgpack_ext
198 (2.5%) 198 (2.5%) Fluent::Plugin::OwnedByMixin#log
197 (2.5%) 197 (2.5%) MonitorMixin#mon_check_owner
541 (6.8%) 187 (2.3%) Fluent::Plugin::Buffer#add_metadata
173 (2.2%) 173 (2.2%) Fluent::Plugin::Buffer::MemoryChunk#commit
171 (2.1%) 171 (2.1%) MonitorMixin#mon_enter
350 (4.4%) 153 (1.9%) MonitorMixin#mon_exit
181 (2.3%) 139 (1.7%) Fluent::Plugin::Buffer::MemoryChunk#concat
135 (1.7%) 135 (1.7%) Fluent::Plugin::Buffer#new_metadata
7230 (90.2%) 109 (1.4%) Coolio::Loop#run
106 (1.3%) 106 (1.3%) MonitorMixin#mon_check_owner
106 (1.3%) 106 (1.3%) Fluent::EventRouter::MatchCache#get
780 (9.7%) 100 (1.2%) Fluent::Plugin::Output#metadata
88 (1.1%) 88 (1.1%) MonitorMixin#mon_check_owner
87 (1.1%) 87 (1.1%) Fluent::Plugin::Buffer::Chunk#staged?
109 (1.4%) 85 (1.1%) Fluent::Plugin::Buffer#chunk_size_full?
83 (1.0%) 83 (1.0%) Fluent::EventTime#initialize
82 (1.0%) 82 (1.0%) Fluent::Plugin::Buffer::MemoryChunk#bytesize
161 (2.0%) 73 (0.9%) MonitorMixin#mon_exit
66 (0.8%) 66 (0.8%) #<Module:0x000055d2b5447158>.engine_factory
65 (0.8%) 65 (0.8%) Fluent::OneEventStream#initialize
169 (2.1%) 63 (0.8%) MonitorMixin#mon_exit
133 (1.7%) 50 (0.6%) Fluent::EventTime.from_time
48 (0.6%) 48 (0.6%) Fluent::Plugin::Output#generate_format_proc
66 (0.8%) 47 (0.6%) Fluent::Plugin::Output#submit_flush_once
42 (0.5%) 42 (0.5%) Fluent::Plugin::Buffer::Chunk#writable?
6071 (75.8%) 38 (0.5%) Fluent::EventRouter#emit
37 (0.5%) 37 (0.5%) Fluent::Log#on_trace
35 (0.4%) 35 (0.4%) Fluent::PluginHelper::EventEmitter#router
33 (0.4%) 33 (0.4%) Fluent::Plugin::Buffer#storable?
29 (0.4%) 29 (0.4%) #<Module:0x000055d2b62b64f0>.generate
28 (0.3%) 28 (0.3%) Fluent::PluginHelper::Extract#extract_tag_from_record
201 (2.5%) 26 (0.3%) Fluent::Plugin::Buffer#queued?
24 (0.3%) 24 (0.3%) Fluent::Plugin::Buffer::MemoryChunk#empty?
5855 (73.1%) 23 (0.3%) #<Fluent::Plugin::NullOutput:0x000055d2b62cec80>.emit_buffered
39 (0.5%) 22 (0.3%) Fluent::Plugin::Buffer#dequeue_chunk
21 (0.3%) 21 (0.3%) Fluent::Plugin::Buffer::Chunk#unstaged?
20 (0.2%) 20 (0.2%) #<Module:0x000055d2b5829a50>.now_raw
163 (2.0%) 18 (0.2%) Fluent::Plugin::Output#flush_thread_run
681 (8.5%) 15 (0.2%) Fluent::OneEventStream#each
45 (0.6%) 15 (0.2%) Fluent::Plugin::Buffer#chunk_size_over?
14 (0.2%) 14 (0.2%) Fluent::Plugin::Output::FlushThreadState#next_clock=
32 (0.4%) 14 (0.2%) Fluent::Plugin::Buffer#purge_chunk
14 (0.2%) 14 (0.2%) MonitorMixin#mon_initialize
12 (0.1%) 12 (0.1%) Fluent::Log#trace
4187 (52.2%) 10 (0.1%) Fluent::Plugin::Output#write_guard
119 (1.5%) 10 (0.1%) Fluent::Plugin::Output#try_flush
17 (0.2%) 10 (0.1%) Fluent::Plugin::Buffer#enqueue_chunk
17 (0.2%) 10 (0.1%) Fluent::Plugin::Output#next_flush_time
9 (0.1%) 9 (0.1%) Fluent::Config::Section#method_missing
8 (0.1%) 8 (0.1%) #<Module:0x000055d2b62b64f0>.hex
5 (0.1%) 5 (0.1%) Fluent::Plugin::Buffer::MemoryChunk#purge
1782 (22.2%) 4 (0.0%) MonitorMixin#mon_synchronize
6695 (83.5%) 4 (0.0%) Fluent::Plugin::NoneParser#parse
443 (5.5%) 4 (0.0%) MonitorMixin#mon_synchronize
110 (1.4%) 4 (0.0%) Fluent::EventRouter#match
680 (8.5%) 4 (0.0%) Fluent::Plugin::Buffer#metadata
177 (2.2%) 4 (0.0%) Fluent::EventStream#empty?
5316 (66.3%) 3 (0.0%) Fluent::Plugin::Output#execute_chunking
5968 (74.5%) 3 (0.0%) Fluent::EventRouter#emit_stream
1426 (17.8%) 3 (0.0%) MonitorMixin#mon_synchronize
69 (0.9%) 3 (0.0%) Fluent::MessagePackFactory::Mixin#msgpack_factory
34 (0.4%) 2 (0.0%) Fluent::Plugin::Output#commit_write
2 (0.0%) 2 (0.0%) Fluent::Plugin::NullOutput#write
3412 (42.6%) 1 (0.0%) #<Fluent::PluginHelper::Server::EventHandler::TCPServer:0x000055d2b52c3610>.on_read_with_connection
44 (0.5%) 1 (0.0%) Fluent::Plugin::Buffer::Chunk#initialize
45 (0.6%) 1 (0.0%) Fluent::Plugin::Buffer::MemoryChunk#initialize
46 (0.6%) 1 (0.0%) Fluent::Plugin::MemoryBuffer#generate_chunk
1 (0.0%) 1 (0.0%) Coolio::IO#detach
3489 (43.5%) 0 (0.0%) #<Fluent::PluginHelper::Server::EventHandler::TCPServer:0x000055d2b52c28f0>.on_read_with_connection
7121 (88.9%) 0 (0.0%) Coolio::IO#on_readable
7121 (88.9%) 0 (0.0%) Coolio::IO::Watcher#on_readable
7230 (90.2%) 0 (0.0%) Fluent::PluginHelper::EventLoop#start
7230 (90.2%) 0 (0.0%) Fluent::PluginHelper::Thread#thread_create
1080 (13.5%) 0 (0.0%) block in <class:Output>
20 (0.2%) 0 (0.0%) #<Module:0x000055d2b5829a50>.now
163 (2.0%) 0 (0.0%) Fluent::Plugin::Output#start
163 (2.0%) 0 (0.0%) Fluent::PluginHelper::Thread#thread_create
8 (0.1%) 0 (0.0%) Fluent::UniqueId::Mixin#dump_unique_id_hex
29 (0.4%) 0 (0.0%) Fluent::UniqueId::Mixin#generate_unique_id
6 (0.1%) 0 (0.0%) Fluent::Plugin::Output#check_slow_flush
14 (0.2%) 0 (0.0%) MonitorMixin#initialize
1 (0.0%) 0 (0.0%) Coolio::Socket#detach
1 (0.0%) 0 (0.0%) Coolio::TCPSocket#detach
1 (0.0%) 0 (0.0%) Coolio::IO#close
1 (0.0%) 0 (0.0%) Fluent::PluginHelper::Server::EventHandler::TCPServer#close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment