Skip to content

runtime, cmd/internal/obj/arm64, cmd/internal/objabi, cmd/link/internal/arm64: enable conditional branches on target outside of arm64.s file #68844

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ArsenySamoylov
Copy link

In some runtime functions, there are conditional branches that lead to absolute branches. For example:

// func memhash(p unsafe.Pointer, h, size uintptr) uintptr
TEXT runtime·memhash<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-32
	MOVB	runtime·useAeshash(SB), R10
	CBZ	R10, noaes
	B	aeshashbody<>(SB)
noaes:
	B	runtime·memhashFallback<ABIInternal>(SB)

This patch allows direct conditional branches. This affects hash function written in runtime/asm_arm64.s.
Results of running runtime hash benchmarks:

goos: linux
goarch: arm64
pkg: runtime
                       │ master_noaes_runtime_hash.txt │ arm64-condbr19_noaes_runtime_hash.txt │
                       │            sec/op             │     sec/op      vs base               │
Hash5-4                                    9.628n ± 0%      8.858n ± 0%  -8.00% (p=0.000 n=25)
Hash16-4                                   9.627n ± 0%      9.627n ± 0%       ~ (p=0.117 n=25)
Hash64-4                                   15.03n ± 0%      14.25n ± 0%  -5.19% (p=0.000 n=25)
Hash1024-4                                 90.19n ± 0%      88.19n ± 0%  -2.22% (p=0.000 n=25)
Hash65536-4                                5.058µ ± 0%      5.192µ ± 0%  +2.65% (p=0.000 n=25)
HashStringSpeed-4                          19.00n ± 3%      18.46n ± 4%       ~ (p=0.096 n=25)
HashBytesSpeed-4                           65.26n ± 0%      64.36n ± 0%  -1.38% (p=0.000 n=25)
HashInt32Speed-4                           12.46n ± 0%      12.50n ± 1%       ~ (p=0.829 n=25)
HashInt64Speed-4                           13.01n ± 3%      12.47n ± 3%  -4.15% (p=0.000 n=25)
HashStringArraySpeed-4                     43.45n ± 2%      41.55n ± 3%  -4.37% (p=0.000 n=25)
FastrandHashiter-4                         11.72n ± 1%      11.81n ± 1%       ~ (p=0.079 n=25)
geomean                                    33.77n           33.00n       -2.26%

            │ master_noaes_runtime_hash.txt │ arm64-condbr19_noaes_runtime_hash.txt │
            │              B/s              │      B/s        vs base               │
Hash5-4                        495.3Mi ± 0%     538.3Mi ± 0%  +8.69% (p=0.000 n=25)
Hash16-4                       1.548Gi ± 0%     1.548Gi ± 0%  +0.00% (p=0.025 n=25)
Hash64-4                       3.966Gi ± 0%     4.183Gi ± 0%  +5.47% (p=0.000 n=25)
Hash1024-4                     10.57Gi ± 0%     10.81Gi ± 0%  +2.27% (p=0.000 n=25)
Hash65536-4                    12.07Gi ± 0%     11.76Gi ± 0%  -2.57% (p=0.000 n=25)
geomean                        3.279Gi          3.367Gi       +2.70%

These results are obtained with cpu.ARM64.HasAES == false

Change-Id: If282267b9b2dcf474516cb33bfdbda4ee35bb8fa

@gopherbot
Copy link
Contributor

This PR (HEAD: 2883dac) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/604775.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/604775.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://go.dev/s/release
for more details.


Please don’t reply on this GitHub thread. Visit golang.org/cl/604775.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Arseny Samoylov:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/604775.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Keith Randall:

Patch Set 2:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/604775.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 3241846) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/604775.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

This PR (HEAD: 2f28f8e) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/604775.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

…arm64: enable conditional branches on target outside of asm file

Results of running runtime hash benchmarks:
goos: linux
goarch: arm64
pkg: runtime
                       │ master_noaes_runtime_hash.txt │ arm64-condbr19_noaes_runtime_hash.txt │
                       │            sec/op             │     sec/op      vs base               │
Hash5-4                                    9.628n ± 0%      8.858n ± 0%  -8.00% (p=0.000 n=25)
Hash16-4                                   9.627n ± 0%      9.627n ± 0%       ~ (p=0.117 n=25)
Hash64-4                                   15.03n ± 0%      14.25n ± 0%  -5.19% (p=0.000 n=25)
Hash1024-4                                 90.19n ± 0%      88.19n ± 0%  -2.22% (p=0.000 n=25)
Hash65536-4                                5.058µ ± 0%      5.192µ ± 0%  +2.65% (p=0.000 n=25)
HashStringSpeed-4                          19.00n ± 3%      18.46n ± 4%       ~ (p=0.096 n=25)
HashBytesSpeed-4                           65.26n ± 0%      64.36n ± 0%  -1.38% (p=0.000 n=25)
HashInt32Speed-4                           12.46n ± 0%      12.50n ± 1%       ~ (p=0.829 n=25)
HashInt64Speed-4                           13.01n ± 3%      12.47n ± 3%  -4.15% (p=0.000 n=25)
HashStringArraySpeed-4                     43.45n ± 2%      41.55n ± 3%  -4.37% (p=0.000 n=25)
FastrandHashiter-4                         11.72n ± 1%      11.81n ± 1%       ~ (p=0.079 n=25)
geomean                                    33.77n           33.00n       -2.26%

            │ master_noaes_runtime_hash.txt │ arm64-condbr19_noaes_runtime_hash.txt │
            │              B/s              │      B/s        vs base               │
Hash5-4                        495.3Mi ± 0%     538.3Mi ± 0%  +8.69% (p=0.000 n=25)
Hash16-4                       1.548Gi ± 0%     1.548Gi ± 0%  +0.00% (p=0.025 n=25)
Hash64-4                       3.966Gi ± 0%     4.183Gi ± 0%  +5.47% (p=0.000 n=25)
Hash1024-4                     10.57Gi ± 0%     10.81Gi ± 0%  +2.27% (p=0.000 n=25)
Hash65536-4                    12.07Gi ± 0%     11.76Gi ± 0%  -2.57% (p=0.000 n=25)
geomean                        3.279Gi          3.367Gi       +2.70%

These results are obtained with cpu.ARM64.HasAES == false

Change-Id: If282267b9b2dcf474516cb33bfdbda4ee35bb8fa
@gopherbot
Copy link
Contributor

This PR (HEAD: c3302d3) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/604775.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from Keith Randall:

Patch Set 5:

(3 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/604775.
After addressing review feedback, remember to publish your drafts!

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