Skip to content

Fold function output type and argument types - #204

Merged
1 commit merged into
rust-lang:masterfrom
espindola:fold_ty_fn
Jan 19, 2011
Merged

1 commit merged into
rust-lang:masterfrom
espindola:fold_ty_fn

Conversation

@espindola

Copy link
Copy Markdown

No description provided.

…compile

type lteq[T] = fn(&T a) -> bool;

with "unresolved name: T". Before we would silently get to the type checker
and assert in a unresolved ty_path.
kazcw pushed a commit to kazcw/rust that referenced this pull request Oct 23, 2018
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this pull request Mar 7, 2023
* Add LULESH-motivated optimization to gradient utils.

* Fix formatting to comply with formatting guidelines.

* Update GradientUtils.cpp

Co-authored-by: William Moses <gh@wsmoses.com>
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this pull request Mar 7, 2023
carolynzech pushed a commit to celinval/rust-dev that referenced this pull request Dec 13, 2024
Towards rust-lang#150

Similar PR Ref : rust-lang#193 

Annotates and verifies the safety contracts for the unsafe function :
`from_ptr` - `core::ffi::c_str`

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

---------

Co-authored-by: Yenyun035 <57857379+Yenyun035@users.noreply.github.com>
Co-authored-by: Yenyun035 <yew005eng@gmail.com>
malezjaa pushed a commit to malezjaa/rust that referenced this pull request Nov 14, 2026
fix: Only instantiate RawTable's reserve functions once

...per key-value.

Each of the previous closures would cause an entirely new reserve/resize
function to be instantiated. By using this trick (which std uses for
iterator adaptors), we always get a single instantiatiation per key
(modulo the insert_with_hasher method).
malezjaa pushed a commit to malezjaa/rust that referenced this pull request Nov 14, 2026
Reduce the amount of llvm IR instantiated

This works to improve the generated code in a similar way to rust-lang#204 , however it is entirely orthogonal to it but also far more invasive.

The main change here is the introduction of `RawTableInner` which is contains all the fields that `RawTable` has but without being parameterized by `T`. Methods have been moved to this new type in parts or their entirety and `RawTable` forwards to these methods.

For this small test case with 4 different maps there is a reduction of the number of llvm lines generated by -17% (18088 / 21873 =0.82695560737) .

```rust
fn main() {
    let mut map1 = hashbrown::HashMap::new();
    map1.insert(1u8, "");
    map1.reserve(1000);
    let mut map2 = hashbrown::HashMap::new();
    map2.insert(1i16, "");
    map2.reserve(1000);
    let mut map3 = hashbrown::HashMap::new();
    map3.insert(3u16, "");
    map3.reserve(1000);
    let mut map4 = hashbrown::HashMap::new();
    map4.insert(3u64, "");
    map4.reserve(1000);
    dbg!((
        map1.iter().next(),
        map2.iter().next(),
        map3.iter().next(),
        map4.iter().next()
    ));
}

```

The commits are almost entirely orthogonal (except the first which does the main refactoring to support the rest) and if some are not desired they can be removed. If it helps, this PR could also be split up into multiple.

For most commitst I don't expect any performance degradation (unless LLVM stops inlining some function as it is now called more), but there are a couple of commits that does slow parts down however these should only be in the cold parts of the code (for instance, panic handling).
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant