Commit Graph

143 Commits

Author SHA1 Message Date
Eduard-Mihai Burtescu
dc8ac2679a Rollup merge of #37229 - nnethercote:FxHasher, r=nikomatsakis
Replace FNV with a faster hash function.

Hash table lookups are very hot in rustc profiles and the time taken within `FnvHash` itself is a big part of that. Although FNV is a simple hash, it processes its input one byte at a time. In contrast, Firefox has a homespun hash function that is also simple but works on multiple bytes at a time. So I tried it out and the results are compelling:

```
futures-rs-test  4.326s vs  4.212s --> 1.027x faster (variance: 1.001x, 1.007x)
helloworld       0.233s vs  0.232s --> 1.004x faster (variance: 1.037x, 1.016x)
html5ever-2016-  5.397s vs  5.210s --> 1.036x faster (variance: 1.009x, 1.006x)
hyper.0.5.0      5.018s vs  4.905s --> 1.023x faster (variance: 1.007x, 1.006x)
inflate-0.1.0    4.889s vs  4.872s --> 1.004x faster (variance: 1.012x, 1.007x)
issue-32062-equ  0.347s vs  0.335s --> 1.035x faster (variance: 1.033x, 1.019x)
issue-32278-big  1.717s vs  1.622s --> 1.059x faster (variance: 1.027x, 1.028x)
jld-day15-parse  1.537s vs  1.459s --> 1.054x faster (variance: 1.005x, 1.003x)
piston-image-0. 11.863s vs 11.482s --> 1.033x faster (variance: 1.060x, 1.002x)
regex.0.1.30     2.517s vs  2.453s --> 1.026x faster (variance: 1.011x, 1.013x)
rust-encoding-0  2.080s vs  2.047s --> 1.016x faster (variance: 1.005x, 1.005x)
syntex-0.42.2   32.268s vs 31.275s --> 1.032x faster (variance: 1.014x, 1.022x)
syntex-0.42.2-i 17.629s vs 16.559s --> 1.065x faster (variance: 1.013x, 1.021x)
```

(That's a stage1 compiler doing debug builds. Results for a stage2 compiler are similar.)

The attached commit is not in a state suitable for landing because I changed the implementation of FnvHasher without changing its name (because that would have required touching many lines in the compiler). Nonetheless, it is a good place to start discussions.

Profiles show very clearly that this new hash function is a lot faster to compute than FNV. The quality of the new hash function is less clear -- it seems to do better in some cases and worse in others (judging by the number of instructions executed in `Hash{Map,Set}::get`).

CC @brson, @arthurprs
2016-11-09 20:51:15 +02:00
bors
38a959a543 Auto merge of #36843 - petrochenkov:dotstab, r=nikomatsakis
Stabilize `..` in tuple (struct) patterns

I'd like to nominate `..` in tuple and tuple struct patterns for stabilization.
This feature is a relatively small extension to existing stable functionality and doesn't have known blockers.
The feature first appeared in Rust 1.10 6 months ago.
An example of use: https://github.com/rust-lang/rust/pull/36203

Closes https://github.com/rust-lang/rust/issues/33627
r? @nikomatsakis
2016-11-08 02:06:45 -08:00
Nicholas Nethercote
00e48affde Replace FnvHasher use with FxHasher.
This speeds up compilation by 3--6% across most of rustc-benchmarks.
2016-11-08 15:14:59 +11:00
bors
08839965f9 Auto merge of #37427 - nnethercote:opt-IchHasher, r=michaelwoerister
Reduce the number of bytes hashed by IchHasher.

IchHasher uses blake2b hashing, which is expensive, so the fewer bytes hashed
the better. There are two big ways to reduce the number of bytes hashed.
- Filenames in spans account for ~66% of all bytes (for builds with debuginfo).
  The vast majority of spans have the same filename for the start of the span
  and the end of the span, so hashing the filename just once in those cases is
  a big win.
- u32 and u64 and usize values account for ~25%--33% of all bytes (for builds
  with debuginfo). The vast majority of these are small, i.e. fit in a u8, so
  shrinking them down before hashing is also a big win.

This PR implements these two optimizations. I'm certain the first one is safe.
I'm about 90% sure that the second one is safe.

Here are measurements of the number of bytes hashed when doing
debuginfo-enabled builds of stdlib and
rustc-benchmarks/syntex-0.42.2-incr-clean.

```
                    stdlib   syntex-incr
                    ------   -----------
original       156,781,386   255,095,596
half-SawSpan   106,744,403   176,345,419
short-ints      45,890,534   118,014,227
no-SawSpan[*]    6,831,874    45,875,714

[*] don't hash the SawSpan at all. Not part of this PR, just implemented for
    comparison's sake.
```

For debug builds of syntex-0.42.2-incr-clean, the two changes give a 1--2%
speed-up.
2016-11-05 01:10:57 -07:00
Vadim Petrochenkov
74bb594563 Stabilize .. in tuple (struct) patterns 2016-11-03 01:38:15 +03:00
Nicholas Nethercote
d73c68ceef leb128-encode integers before hashing them in IchHasher.
This significantly reduces the number of bytes hashed by IchHasher.
2016-11-03 09:05:56 +11:00
Jonathan Turner
27f41b7001 Rollup merge of #37513 - michaelwoerister:hash-panic-spans, r=nikomatsakis
ICH: Hash expression spans if their source location is captured for panics.

Since the location of some expressions is captured in error message constants, it has an influence on machine code and consequently we need to take them into account by the incr. comp. hash. This PR makes this happen for `+, -, *, /, %` and for array indexing -- let me know if I forgot anything.

In the future we might want to change the codegen strategy for those error messages, so that they are stored in a separate object file with a stable symbol name, so that only this object file has to be regenerated when source locations change. This strategy would also eliminate unnecessary duplications due  to monomorphization, as @arielb1 has pointed out on IRC. I opened https://github.com/rust-lang/rust/issues/37512, so we don't forget about this.

r? @nikomatsakis
2016-11-02 15:09:42 -04:00
Nicholas Nethercote
af0b27e01f Don't hash span filenames twice in IchHasher.
This significantly reduces the number of bytes hashed by IchHasher.
2016-11-02 14:17:36 +11:00
Michael Woerister
e3025a0733 ICH: Hash expression spans if their source location is captured for panics 2016-11-01 09:41:46 -04:00
Seo Sanghyeon
07c8a25f42 Remove unused type aliases 2016-10-31 23:14:27 +09:00
Michael Woerister
a2a2763e6d Replace all uses of SHA-256 with BLAKE2b. 2016-10-30 19:14:18 -04:00
Jeffrey Seyfried
cbd24757eb Move CrateConfig from Crate to ParseSess. 2016-10-29 07:52:58 +00:00
Jeffrey Seyfried
53de24bbd1 Refactor away fields MacroDef::{use_locally, export}. 2016-10-24 00:43:19 +00:00
Michael Woerister
d07523c716 ICH: Use 128-bit Blake2b hash instead of 64-bit SipHash for incr. comp. fingerprints. 2016-10-17 12:40:25 -04:00
Alex Crichton
9d70ff384f Rollup merge of #36995 - nrc:stable, r=@nikomatsakis
stabilise ?, attributes on stmts, deprecate Reflect

r? @nikomatsakis
2016-10-12 14:07:55 -07:00
Nick Cameron
9bc6d26092 Stabilise ?
cc [`?` tracking issue](https://github.com/rust-lang/rust/issues/31436)
2016-10-12 08:40:22 +13:00
Michael Woerister
57d6ddd649 incr.comp.: Hide concrete hash algorithm used for ICH 2016-10-07 10:08:57 -04:00
Mathieu Borderé
0e40dbb2f7 ICH: Remove obsolete binding in saw_ty 2016-10-06 08:10:52 +02:00
Mathieu Borderé
4b5a9a3706 ICH: update saw_ty for TyBareFn; Update tests for functioninterfaces 2016-10-05 23:17:58 +02:00
Mathieu Borderé
14fe7ce9dc Adjustments due to naming changes in Ty_ and PatKind structs 2016-10-05 07:11:04 +02:00
Mathieu Borderé
e051eb32c2 ICH - Include omitted elements in inc. comp. hash #36914 2016-10-05 06:46:04 +02:00
Vadim Petrochenkov
da7b1c984c Separate Def::StructCtor/Def::VariantCtor from Def::Struct/Def::Variant 2016-10-04 22:20:37 +03:00
bors
9c31d76e97 Auto merge of #36821 - pweaver:master, r=michaelwoerister
#36821

I am just starting to learn rust. Feedback would be appreciated.
2016-10-03 15:04:41 -07:00
Pweaver (Paul Weaver)
7cf90d0a1d fixes multi-line string whitespace in librustc_incremental/persist/fs.rs 2016-10-03 15:18:27 -04:00
bors
7a26aeca77 Auto merge of #36815 - alexcrichton:stabilize-1.13, r=aturon
std: Stabilize and deprecate APIs for 1.13

This commit is intended to be backported to the 1.13 branch, and works with the
following APIs:

Stabilized

* `i32::checked_abs`
* `i32::wrapping_abs`
* `i32::overflowing_abs`
* `RefCell::try_borrow`
* `RefCell::try_borrow_mut`

Deprecated

* `BinaryHeap::push_pop`
* `BinaryHeap::replace`
* `SipHash13`
* `SipHash24`
* `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map`
  module

Closes #28147
Closes #34767
Closes #35057
Closes #35070
2016-10-03 11:00:03 -07:00
Alex Crichton
10c3134da0 std: Stabilize and deprecate APIs for 1.13
This commit is intended to be backported to the 1.13 branch, and works with the
following APIs:

Stabilized

* `i32::checked_abs`
* `i32::wrapping_abs`
* `i32::overflowing_abs`
* `RefCell::try_borrow`
* `RefCell::try_borrow_mut`
* `DefaultHasher`
* `DefaultHasher::new`
* `DefaultHasher::default`

Deprecated

* `BinaryHeap::push_pop`
* `BinaryHeap::replace`
* `SipHash13`
* `SipHash24`
* `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map`
  module

Closes #28147
Closes #34767
Closes #35057
Closes #35070
2016-10-03 10:34:34 -07:00
Manish Goregaokar
259d1fcd47 Rollup merge of #36599 - jonas-schievink:whats-a-pirates-favorite-data-structure, r=pnkfelix
Contains a syntax-[breaking-change] as a separate commit (cc #31645).nnAlso renames slice patterns from `PatKind::Vec` to `PatKind::Slice`.
2016-10-01 19:22:12 +05:30
Pweaver (Paul Weaver)
5e3aaab2f6 #36680 add warning when compliation cache fails to hard link 2016-09-29 00:03:13 -04:00
Jonathan Turner
94622260a8 Rollup merge of #36460 - mikhail-m1:35123-map3, r=nikomatsakis
map crate numbers between compilations

?r nikomatsakis
issue #35123
2016-09-28 20:21:50 -07:00
Jonas Schievink
cf0b7bdd0c Call arrays "arrays" instead of "vecs" internally 2016-09-28 22:30:30 +02:00
Michael Woerister
263ba92045 incr.comp.: Fix build issue in rustc_incremental if CFG_VERSION is not set. 2016-09-26 22:26:10 -04:00
Michael Woerister
1e5c253aa1 incr.comp.: Add test case for cache artifact file headers. 2016-09-26 17:14:31 -04:00
Michael Woerister
76f76ae1d8 incr.comp.: Add file header to on-disk artifacts for validation. 2016-09-26 16:05:01 -04:00
Michael Woerister
6a2666d5b0 ICH: Add ability to test the ICH of exported metadata items. 2016-09-23 17:23:23 -04:00
Mikhail Modin
20c10913ff Merge branch 'master' into 35123-map3 2016-09-23 06:52:06 +03:00
Eduard Burtescu
ef4352fba6 rustc_metadata: group information into less tags. 2016-09-20 20:08:04 +03:00
Eduard Burtescu
0863012fb9 Remove librbml and the RBML-tagged auto-encoder/decoder. 2016-09-20 20:08:01 +03:00
Eduard Burtescu
fc363cb482 rustc_metadata: go only through rustc_serialize in astencode. 2016-09-20 20:07:54 +03:00
bors
739d57180f Auto merge of #36041 - ahmedcharles:try, r=nrc
Replace try! with ?.
2016-09-13 22:41:34 -07:00
Mikhail Modin
da3c6b7646 map create numbers between compilations 2016-09-14 00:00:23 +03:00
bors
fa9d8cc8ac Auto merge of #35960 - nikomatsakis:incr-comp-krate-edges, r=michaelwoerister
fix a few errant `Krate` edges

Exploring the effect of small changes on `syntex` reuse, I discovered the following sources of unnecessary edges from `Krate`

r? @michaelwoerister
2016-09-12 17:15:26 -07:00
Ahmed Charles
8a9e52a8e7 Use question_mark feature in librustc_incremental. 2016-09-11 16:02:41 -07:00
bors
923bac4596 Auto merge of #36025 - michaelwoerister:incr-comp-hash-spans, r=nikomatsakis
incr. comp.: Take spans into account for ICH

This PR makes the ICH (incr. comp. hash) take spans into account when debuginfo is enabled.

A side-effect of this is that the SVH (which is based on the ICHs of all items in the crate) becomes sensitive to the tiniest change in a code base if debuginfo is enabled. Since we are not trying to model ABI compatibility via the SVH anymore (this is done via the crate disambiguator now), this should be not be a problem.

Fixes #33888.
Fixes #32753.
2016-09-06 13:22:35 -07:00
Michael Woerister
3057b7b974 ICH: Make CachingCodemapView robustly handle invalid spans. 2016-09-06 12:14:43 -04:00
Niko Matsakis
2a84449169 allow testing DepNode::Krate edges directly 2016-09-06 11:18:09 -04:00
Vadim Petrochenkov
e05e74ac83 Replace _, _ with .. 2016-09-04 12:30:33 +03:00
Vadim Petrochenkov
641d8e9e4c Some better support for unions through the compiler 2016-09-03 13:39:34 +03:00
Michael Woerister
7310a8ffea ICH: Adapt to changes in the MetaItem AST representation. 2016-09-01 14:39:31 -04:00
Michael Woerister
8cbd6fe331 ICH: Share codemap cache between subsequent runs of the ICH visitor. 2016-09-01 09:43:44 -04:00
Michael Woerister
2faca22bd3 ICH: Fix codemap lookup caching. 2016-09-01 09:43:44 -04:00