How I Found a Go Issue on ARM that Crashed the Database Server

TiDB is an open-source, MySQL-compatible, distributed SQL database. Its architecture adopts a layered design. The storage layer is implemented in Rust, while the computing layer is implemented in Go. A distributed database like TiDB is a very complex project. Its performance depends on multiple factors, such as the operating system and the hardware platform it is running on, and the compiling language it uses.

In this article, I will share a peculiar Go bug that caused TiDB to crash on the Advanced RISC Machine (ARM) platform.

Android Native – How to load Samsung Emulator Skins

Introduction

Based on the latest report from Appbrain, Samsung has the highest market share(>35%) among all of the Android OEMs, therefore it is important that your apps are tested against Samsung phones.

In this tutorial, we will learn how to load Samsung Emulator skins onto our emulator devices.

Goals

At the end of the tutorial, you would have learned:

  1. How to load Samsung Emulator skins onto Android emulators with Android Studio.
  2. How custom AVD skins work.
Tools Required
  1. Android Studio. The version used in this tutorial is Arctic Fox 2020.3.1 Patch 4.
Prerequisite Knowledge
  1. Basic Android.
Project Setup

To follow along with the tutorial, perform the steps below:

  1. Create a new Android project with the default Empty Activity.
AVD Skins

Before learning how to add Samsung Emulator skins to our emulators, first, let us dig a little bit deeper into custom AVD (Android Virtual Device) skins.

For each emulator managed by the AVD Manager, there is an advanced option called Custom skin definition, which allows you to load a skin that is different from stock Android.

10000201000001C10000002F981313D99AB37890.png

You can either get these skins directly from the OEMs or create them yourselves. Unfortunately, not all Android OEMs provide them to developers, but Samsung is one of the few OEMs that provides a collection of pre-made skins for their devices.

Custom Skin only applies to the emulator frame

Even though we can make our stock emulators look and feel like real Samsung devices, this approach does not replicate the functionalities of the Launcher and other System applications on Samsung phones, so you still need to test with real devices or cloud testing farms for more accurate results.

The emulator skin can only emulate volume buttons and camera/speaker/microphone cutouts. Refer to the picture below if you need further clarification.

10000201000001D0000003FBABA9DB1D4F1CE307.png

Anatomy of AVD Skins

When you are loading a skin, you are simply loading a directory containing skin configuration files and graphic assets. A skin directory contains the files below:

  1. Configuration file named layout: this is the main configuration file, which defines the appearance of the skin. The format of this file looks similar to JSON, but its actual format must follow the rules described in ANDROID-CONFIG-FILES.TXT. Its supported key-value pairs are documented in ANDROID-SKIN-FILES.TXT.
  2. The image files for custom elements of the skin.
  3. Configuration file named hardware.ini: optional file containing custom hardware configurations for the emulator.

Besides OEM device skins that we can download from the internet, Android Studio already includes pre-made skins for us to inspect. On Windows, by default, they are located at the locations below:

  1. %USERPROFILE%\AppData\Local\Android\Sdk
  2. %USERPROFILE%\AppData\Local\Android\Sdk\platforms\android-31\skins

You will need to modify the platform level in the path above if you do not have android-31 installed.

I have opened the HVGA skin (under android-31/skins), which includes the layout, hardware.ini, and graphical assets in the picture below.

100002010000056E000001879C4FECF61A828BCD.png

Get Emulator Skins from Samsung

For this tutorial, we will learn how to load the emulator skin of a Galaxy S21+. To download this skin, follow the steps below:

  1. Go to this link to access all Galaxy S skins. A free Samsung account is required to access this page.
    100002010000008C00000108AA334F120350F879.png
  2. Scroll download until you find Galaxy S21+, and then click DOWNLOAD SKIN.
    100002010000026F00000108E31CC34920322869.png
  3. Find the downloaded Galaxy_S21_Plus.zip file and extract the content.
    10000201000000B50000002DF51D8ED3CE5F6441.png
Inspecting the Configuration Files

Using what we know so far about the layout configuration file, we will now try to understand the layout file included in the Galaxy S21+ skin.

  1. Inside the extracted Galaxy_S21_Plus directory, open up the layout file with a text editor. Under the parts/portrait section, we can easily see which configuration is referring to which graphic asset.
    100002010000032A000001BB64D7045CA8426C17.png
  2. There are three different colors of the Galaxy S21+, and the Black color is used by default, so thats why device_Port_PhantomBlack.png is used in the configuration file. The Silver and Violet backgrounds are not used, but you are allowed to modify the configuration file as you wish.
  3. The foreground mask is applied on top of the background to give the skin the correct curves as well as the camera cutout.
  4. volume_up, volume_down, and power assets emulate the volume rockers and the power button, including their X and Y coordinates.
  5. Unfortunately, this skin from Samsung does not include the hardware.ini file, so we will have to apply the emulator hardware configurations by ourselves later.
Create the Galaxy S21+ Emulator

For the skin to apply properly, we will have to create an emulator with the same dimensions as the real device. The resolution of the Galaxy S21+ is 1080x2400, so our emulator must use the same resolution as well.

  1. In Android Studio, Open the AVD Manager from Tools > AVD Manager.
  2. At the bottom left, select Create Virtual Device.
    10000201000000DE00000031B4C232784B6D0582.png
  3. On the next screen, select New Hardware Profile.
    10000201000000C500000023429952E429D5ACCC.png
  4. For the Device Name, use Mock Galaxy S21_Plus.
  5. For the Device Type, use Phone/Tablet.
  6. The screen size must be 6.7.
  7. The resolution would be 1080x2400.
  8. Leave Input, Supported device states, Camera, and Sensors as default.
    100002010000045A000002563EB0FED8D358BECF.png
  9. Scroll all the way to the end where you will find the Default skin option. Select the 3 dots icon and then select the Galaxy_S21_Plus directory that you have extracted earlier.
    100002010000029800000032C1D80E02F86B786F.png
  10. You will now see the Galaxy_S21_Plus skin set as the Default skin.
    100002010000028800000025AA5AE80B726C2BE0.png
  11. Click Finish. The window will close and bring us back to the previous screen.
  12. With the Mock Galaxy S21_Plus selected, hit Next.
    1000020100000421000002DD712DE717F22F21CE.png
  13. Now select your System Image of choice and select Next. I am using the x86 API 31 Image, but you might have to select a different Image depending on your own system (ARM-based systems such as Qualcomm/Raspberry Pi/Apple ARM should use ARM images instead of x86).
    1000020100000443000002DEF424843121015C74.png
  14. On the last screen, make sure that Enable Device Frame is selected before hitting Finish.
    10000201000004C40000027D4328EE5DB2D3602C.png
  15. Back to AVD Manager, press the green Play button to start your emulator.
    1000020100000465000000514540AAAA88DC6474.png

Your system might take a couple of minutes to start the emulator for the first time, but that should not affect the emulator skin from loading. You should see your emulator with a similar interface to the picture below.

1000020100000210000003FAAAB66CC5979685DF.png

If we compare our emulator skin with the real stock images, then we can see that the antennas, camera cutout, volume rockers, and the power button are all at the right places.

1000020100000525000003D346EDC6C9964B249E.png

Summary

We have learned how to load custom skins on Android emulators.

For this particular S21+ skin, I think the real benefits are to see where the camera cutout is as well as the volume/power rockers, especially if your app focuses on flagship galaxy devices. Maybe it will help you design your game controls better so they are not accidentally placed under the camera cutout; or maybe now that you know where the volume rockers and power buttons are, you would be able to avoid forcing your users to hold the device in an awkward position when using your app.

C++ Memory Model: Migrating From X86 to ARM

Over the past years, we have seen a shift in processors from the previously dominant x86 architecture to the more energy-efficient (and often cheaper) ARM architecture. This trend is true for both consumer hardware, e.g., Apple's M1 SoC, and also server hardware, e.g. AWS's Gravitron processor. Given that the ARM architecture has a more relaxed memory model, this might have some subtle impact on C++ programs.

So far, ArangoDB was only built for x86-based CPUs, but due to the rise of ARM processors, we are faced with an ever-increasing number of requests from users to support ARM. Since performance is at the heart of ArangoDB, there are a lot of places where we use atomic operations. In order to ensure that our code behaves correctly on ARM, we have to revisit all those places and make sure that the operations use the correct memory order. But what does that mean?

How to Utilize Java Benchmarks With Arm Processors

I have seen a lot of speculation surrounding ARM processors, specifically after Apple announced its plan to change over to Arm-based processors. Many people assume that the performance will be similar to a Raspberry Pi, however, this is incorrect. While Java on ARM is not uncommon, there has been a recent spike due to increased ARM investments from cloUd vendors. Amazon and Microsoft have taken steps towards this, with Amazon updating its ARM offerings, and Microsoft porting the JVM to Arm64 for Windows, which will be helpful for future Azure support. 

In this article, I will show the Java benchmarks I took on different AWS EC2 instances, and for fun on my laptop.

Analysis of Merge Requests in GitLab Using PVS-Studio For C#

Do you like GitLab and don't like bugs? Do you want to improve the quality of your source code? Then you've come to the right place. Today we will tell you how to configure the PVS-Studio C# analyzer for checking merge requests. Enjoy the reading and have a nice unicorn mood.

PVS-Studio is a tool designed to detect errors and potential vulnerabilities in the source code of programs, written in C, C++, C#, and Java. Works in 64-bit systems on Windows, Linux, and macOS. Can analyze the code meant for 32-bit, 64-bit, and embedded ARM platforms.

Adding Server in Runtime Manager

On-Prem Mule Runtime instances/servers can be registered with the Anypoint Runtime Manager (ARM) and managed from there. Servers use Runtime agents to communicate with ARM. This approach of having self-provisioned Mule Runtime Servers connected to Anypoint Platform using Anypoint Runtime Manager Agent is called Hybrid implementation.

One advantage of having On-Prem or Hybrid implementation over Cloudhub is that multiple applications can be connected using Mule Domain Project allowing them to share resources and connector versions which is not possible on Cloudhub.

Help Inform Azure Java EE Migration Guides

The Azure team at Microsoft (myself included) has been strengthening its commitment and outreach to the Java EE community and customers. A few months ago, I ran a study with the community and customers to understand how Java EE developers move to the cloud. One of the interesting findings of the study is that Java EE developers like to see migration guides that speak to their use case from cloud providers like Microsoft. Following up on these findings, the team is now developing just such guidance that hopefully speaks to you, starting with Linux virtual machines and Kubernetes.

The idea is to target Azure migration of major Java EE application server workloads (such as WebSphere ND, WebSphere Liberty, WebLogic, JBoss EAP, and WildFly). The guidance will likely include online documentation, ARM templates, Azure Marketplace solutions, Docker images, Helm charts, samples, workshops, talks, and so on. All the materials will be developed completely in open source so customers and the community can contribute at any point.

Creating Cosmos DB Resources Using ARM Templates

This week, we saw a significant update to the ARM template for Cosmos DB, which now allows us to create databases and containers. Up until now, we've only been able to create Cosmos DB accounts using templates, we then had to create the databases, containers, tables, etc. through PowerShell or the portal etc.

With this update, we are now able to deploy much more of our Cosmos setup with ARM templates, including databases, containers, graphs, namespaces, and tables. However, there are still some components we can't create with templates yet:

SWO With NXP i.MX RT1064-EVK Board

With the cost of a single pin, many ARM Cortex-M boards, including the NXP i.MX RT1064, can produce SWO data: Think about a pin that's able to stream data out of the chip in real-time. For example, it can interrupt activity, which, otherwise, might be hard to capture:

SWO Interrupt Trace

Azure Resource Manager Templates and Nested Loops: A Commentary

What is Azure Resource Manager, or ARM?

ARM is a Microsoft Azure provided managed service that enables an automation designer to define their design intent, expressed as templates, using ARM's automation language, which is currently AzureRM and is transitioning to Az.

ARM enables a designer to express their intent as to the selection, configuration, and assembly sequence of computing resource objects as specified by ARM automation resource templates.