[SRU] Enable some arm64 performance optimizations already available for other architectures

Bug #1901074 reported by Lucas Kanashiro
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ruby2.5 (Ubuntu)
Bionic
Fix Released
Undecided
Lucas Kanashiro
ruby2.7 (Ubuntu)
Fix Released
Undecided
Lucas Kanashiro
Focal
Fix Released
Undecided
Lucas Kanashiro
Groovy
Fix Released
Undecided
Lucas Kanashiro

Bug Description

[Impact]

Upstream merged some changes to improve performance on arm64 which could benefit Ubuntu users:

https://github.com/ruby/ruby/commit/511b55bcefc81c03

FWIW the landing of this patch was driven by AWS to improve performance on their arm64 instances. Actually, those are performance optimizations improvements which arm64 is missing that other architectures have.

Those changes considerably increase the number of instructions executed per second (ips) and also reduce the time to execute different tasks. On the other hand, it increases a bit the memory consumption. Here you can find the results of an experiment where some benchmarks defined by upstream were executed with the proposed patch on top of the Focal source package, a simple rebuild of the Focal version, and the binary from the archive in a Raspberry Pi 4 and a Canonistack VM (check the summary tab):

https://docs.google.com/spreadsheets/d/1_-H78uBDrlKHcmH1IPCbnxhLsNnD6Nj-Ya31_QSnW54/edit?usp=sharing

It is quite impressive how under some circumstances the ips was increased in more than 50% and the time taken to execute some tasks reduced more than 25%. IMHO those numbers are really good, and the small increase of at most 4% in the memory consumption worth in this case.

[Test Case]

Run the upstream benchmarks in a Ubuntu Focal arm64 machine:

1 - Install the ruby2.7 binary form the archive.
2 - Rebuild the ruby2.7 source package from Focal and install it.
3 - Build the ruby2.7 source package from Focal with the optimization patch on top of it and install it.
4 - Install the benchmark_driver gem. It is not in the archive, so install it from rubygems (sudo gem install benchmark_driver).
5 - Download the benchmarks definition from upstream master branch (https://github.com/ruby/ruby/raw/master/benchmark/). They are:
  * vm_array.yml
  * vm_attr_ivar_set.yml
  * vm_bigarray.yml
  * vm_block.yml
  * vm_attr_ivar.yml
  * vm_backtrace.rb
  * vm_bighash.yml
  * vm_block_handler.yml
6 - Run the benchmarks (in the presented experiment 6 rounds were executed):

$ benchmark-driver $BENCHMARK_INPUT_DIR/*.yml \
 -r $runner -e $RUBY_SYSTEM -e $RUBY_PATCHED -e $RUBY_REBUILT

where $BENCHMARK_INPUT_DIR is the directory with the benchmarks definition and $RUBY* is the path to the respective ruby versions under analysis.

[Regression Potential]

The code changes impact only aarch64 so no regression is expected in other architectures. No breakage during runtime is expected.

Based on the experiment presented above we might expect some extra memory consumption hitting users. However, the increase of at most 4% of memory consumption faced during the experiment seems a fair price to pay for the boost in performance this patch will provide.

With performance improvements, particularly in C code, common things to watch for would be segfaults, unexpected behavioral changes, and performance regressions that are seen only on arm64. Mitigating the risk here is that the code paths are already in use for many other architectures.

Related branches

Revision history for this message
Brian Murray (brian-murray) wrote :

I don't see these changes in groovy at all, is there a reason why?

Changed in ruby2.7 (Ubuntu):
status: New → Incomplete
Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Actually no. Now that the archive is opened for Hirsute I'll apply the patch there first and then start to backport it to the other releases.

Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

This patch was uploaded to Debian [1], and I'll sync it to Hirsute as soon as I can.

[1] https://tracker.debian.org/news/1188043/accepted-ruby27-272-3-source-into-unstable/

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Any reason why this got uploaded only to focal and not to groovy? From your comments I can see that hirsute was waiting for archive opening, but what about groovy? Anyway, please upload to all the later series ASAP as we won't accept it into focal before that happens.

Changed in ruby2.7 (Ubuntu Bionic):
status: New → Invalid
Changed in ruby2.5 (Ubuntu Groovy):
status: New → Invalid
Changed in ruby2.5 (Ubuntu Focal):
status: New → Invalid
Changed in ruby2.5 (Ubuntu Bionic):
status: New → Triaged
Changed in ruby2.7 (Ubuntu Focal):
status: New → Triaged
Changed in ruby2.7 (Ubuntu Groovy):
status: New → Triaged
Changed in ruby2.5 (Ubuntu):
status: New → Invalid
Changed in ruby2.7 (Ubuntu):
assignee: nobody → Lucas Kanashiro (lucaskanashiro)
Changed in ruby2.7 (Ubuntu Focal):
assignee: nobody → Lucas Kanashiro (lucaskanashiro)
Changed in ruby2.7 (Ubuntu Groovy):
assignee: nobody → Lucas Kanashiro (lucaskanashiro)
Changed in ruby2.5 (Ubuntu Bionic):
assignee: nobody → Lucas Kanashiro (lucaskanashiro)
Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

I already synced ruby2.7/2.7.2-3 to hirsute (waiting for tests to be run), also uploaded a new version (2.7.1-3ubuntu1.1) to groovy-proposed including the patch.

Now I am working to backport this patch to ruby2.5 in bionic.

Changed in ruby2.5 (Ubuntu Bionic):
status: Triaged → In Progress
Changed in ruby2.7 (Ubuntu Focal):
status: Triaged → In Progress
Changed in ruby2.7 (Ubuntu Groovy):
status: Triaged → In Progress
Changed in ruby2.7 (Ubuntu):
status: Incomplete → In Progress
description: updated
summary: - [SRU] Enable some arm64 optimizations
+ [SRU] Enable some arm64 performance optimizations already available for
+ other architectures
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ruby2.7 - 2.7.2-3

---------------
ruby2.7 (2.7.2-3) unstable; urgency=medium

  * d/p/0013-Enable-arm64-optimizations-that-exist-for-power-x86-.patch:
    Backport an upstream patch. It includes enabling unaligned memory access,
    gc and vm_exec.c optimizations (LP: #1901074).
  * Refresh and sort patches numerically.
  * B-d on debhelper-compat instead of debhelper.
  * Drop debian/ruby2.7.lintian-overrides. The only override there is
    hyphen-used-as-minus-sign and it seems to not be a thing anymore.
    Moreover, it is malformed according to lintian.

 -- Lucas Kanashiro <email address hidden> Fri, 30 Oct 2020 16:04:41 -0300

Changed in ruby2.7 (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Lucas, or anyone else affected,

Accepted ruby2.7 into groovy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ruby2.7/2.7.1-3ubuntu1.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-groovy to verification-done-groovy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-groovy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in ruby2.7 (Ubuntu Groovy):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-groovy
Revision history for this message
Brian Murray (brian-murray) wrote :

Hello Lucas, or anyone else affected,

Accepted ruby2.7 into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ruby2.7/2.7.0-5ubuntu1.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in ruby2.7 (Ubuntu Focal):
status: In Progress → Fix Committed
tags: added: verification-needed-focal
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (ruby2.7/2.7.1-3ubuntu1.1)

All autopkgtests for the newly accepted ruby2.7 (2.7.1-3ubuntu1.1) for groovy have finished running.
The following regressions have been reported in tests triggered by the package:

puma/3.12.4-1ubuntu2 (s390x)
ruby-stackprof/0.2.15-2 (arm64)
ruby-rblineprof/0.3.7-2build1 (armhf)
ruby-openstack/2.0.2-1 (ppc64el)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/groovy/update_excuses.html#ruby2.7

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (ruby2.7/2.7.0-5ubuntu1.2)

All autopkgtests for the newly accepted ruby2.7 (2.7.0-5ubuntu1.2) for focal have finished running.
The following regressions have been reported in tests triggered by the package:

ruby-stackprof/0.2.15-2 (arm64, amd64)
puma/3.12.4-1ubuntu2 (s390x)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/focal/update_excuses.html#ruby2.7

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

I created a Focal and Groovy VMs, enabled proposed, and installed ruby2.7 from there. I was able to re-run the benchmarks and get a similar result as the one obtained in the experiment presented in the bug description.

tags: added: verification-done-focal verification-done-groovy
removed: verification-needed verification-needed-focal verification-needed-groovy
Mathew Hodson (mhodson)
no longer affects: ruby2.7 (Ubuntu Bionic)
no longer affects: ruby2.5 (Ubuntu Groovy)
no longer affects: ruby2.5 (Ubuntu Focal)
no longer affects: ruby2.5 (Ubuntu)
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Lucas, or anyone else affected,

Accepted ruby2.5 into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ruby2.5/2.5.1-1ubuntu1.7 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in ruby2.5 (Ubuntu Bionic):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-bionic
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ruby2.7 - 2.7.1-3ubuntu1.1

---------------
ruby2.7 (2.7.1-3ubuntu1.1) groovy; urgency=medium

  * d/p/0012-arm64-optimizations.patch: enable arm64 optimizations that exist
    for power/x86. It includes enabling unaligned memory access, gc and
    vm_exec.c optimizations (LP: #1901074).

 -- Lucas Kanashiro <email address hidden> Thu, 05 Nov 2020 09:27:05 -0300

Changed in ruby2.7 (Ubuntu Groovy):
status: Fix Committed → Fix Released
Revision history for this message
Chris Halse Rogers (raof) wrote : Update Released

The verification of the Stable Release Update for ruby2.7 has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ruby2.7 - 2.7.0-5ubuntu1.2

---------------
ruby2.7 (2.7.0-5ubuntu1.2) focal; urgency=medium

  * d/p/arm64-optimizations.patch: enable arm64 optimizations that exist for
    power/x86. It includes enabling unaligned memory access, gc and vm_exec.c
    optimizations (LP: #1901074).

 -- Lucas Kanashiro <email address hidden> Wed, 14 Oct 2020 14:55:55 -0300

Changed in ruby2.7 (Ubuntu Focal):
status: Fix Committed → Fix Released
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (ruby2.5/2.5.1-1ubuntu1.7)

All autopkgtests for the newly accepted ruby2.5 (2.5.1-1ubuntu1.7) for bionic have finished running.
The following regressions have been reported in tests triggered by the package:

ruby-gnome2/3.2.4-1 (arm64, armhf)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/bionic/update_excuses.html#ruby2.5

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

I created an arm64 Bionic VM, enabled proposed, and installed ruby2.5 from there. I was able to re-run the benchmarks and get a similar result as the one obtained in the experiment presented in the bug description.

tags: added: verification-done verification-done-bionic
removed: verification-needed verification-needed-bionic
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ruby2.5 - 2.5.1-1ubuntu1.7

---------------
ruby2.5 (2.5.1-1ubuntu1.7) bionic; urgency=medium

  * d/p/arm64-optimizations.patch: enable arm64 optimizations that exist
    for power/x86. It includes enabling unaligned memory access, gc and
    vm_exec.c optimizations (LP: #1901074).
  * Fix FTBFS, many tests were failing during the build (LP: #1903902).
    - Add missing b-d on tzdata.
  * Fix DEP-8 tests (LP: #1903905).
    - Backport patches to fix Kiritimati TZ tests:
      + 0029-Backport-upstream-patch-to-fix-Kiritimati-TZ-test-1-.patch
      + 0030-Backport-upstream-patch-to-fix-Kiritimati-TZ-test-2-.patch
    - d/t/control: add restriction to allow-stderr. The rubyconfig test calls
      dpkg-architecture which is returning a warning in Bionic.
    - d/t/bundled-gems: skip gems which do not match upstream expectations.
      Some gems listed as bundled by upstream are not satisfied by the Ubuntu
      Bionic archive.

 -- Lucas Kanashiro <email address hidden> Thu, 05 Nov 2020 10:30:22 -0300

Changed in ruby2.5 (Ubuntu Bionic):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.