Debian Codegraph @

tools/check-small-index-limit.rb

raw symbols SCIP
1 #!/usr/bin/env ruby
2
3 # Groonga: 70dc95ef3b6fed1225981d099a65dcb7297248c5
4 #
5 # N segments N chunks N patterns N records
6 # 1 1 2 50
7 # 2 2 2 18898
8 # 4 4 2 31181
9 # 8 8 2 57853
10 # 16 16 2 91349
11 # 32 32 2 178502
12 # 64 64 2 475020
13 # 128 128 2 1066081
14 # 256 256 2 2250389
15 # 512 512 2 4648072
16 # nil nil 1 16779239
17 # nil nil 2 4648063
18 # nil nil 4 7239005
19 # nil nil 8 8308626
20 # nil nil 16 11068608
21 # nil nil 32 12670806
22 # nil nil 64 18524231
23 # nil nil 128 38095525
24 # nil nil 256 51265415
25
26 require "fileutils"
27 require "json"
28
29 def check_max_index(options)
30 max_n_segments = options[:max_n_segments]
31 max_n_chunks = options[:max_n_chunks]
32 n_patterns = options[:n_patterns] || 2
33
34 ENV["GRN_II_MAX_N_SEGMENTS_SMALL"] = max_n_segments&.to_s
35 ENV["GRN_II_MAX_N_CHUNKS_SMALL"] = max_n_chunks&.to_s
36
37 db_dir = "/dev/shm/db"
38 log_path = "#{db_dir}/log"
39 FileUtils.rm_rf(db_dir)
40 FileUtils.mkdir_p(db_dir)
41 command_line = [
42 "groonga",
43 "--log-path", log_path,
44 "-n", "#{db_dir}/db",
45 ]
46 IO.popen(command_line, "r+") do |groonga|
47 groonga.puts("table_create x TABLE_HASH_KEY UInt32")
48 groonga.gets
49 groonga.puts("column_create x y COLUMN_SCALAR UInt32")
50 groonga.gets
51 groonga.puts("table_create a TABLE_PAT_KEY UInt32")
52 groonga.gets
53 groonga.puts("column_create a b COLUMN_INDEX|INDEX_SMALL x y")
54 groonga.gets
55
56 groonga.puts("load --table x")
57 groonga.puts("[")
58 File.open(log_path) do |log|
59 log.seek(0, IO::SEEK_END)
60 log_size = log.size
61 i = 0
62 catch do |abort|
63 loop do
64 y = i + 1
65 n_patterns.times do
66 groonga.print(JSON.generate({"_key" => i, "y" => y}))
67 groonga.puts(",")
68 groonga.flush
69 i += 1
70 if log.size != log_size
71 data = log.read
72 if /\|[Ae]\|/ =~ data
73 parameters = [
74 max_n_segments.inspect,
75 max_n_chunks.inspect,
76 n_patterns.inspect,
77 i,
78 ]
79 puts(parameters.join("\t"))
80 # puts(data)
81 throw(abort)
82 end
83 log_size = log.size
84 end
85 end
86 end
87 end
88 end
89 groonga.puts("]")
90 load_response = groonga.gets
91 # puts(load_response)
92
93 groonga.puts("quit")
94 groonga.gets
95 end
96 end
97
98 puts("N segments\tN chunks\tN patterns\tN records")
99 [
100 [1, 1, 2],
101 [2, 2, 2],
102 [4, 4, 2],
103 [8, 8, 2],
104 [16, 16, 2],
105 [32, 32, 2],
106 [64, 64, 2],
107 [128, 128, 2],
108 [256, 256, 2],
109 [512, 512, 2],
110 [nil, nil, 1],
111 [nil, nil, 2],
112 [nil, nil, 4],
113 [nil, nil, 8],
114 [nil, nil, 16],
115 [nil, nil, 32],
116 [nil, nil, 64],
117 [nil, nil, 128],
118 [nil, nil, 256],
119 ].each do |max_n_segments, max_n_chunks, n_parameters|
120 check_max_index(:max_n_segments => max_n_segments,
121 :max_n_chunks => max_n_chunks,
122 :n_patterns => n_parameters)
123 end