raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
blob 73682203c1f480cbf283be9437ea31252d9cefdf 1012 bytes (raw)
name: test/test_linux_all_tcp_listen_stats_leak.rb 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
# -*- encoding: binary -*-
require 'test/unit'
require 'raindrops'
require 'socket'
require 'benchmark'
$stderr.sync = $stdout.sync = true

class TestLinuxAllTcpListenStatsLeak < Test::Unit::TestCase

  TEST_ADDR = ENV['UNICORN_TEST_ADDR'] || '127.0.0.1'


  def rss_kb
    File.readlines("/proc/#$$/status").grep(/VmRSS:/)[0].split(/\s+/)[1].to_i
  end
  def test_leak
    s = TCPServer.new(TEST_ADDR, 0)
    start_kb = rss_kb
    p [ :start_kb, start_kb ]
    assert_nothing_raised do
      p(Benchmark.measure {
        1000.times { Raindrops::Linux.all_tcp_listener_stats }
      })
    end
    cur_kb = rss_kb
    p [ :cur_kb, cur_kb ]
    now = Time.now.to_i
    fin = now + 60
    assert_nothing_raised do
      1000000000.times { |i|
        if (i % 1024) == 0
          now = Time.now.to_i
          break if now > fin
        end
        Raindrops::Linux.all_tcp_listener_stats
      }
    end
    cur_kb = rss_kb
    p [ :cur_kb, cur_kb ]
    ensure
      s.close
  end
end if ENV["STRESS"].to_i != 0

debug log:

solving 7368220 ...
found 7368220 in https://yhbt.net/raindrops.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/raindrops.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).