Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce internal IdRef type #435

Merged
merged 2 commits into from
Sep 1, 2024

Conversation

jalil-salame
Copy link
Contributor

We use &Id in many places. As Id is defined as struct Id(pub String) this is a ptr-to-ptr situation. By using &IdRef(str) we remove that indirection, this increases memory usage as &IdRef is now a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win is worth it:

(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.

The discussions on Zulip propose changing the Id definition in rustdoc-types to u64 or even u32, but while we wait for this change to land (and for older rustdoc versions), this should be a nice perf improvement.

The improvements are bigger when using rayon, because we spend more time on visibility_tracker stuff (which is where the biggest improvements are).

We use `&Id` in many places. As `Id` is defined as `struct Id(pub
String)` this is a ptr-to-ptr situation. By using `&IdRef(str)` we
remove that indirection, this increases memory usage as `&IdRef` is now
a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win
is worth it:

```console
(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The discussions on Zulip propose changing the `Id` definition in
`rustdoc-types` to `u64` or even `u32`, but while we wait for this
change to land (and for older `rustdoc` versions), this should be a nice
perf improvement.

The improvements are bigger when using `rayon`, because we spend more
time on `visibility_tracker` stuff (which is where the biggest
improvements are).
Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job as always! 🚀

@obi1kenobi obi1kenobi enabled auto-merge (squash) September 1, 2024 17:02
@obi1kenobi obi1kenobi merged commit 4d123be into obi1kenobi:rustdoc-v33 Sep 1, 2024
4 checks passed
@jalil-salame jalil-salame deleted the use-idref branch September 1, 2024 17:49
obi1kenobi added a commit that referenced this pull request Sep 1, 2024
We use `&Id` in many places. As `Id` is defined as `struct Id(pub
String)` this is a ptr-to-ptr situation. By using `&IdRef(str)` we
remove that indirection, this increases memory usage as `&IdRef` is now
a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win
is worth it:

```console
(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The discussions on Zulip propose changing the `Id` definition in
`rustdoc-types` to `u64` or even `u32`, but while we wait for this
change to land (and for older `rustdoc` versions), this should be a nice
perf improvement.

The improvements are bigger when using `rayon`, because we spend more
time on `visibility_tracker` stuff (which is where the biggest
improvements are).

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
obi1kenobi added a commit that referenced this pull request Sep 1, 2024
We use `&Id` in many places. As `Id` is defined as `struct Id(pub
String)` this is a ptr-to-ptr situation. By using `&IdRef(str)` we
remove that indirection, this increases memory usage as `&IdRef` is now
a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win
is worth it:

```console
(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The discussions on Zulip propose changing the `Id` definition in
`rustdoc-types` to `u64` or even `u32`, but while we wait for this
change to land (and for older `rustdoc` versions), this should be a nice
perf improvement.

The improvements are bigger when using `rayon`, because we spend more
time on `visibility_tracker` stuff (which is where the biggest
improvements are).

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
obi1kenobi added a commit that referenced this pull request Sep 1, 2024
We use `&Id` in many places. As `Id` is defined as `struct Id(pub
String)` this is a ptr-to-ptr situation. By using `&IdRef(str)` we
remove that indirection, this increases memory usage as `&IdRef` is now
a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win
is worth it:

```console
(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The discussions on Zulip propose changing the `Id` definition in
`rustdoc-types` to `u64` or even `u32`, but while we wait for this
change to land (and for older `rustdoc` versions), this should be a nice
perf improvement.

The improvements are bigger when using `rayon`, because we spend more
time on `visibility_tracker` stuff (which is where the biggest
improvements are).

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
obi1kenobi added a commit that referenced this pull request Sep 1, 2024
We use `&Id` in many places. As `Id` is defined as `struct Id(pub
String)` this is a ptr-to-ptr situation. By using `&IdRef(str)` we
remove that indirection, this increases memory usage as `&IdRef` is now
a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win
is worth it:

```console
(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The discussions on Zulip propose changing the `Id` definition in
`rustdoc-types` to `u64` or even `u32`, but while we wait for this
change to land (and for older `rustdoc` versions), this should be a nice
perf improvement.

The improvements are bigger when using `rayon`, because we spend more
time on `visibility_tracker` stuff (which is where the biggest
improvements are).

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
obi1kenobi added a commit that referenced this pull request Sep 1, 2024
We use `&Id` in many places. As `Id` is defined as `struct Id(pub
String)` this is a ptr-to-ptr situation. By using `&IdRef(str)` we
remove that indirection, this increases memory usage as `&IdRef` is now
a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win
is worth it:

```console
(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The discussions on Zulip propose changing the `Id` definition in
`rustdoc-types` to `u64` or even `u32`, but while we wait for this
change to land (and for older `rustdoc` versions), this should be a nice
perf improvement.

The improvements are bigger when using `rayon`, because we spend more
time on `visibility_tracker` stuff (which is where the biggest
improvements are).

Co-authored-by: Jalil David Salamé Messina <60845989+jalil-salame@users.noreply.github.com>
obi1kenobi added a commit that referenced this pull request Sep 1, 2024
We use `&Id` in many places. As `Id` is defined as `struct Id(pub
String)` this is a ptr-to-ptr situation. By using `&IdRef(str)` we
remove that indirection, this increases memory usage as `&IdRef` is now
a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win
is worth it:

```console
(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The discussions on Zulip propose changing the `Id` definition in
`rustdoc-types` to `u64` or even `u32`, but while we wait for this
change to land (and for older `rustdoc` versions), this should be a nice
perf improvement.

The improvements are bigger when using `rayon`, because we spend more
time on `visibility_tracker` stuff (which is where the biggest
improvements are).

Co-authored-by: Jalil David Salamé Messina <60845989+jalil-salame@users.noreply.github.com>
obi1kenobi added a commit that referenced this pull request Sep 1, 2024
We use `&Id` in many places. As `Id` is defined as `struct Id(pub
String)` this is a ptr-to-ptr situation. By using `&IdRef(str)` we
remove that indirection, this increases memory usage as `&IdRef` is now
a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win
is worth it:

```console
(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The discussions on Zulip propose changing the `Id` definition in
`rustdoc-types` to `u64` or even `u32`, but while we wait for this
change to land (and for older `rustdoc` versions), this should be a nice
perf improvement.

The improvements are bigger when using `rayon`, because we spend more
time on `visibility_tracker` stuff (which is where the biggest
improvements are).

Co-authored-by: Jalil David Salamé Messina <60845989+jalil-salame@users.noreply.github.com>
obi1kenobi added a commit that referenced this pull request Sep 1, 2024
We use `&Id` in many places. As `Id` is defined as `struct Id(pub
String)` this is a ptr-to-ptr situation. By using `&IdRef(str)` we
remove that indirection, this increases memory usage as `&IdRef` is now
a "wide" ptr (ptr and length) instead of a "thin" ptr, but the perf win
is worth it:

```console
(32418dd)❯ cargo criterion --bench indexed_crate
                        time:   [1.3590 s 1.3599 s 1.3609 s]

(changes)❯ cargo criterion --bench indexed_crate
IndexedCrate/new(aws-sdk-ec2)
                        time:   [1.2456 s 1.2466 s 1.2478 s]
                        change: [-8.4413% -8.3275% -8.2222%] (p = 0.00 < 0.05)
                        Performance has improved.

(32418dd)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [571.63 ms 572.93 ms 574.23 ms]

(changes)❯ cargo criterion --bench indexed_crate --features rayon
IndexedCrate/new(aws-sdk-ec2)
                        time:   [501.28 ms 502.32 ms 503.34 ms]
                        change: [-12.596% -12.324% -12.053%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The discussions on Zulip propose changing the `Id` definition in
`rustdoc-types` to `u64` or even `u32`, but while we wait for this
change to land (and for older `rustdoc` versions), this should be a nice
perf improvement.

The improvements are bigger when using `rayon`, because we spend more
time on `visibility_tracker` stuff (which is where the biggest
improvements are).

Co-authored-by: Jalil David Salamé Messina <60845989+jalil-salame@users.noreply.github.com>
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.

2 participants