# My wish list for Rust 2024 and beyond

**URL:** <https://internals.rust-lang.org/t/my-wish-list-for-rust-2024-and-beyond/20407>\
**Category:** language design\
**Created:** [February 28, 2024, 5:46pm UTC](https://internals.rust-lang.org/t/my-wish-list-for-rust-2024-and-beyond/20407 "2024-02-28T17:46:38Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![rxdiscovery](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/rxdiscovery/32/11755_2.png) [@rxdiscovery](https://internals.rust-lang.org/u/rxdiscovery)\
**Post date:** [March 1, 2024, 10:51pm UTC](https://internals.rust-lang.org/t/my-wish-list-for-rust-2024-and-beyond/20407/21 "2024-03-01T22:51:05Z")

</div>

> [@tczajka](#):
>
> Not only is this not really a great reason to duplicate a feature (unless you were to also remove the previous notation), it would be ambiguous because `?` already has another meaning, for example:

I just gave an example with "?", for Rust this symbol is already reserved, but like we can replace it with "§" or "?!" 😆 ( but I understand your point of view 👍 )

> [@quaternic](#):
>
> ```rust
> nop: 27 - 28 - 37 p95 interval: ( 23.3, 35.2)
> flat: 82 - 84 - 93 p95 interval: ( 78.6, 93.5)
> base_inside: 82 - 84 - 102 p95 interval: ( 75.3, 97.5)
> base_outside: 82 - 84 - 94 p95 interval: ( 78.4, 94.2)
> 
> ```

the Flat always remains better by ~5%

in my test I made a loop of 10000000 just to be sure to make the noise negligible..

---

<div class="post-metadata">

**Author:** ![quaternic](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/quaternic/32/10440_2.png) [@quaternic](https://internals.rust-lang.org/u/quaternic)\
**Post date:** [March 1, 2024, 11:39pm UTC](https://internals.rust-lang.org/t/my-wish-list-for-rust-2024-and-beyond/20407/22 "2024-03-01T23:39:33Z")

</div>

For me, running `cargo run --release`, all three benchmarks (from 2e71828's playground) had this _identical_ assembly:

```rust
70: movdqu xmm0,XMMWORD PTR [rsp]
    movdqu xmm1,XMMWORD PTR [rsp+0x10]
    paddq xmm1,xmm0
    pshufd xmm0,xmm1,0xee
    paddq xmm0,xmm1
    movq r8,xmm0
    add r8,rcx
    add r8,rdi
    inc rdi
    mov QWORD PTR [rsp+0x20],r8
    cmp r15,rdi
    jne 70

```

So them also performing the same is to be expected (though not guaranteed).

I'm not convinced the vectorization is ideal in this case, but that's beside the point. The benchmark is very artificial anyway.

---

<div class="post-metadata">

**Author:** ![rxdiscovery](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/rxdiscovery/32/11755_2.png) [@rxdiscovery](https://internals.rust-lang.org/u/rxdiscovery)\
**Post date:** [March 1, 2024, 11:54pm UTC](https://internals.rust-lang.org/t/my-wish-list-for-rust-2024-and-beyond/20407/23 "2024-03-01T23:54:01Z")

</div>

I found a difference (release mode) in my test 🤔

FLAT style :

```rust
fn_test::test_perf_cpp_style:
 sub rsp, 136
 mov qword, ptr, [rsp, +, 8], rdi
 mov qword, ptr, [rsp, +, 32], 0
 call qword, ptr, [rip, +, _ZN3std4time7Instant3now17hcaf082b521a24e93E@GOTPCREL]
 mov rdi, qword, ptr, [rsp, +, 8]
 mov qword, ptr, [rsp, +, 16], rax
 mov dword, ptr, [rsp, +, 28], edx
 mov qword, ptr, [rsp, +, 40], 0
 mov qword, ptr, [rsp, +, 48], rdi
 mov rdi, qword, ptr, [rsp, +, 40]
 mov rsi, qword, ptr, [rsp, +, 48]
 call <I as core::iter::traits::collect::IntoIterator>::into_iter
 mov qword, ptr, [rsp, +, 56], rax
 mov qword, ptr, [rsp, +, 64], rdx
.LBB16_1:
 lea rdi, [rsp, +, 56]
 call core::iter::range::<impl core::iter::traits::iterator::Iterator for core::ops::range::Range<A>>::next
 mov qword, ptr, [rsp, +, 80], rdx
 mov qword, ptr, [rsp, +, 72], rax
 cmp qword, ptr, [rsp, +, 72], 0
 jne .LBB16_3
 mov rax, qword, ptr, [rip, +, _ZN3std4time7Instant3now17hcaf082b521a24e93E@GOTPCREL]
 call rax
 mov rsi, qword, ptr, [rsp, +, 16]
 mov ecx, edx
 mov edx, dword, ptr, [rsp, +, 28]
 mov dword, ptr, [rsp, +, 128], ecx
 mov qword, ptr, [rsp, +, 120], rax
 mov rax, qword, ptr, [rip, +, _ZN3std4time7Instant14duration_since17h04c83e08d82e773aE@GOTPCREL]
 lea rdi, [rsp, +, 120]
 call rax
 add rsp, 136
 ret
.LBB16_3:
 mov rcx, qword, ptr, [rsp, +, 80]
 mov rdi, rcx
 add rdi, 1
 mov rsi, rcx
 add rsi, 3
 mov rdx, rcx
 add rdx, 3
 mov rax, rcx
 add rax, 2
 mov qword, ptr, [rsp, +, 88], rdi
 mov qword, ptr, [rsp, +, 96], rsi
 mov qword, ptr, [rsp, +, 104], rdx
 mov qword, ptr, [rsp, +, 112], rax
 mov rax, qword, ptr, [rsp, +, 88]
 add rax, qword, ptr, [rsp, +, 96]
 add rax, rcx
 mov qword, ptr, [rsp, +, 32], rax
 jmp .LBB16_1

```

Rust Style

```rust
fn_test::test_perf_rust_style:
 sub rsp, 152
 mov qword, ptr, [rsp, +, 8], rdi
 mov qword, ptr, [rsp, +, 32], 0
 call qword, ptr, [rip, +, _ZN3std4time7Instant3now17hcaf082b521a24e93E@GOTPCREL]
 mov rdi, qword, ptr, [rsp, +, 8]
 mov qword, ptr, [rsp, +, 16], rax
 mov dword, ptr, [rsp, +, 28], edx
 mov qword, ptr, [rsp, +, 40], 0
 mov qword, ptr, [rsp, +, 48], rdi
 mov rdi, qword, ptr, [rsp, +, 40]
 mov rsi, qword, ptr, [rsp, +, 48]
 call <I as core::iter::traits::collect::IntoIterator>::into_iter
 mov qword, ptr, [rsp, +, 56], rax
 mov qword, ptr, [rsp, +, 64], rdx
.LBB15_1:
 lea rdi, [rsp, +, 56]
 call core::iter::range::<impl core::iter::traits::iterator::Iterator for core::ops::range::Range<A>>::next
 mov qword, ptr, [rsp, +, 80], rdx
 mov qword, ptr, [rsp, +, 72], rax
 cmp qword, ptr, [rsp, +, 72], 0
 jne .LBB15_3
 mov rax, qword, ptr, [rip, +, _ZN3std4time7Instant3now17hcaf082b521a24e93E@GOTPCREL]
 call rax
 mov rsi, qword, ptr, [rsp, +, 16]
 mov ecx, edx
 mov edx, dword, ptr, [rsp, +, 28]
 mov dword, ptr, [rsp, +, 144], ecx
 mov qword, ptr, [rsp, +, 136], rax
 mov rax, qword, ptr, [rip, +, _ZN3std4time7Instant14duration_since17h04c83e08d82e773aE@GOTPCREL]
 lea rdi, [rsp, +, 136]
 call rax
 add rsp, 152
 ret
.LBB15_3:
 mov rcx, qword, ptr, [rsp, +, 80]
 mov rdx, rcx
 add rdx, 1
 mov rax, rcx
 add rax, 3
 mov qword, ptr, [rsp, +, 120], rdx
 mov qword, ptr, [rsp, +, 128], rax
 mov rdx, rcx
 add rdx, 3
 mov rax, rcx
 add rax, 2
 mov rdi, qword, ptr, [rsp, +, 120]
 mov rsi, qword, ptr, [rsp, +, 128]
 mov qword, ptr, [rsp, +, 88], rdi
 mov qword, ptr, [rsp, +, 96], rsi
 mov qword, ptr, [rsp, +, 104], rdx
 mov qword, ptr, [rsp, +, 112], rax
 mov rax, qword, ptr, [rsp, +, 88]
 add rax, qword, ptr, [rsp, +, 96]
 add rax, rcx
 mov qword, ptr, [rsp, +, 32], rax
 jmp .LBB15_1

```

 ![diff](https://us1.discourse-cdn.com/flex002/uploads/rustlang/original/2X/1/10c2857f0944b80baa619edefe23ced63ca2e0cc.png)

more instructions, so that justifies the 5%.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [May 30, 2024, 11:54pm UTC](https://internals.rust-lang.org/t/my-wish-list-for-rust-2024-and-beyond/20407/24 "2024-05-30T23:54:02Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

[Previous page](https://internals.rust-lang.org/t/my-wish-list-for-rust-2024-and-beyond/20407.md?page=1)
