Add branch_type and in_tx to Python db export and the export-to-postgresql.py script.
Showing the changes to tools/perf/scripts/python (1 of 2 files). Show all
Unified · Split
| @@ -123,6 +123,10 @@ do_query(query, 'CREATE TABLE symbols (' · 122 unmodified lines | ||
| 123 | 123 | 'sym_end bigint,' |
| 124 | 124 | 'binding integer,' |
| 125 | 125 | 'name varchar(2048))') |
| 126 | +do_query(query, 'CREATE TABLE branch_types (' | |
| 127 | + 'id integer NOT NULL,' | |
| 128 | + 'name varchar(80))') | |
| 129 | + | |
| 126 | 130 | if branches: |
| 127 | 131 | do_query(query, 'CREATE TABLE samples (' |
| 128 | 132 | 'id bigint NOT NULL,' |
| @@ -139,7 +143,9 @@ if branches: · 10 unmodified lines | ||
| 139 | 143 | 'to_dso_id bigint,' |
| 140 | 144 | 'to_symbol_id bigint,' |
| 141 | 145 | 'to_sym_offset bigint,' |
| 142 | − 'to_ip bigint)') | |
| 146 | + 'to_ip bigint,' | |
| 147 | + 'branch_type integer,' | |
| 148 | + 'in_tx boolean)') | |
| 143 | 149 | else: |
| 144 | 150 | do_query(query, 'CREATE TABLE samples (' |
| 145 | 151 | 'id bigint NOT NULL,' |
| @@ -160,7 +166,9 @@ else: · 14 unmodified lines | ||
| 160 | 166 | 'period bigint,' |
| 161 | 167 | 'weight bigint,' |
| 162 | 168 | 'transaction bigint,' |
| 163 | − 'data_src bigint)') | |
| 169 | + 'data_src bigint,' | |
| 170 | + 'branch_type integer,' | |
| 171 | + 'in_tx boolean)') | |
| 164 | 172 | |
| 165 | 173 | do_query(query, 'CREATE VIEW samples_view AS ' |
| 166 | 174 | 'SELECT ' |
| @@ -178,7 +186,9 @@ do_query(query, 'CREATE VIEW samples_view AS ' · 11 unmodified lines | ||
| 178 | 186 | 'to_hex(to_ip) AS to_ip_hex,' |
| 179 | 187 | '(SELECT name FROM symbols WHERE id = to_symbol_id) AS to_symbol,' |
| 180 | 188 | 'to_sym_offset,' |
| 181 | − '(SELECT short_name FROM dsos WHERE id = to_dso_id) AS to_dso_short_name' | |
| 189 | + '(SELECT short_name FROM dsos WHERE id = to_dso_id) AS to_dso_short_name,' | |
| 190 | + '(SELECT name FROM branch_types WHERE id = branch_type) AS branch_type_name,' | |
| 191 | + 'in_tx' | |
| 182 | 192 | ' FROM samples') |
| 183 | 193 | |
| 184 | 194 | |
| @@ -234,6 +244,7 @@ comm_file = open_output_file("comm_table.bin") · 49 unmodified lines | ||
| 234 | 244 | comm_thread_file = open_output_file("comm_thread_table.bin") |
| 235 | 245 | dso_file = open_output_file("dso_table.bin") |
| 236 | 246 | symbol_file = open_output_file("symbol_table.bin") |
| 247 | +branch_type_file = open_output_file("branch_type_table.bin") | |
| 237 | 248 | sample_file = open_output_file("sample_table.bin") |
| 238 | 249 | |
| 239 | 250 | def trace_begin(): |
| @@ -257,6 +268,7 @@ def trace_end(): · 17 unmodified lines | ||
| 257 | 268 | copy_output_file(comm_thread_file, "comm_threads") |
| 258 | 269 | copy_output_file(dso_file, "dsos") |
| 259 | 270 | copy_output_file(symbol_file, "symbols") |
| 271 | + copy_output_file(branch_type_file, "branch_types") | |
| 260 | 272 | copy_output_file(sample_file, "samples") |
| 261 | 273 | |
| 262 | 274 | print datetime.datetime.today(), "Removing intermediate files..." |
| @@ -267,6 +279,7 @@ def trace_end(): · 4 unmodified lines | ||
| 267 | 279 | remove_output_file(comm_thread_file) |
| 268 | 280 | remove_output_file(dso_file) |
| 269 | 281 | remove_output_file(symbol_file) |
| 282 | + remove_output_file(branch_type_file) | |
| 270 | 283 | remove_output_file(sample_file) |
| 271 | 284 | os.rmdir(output_dir_name) |
| 272 | 285 | print datetime.datetime.today(), "Adding primary keys" |
| @@ -277,6 +290,7 @@ def trace_end(): · 4 unmodified lines | ||
| 277 | 290 | do_query(query, 'ALTER TABLE comm_threads ADD PRIMARY KEY (id)') |
| 278 | 291 | do_query(query, 'ALTER TABLE dsos ADD PRIMARY KEY (id)') |
| 279 | 292 | do_query(query, 'ALTER TABLE symbols ADD PRIMARY KEY (id)') |
| 293 | + do_query(query, 'ALTER TABLE branch_types ADD PRIMARY KEY (id)') | |
| 280 | 294 | do_query(query, 'ALTER TABLE samples ADD PRIMARY KEY (id)') |
| 281 | 295 | |
| 282 | 296 | print datetime.datetime.today(), "Adding foreign keys" |
| @@ -352,9 +366,15 @@ def symbol_table(symbol_id, dso_id, sym_start, sym_end, binding, symbol_name, *x · 69 unmodified lines | ||
| 352 | 366 | value = struct.pack(fmt, 6, 8, symbol_id, 8, dso_id, 8, sym_start, 8, sym_end, 4, binding, n, symbol_name) |
| 353 | 367 | symbol_file.write(value) |
| 354 | 368 | |
| 355 | −def sample_table(sample_id, evsel_id, machine_id, thread_id, comm_id, dso_id, symbol_id, sym_offset, ip, time, cpu, to_dso_id, to_symbol_id, to_sym_offset, to_ip, period, weight, transaction, data_src, *x): | |
| 369 | +def branch_type_table(branch_type, name, *x): | |
| 370 | + n = len(name) | |
| 371 | + fmt = "!hiii" + str(n) + "s" | |
| 372 | + value = struct.pack(fmt, 2, 4, branch_type, n, name) | |
| 373 | + branch_type_file.write(value) | |
| 374 | + | |
| 375 | +def sample_table(sample_id, evsel_id, machine_id, thread_id, comm_id, dso_id, symbol_id, sym_offset, ip, time, cpu, to_dso_id, to_symbol_id, to_sym_offset, to_ip, period, weight, transaction, data_src, branch_type, in_tx, *x): | |
| 356 | 376 | if branches: |
| 357 | − value = struct.pack("!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiq", 15, 8, sample_id, 8, evsel_id, 8, machine_id, 8, thread_id, 8, comm_id, 8, dso_id, 8, symbol_id, 8, sym_offset, 8, ip, 8, time, 4, cpu, 8, to_dso_id, 8, to_symbol_id, 8, to_sym_offset, 8, to_ip) | |
| 377 | + value = struct.pack("!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiiiB", 17, 8, sample_id, 8, evsel_id, 8, machine_id, 8, thread_id, 8, comm_id, 8, dso_id, 8, symbol_id, 8, sym_offset, 8, ip, 8, time, 4, cpu, 8, to_dso_id, 8, to_symbol_id, 8, to_sym_offset, 8, to_ip, 4, branch_type, 1, in_tx) | |
| 358 | 378 | else: |
| 359 | − value = struct.pack("!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiqiqiqiq", 19, 8, sample_id, 8, evsel_id, 8, machine_id, 8, thread_id, 8, comm_id, 8, dso_id, 8, symbol_id, 8, sym_offset, 8, ip, 8, time, 4, cpu, 8, to_dso_id, 8, to_symbol_id, 8, to_sym_offset, 8, to_ip, 8, period, 8, weight, 8, transaction, 8, data_src) | |
| 379 | + value = struct.pack("!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiqiqiqiqiiiB", 21, 8, sample_id, 8, evsel_id, 8, machine_id, 8, thread_id, 8, comm_id, 8, dso_id, 8, symbol_id, 8, sym_offset, 8, ip, 8, time, 4, cpu, 8, to_dso_id, 8, to_symbol_id, 8, to_sym_offset, 8, to_ip, 8, period, 8, weight, 8, transaction, 8, data_src, 4, branch_type, 1, in_tx) | |
| 360 | 380 | sample_file.write(value) |