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

An additional benchmark for KeyPath read performance. #61795

Merged
merged 21 commits into from
Nov 7, 2022

Conversation

fibrechannelscsi
Copy link
Contributor

This adds one additional benchmark where a read is performed on a KeyPath whose root is a reference type. Subsequent elements encountered during a project-read operation are pure struct types.

The goal is to highlight an upcoming performance optimization where, during a read or write operation, we project through non-pure-struct types first, and then use a pre-computed offset to jump to the final value once we encounter a stretch of trivially-typed memory only. In essence, if we have the following nested structure (with S and C referring to struct and non-struct types, respectively):
C1 -> C2 -> ... -> Cm -> S1 -> S2 -> ..., -> Sn
we project normally from C1 to Cm, then as soon as we get to S1, we use the pre-computed offset to jump to Sn.

The upcoming optimization will not jump via an offset through intermediate stretches of trivially-typed memory. Namely, if we have the following situation:
C1 -> C2 -> ... -> Cm -> S1 -> S2 -> ..., -> Sn -> Cm+1 -> Cm+2 -> ... -> Cm+x -> Sn+1 -> Sn+2 -> ..., -> Sn+y
then only one offset will be involved, and the jump will only be performed from Sn+1 to Sn+y.

Relates to:
#60758

fibrechannelscsi and others added 19 commits August 3, 2022 13:38
…. Removed benchmarks dealing with an inlining issue.
@BradLarson
Copy link
Contributor

@swift-ci please benchmark

KeyPath.swift should now look like what is currently in main.
@BradLarson
Copy link
Contributor

@swift-ci please benchmark

@BradLarson
Copy link
Contributor

@swift-ci please benchmark

@BradLarson BradLarson requested a review from eeckstein November 7, 2022 17:10
Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

@BradLarson
Copy link
Contributor

@swift-ci please test

@BradLarson BradLarson merged commit 2d052a0 into swiftlang:main Nov 7, 2022
meg-gupta pushed a commit to meg-gupta/swift that referenced this pull request Nov 9, 2022
* Added a benchmark for KeyPaths where trivially-typed memory is preceded by non-trivially-typed memory.

* Reduces the workload of run_KeyPathClassStructs by a factor of 4.

The reported time was 1847 us.
valeriyvan pushed a commit to valeriyvan/swift that referenced this pull request Nov 15, 2022
* Added a benchmark for KeyPaths where trivially-typed memory is preceded by non-trivially-typed memory.

* Reduces the workload of run_KeyPathClassStructs by a factor of 4.

The reported time was 1847 us.
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.

3 participants