Skip to content

Commit 353f9db

Browse files
committed
---
yaml --- r: 28117 b: refs/heads/try c: 88e0476 h: refs/heads/master i: 28115: 4c8d970 v: v3
1 parent 6bc3155 commit 353f9db

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5-
refs/heads/try: 9fafb63d5eeed0194d7cf56b6328823114949b29
5+
refs/heads/try: 88e0476bd024ef83052479588278669f56a346e2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df

branches/try/src/rustc/driver/session.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const borrowck_note_loan: uint = 4096;
4242
const no_landing_pads: uint = 8192;
4343
const debug_llvm: uint = 16384;
4444
const count_type_sizes: uint = 32768;
45+
const meta_stats: uint = 65536;
4546

4647
fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
4748
~[(~"ppregions", ~"prettyprint regions with \
@@ -66,7 +67,8 @@ fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
6667
no_landing_pads),
6768
(~"debug-llvm", ~"enable debug output from LLVM", debug_llvm),
6869
(~"count-type-sizes", ~"count the sizes of aggregate types",
69-
count_type_sizes)
70+
count_type_sizes),
71+
(~"meta-stats", ~"gather metadata statistics", meta_stats)
7072
]
7173
}
7274

@@ -198,6 +200,7 @@ impl session {
198200
fn count_type_sizes() -> bool { self.debugging_opt(count_type_sizes) }
199201
fn time_llvm_passes() -> bool { self.debugging_opt(time_llvm_passes) }
200202
fn trans_stats() -> bool { self.debugging_opt(trans_stats) }
203+
fn meta_stats() -> bool { self.debugging_opt(meta_stats) }
201204
fn no_asm_comments() -> bool { self.debugging_opt(no_asm_comments) }
202205
fn no_verify() -> bool { self.debugging_opt(no_verify) }
203206
fn trace() -> bool { self.debugging_opt(trace) }

branches/try/src/rustc/metadata/encoder.rs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,23 @@ type encode_parms = {
5454
encode_inlined_item: encode_inlined_item
5555
};
5656

57+
type stats = {
58+
mut inline_bytes: uint,
59+
mut attr_bytes: uint,
60+
mut dep_bytes: uint,
61+
mut item_bytes: uint,
62+
mut index_bytes: uint,
63+
mut zero_bytes: uint,
64+
mut total_bytes: uint,
65+
66+
mut n_inlines: uint
67+
};
68+
5769
enum encode_ctxt = {
5870
diag: span_handler,
5971
tcx: ty::ctxt,
72+
buf: io::MemBuffer,
73+
stats: stats,
6074
reachable: hashmap<ast::node_id, ()>,
6175
reexports: ~[(~str, def_id)],
6276
reexports2: middle::resolve3::ExportMap2,
@@ -1072,9 +1086,21 @@ fn encode_hash(ebml_w: ebml::writer, hash: ~str) {
10721086
}
10731087

10741088
fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] {
1089+
let buf = io::mem_buffer();
1090+
let stats =
1091+
{mut inline_bytes: 0,
1092+
mut attr_bytes: 0,
1093+
mut dep_bytes: 0,
1094+
mut item_bytes: 0,
1095+
mut index_bytes: 0,
1096+
mut zero_bytes: 0,
1097+
mut total_bytes: 0,
1098+
mut n_inlines: 0};
10751099
let ecx: @encode_ctxt = @encode_ctxt({
10761100
diag: parms.diag,
10771101
tcx: parms.tcx,
1102+
buf: buf,
1103+
stats: stats,
10781104
reachable: parms.reachable,
10791105
reexports: parms.reexports,
10801106
reexports2: parms.reexports2,
@@ -1086,24 +1112,55 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] {
10861112
type_abbrevs: ty::new_ty_hash()
10871113
});
10881114

1089-
let buf = io::mem_buffer();
10901115
let buf_w = io::mem_buffer_writer(buf);
10911116
let ebml_w = ebml::writer(buf_w);
10921117

10931118
encode_hash(ebml_w, ecx.link_meta.extras_hash);
10941119

1120+
let mut i = buf.pos;
10951121
let crate_attrs = synthesize_crate_attrs(ecx, crate);
10961122
encode_attributes(ebml_w, crate_attrs);
1123+
ecx.stats.attr_bytes = buf.pos - i;
10971124

1125+
i = buf.pos;
10981126
encode_crate_deps(ecx, ebml_w, ecx.cstore);
1127+
ecx.stats.dep_bytes = buf.pos - i;
10991128

11001129
// Encode and index the items.
11011130
ebml_w.start_tag(tag_items);
1131+
i = buf.pos;
11021132
let items_index = encode_info_for_items(ecx, ebml_w, crate);
1133+
ecx.stats.item_bytes = buf.pos - i;
1134+
1135+
i = buf.pos;
11031136
let items_buckets = create_index(items_index, hash_node_id);
11041137
encode_index(ebml_w, items_buckets, write_int);
1138+
ecx.stats.index_bytes = buf.pos - i;
11051139
ebml_w.end_tag();
11061140

1141+
ecx.stats.total_bytes = buf.pos;
1142+
1143+
if (parms.tcx.sess.meta_stats()) {
1144+
1145+
do buf.buf.borrow |v| {
1146+
do v.each |e| {
1147+
if e == 0 {
1148+
ecx.stats.zero_bytes += 1;
1149+
}
1150+
true
1151+
}
1152+
}
1153+
1154+
io::println("metadata stats:");
1155+
io::println(fmt!(" inline bytes: %u", ecx.stats.inline_bytes));
1156+
io::println(fmt!(" attribute bytes: %u", ecx.stats.attr_bytes));
1157+
io::println(fmt!(" dep bytes: %u", ecx.stats.dep_bytes));
1158+
io::println(fmt!(" item bytes: %u", ecx.stats.item_bytes));
1159+
io::println(fmt!(" index bytes: %u", ecx.stats.index_bytes));
1160+
io::println(fmt!(" zero bytes: %u", ecx.stats.zero_bytes));
1161+
io::println(fmt!(" total bytes: %u", ecx.stats.total_bytes));
1162+
}
1163+
11071164
// Pad this, since something (LLVM, presumably) is cutting off the
11081165
// remaining % 4 bytes.
11091166
buf_w.write(&[0u8, 0u8, 0u8, 0u8]);

0 commit comments

Comments
 (0)