Apr 9, 2018

Flash Memory Internals Explored

Last updated - 2018/04/09

Micron

3D NAND - 1st generation

Micron 3D NAND
Micron 3D NAND Datasheet
I found this table interesting enough that I wanted to highlight it. Micron seem to manufacture the chips in a way that the page size remains the standard 16KiB but the erase block is a multiple of three (above should read 24MiB + 2208KiB). The 2208KiB is simply where the error correction information is stored. Unfortunately, there is no information about the number of expected erase cycles.

Anandtech also shares the following details about Micron's 3D NAND
On a smaller scale, the 3D NAND will have a page size of 16kB and erase block sizes of 16MiB for the MLC and 24MiB for the TLC. Because CPUs and file systems are still mostly dealing with 4KiB chunks, Micron has included a partial page read capability that allows for a 4KiB read to be done a bit faster and with about half the power of a full 16KiB page read.
This is an interesting data point, one which we can take a look at with programs like "flashbench". Sometimes one can spot half page reads (8KiB) being faster but optimizing for file system page size is even better.

Toshiba

BiCS 3 QLC (3D NAND)

Details are very scarce about these chips, except that dies are available in 768Gb capacities and that endurance of this solution is confirmed to be around 1000 erase cycles (Toshiba QLC NAND - Anandtech).

BiCS 4

Not much information is available, except that it features 96 layers.

Oct 2, 2017

HP Chromebook 11 G1/G2 Performance Fixes

One of the problems with this laptop, has always been performance. There are various issues on ChromeOS, some which can be mitigated:
  • Bugged thermal governor script - drops CPU to 700MHz constantly.
  • Compressed swap slows down the CPU, while ChromeOS does a great handling of out of memory conditions.
  • 1080p60 video support only for H.264, which is not the default codec on Youtube.
Both the software issues can be solved by running a 'tweaks' script and then a replacement 'thermal' script that gracefully drops clocks as it the CPU heats up - these are available on my Github repo.
You need to do this on a console after the system boots, due to read only root filesystem.

Without swap you will get more tabs killed but the behaviour is mostly excellent as long as you reboot every couple days to clean memory leaks. When using ZSWAP, it will be pushing the CPU constantly and slow downs are plenty.

For Youtube, you need to use the h264ify plugin but this will only work when you open Youtube directly - the plugin can't access data from other websites, rightfully so. This way the hardware decoder is used and it can play video smoothly.

Still, the system is a bit slow for some tasks. My experience installing Arch Linux is much faster, as it also uses much less RAM. This is a lot harder and is work in progress but using Firefox 55 is faster than the current Chromium builds - both on benchmarks and real scenarios.

HP Chromebook 11 G1/G2 Repairs

TLDR

I have tested and recommend the following replacement hardware for charging problems:

Sep 1, 2016

MySQL - Root Password Reset

To reset the MySQL root password, we need to start MySQL in safe mode. Type in the console:

sudo service mysqld stop
sudo mysqld_safe --skip-grant-tables &
mysql -u root mysql

Then you'll be on the MySQL prompt where you should define the new password:

UPDATE user SET password=PASSWORD("abcd") WHERE user="root";
FLUSH PRIVILEGES;
exit

After this you should have dropped to the Linux console again, where you need to restart the service to enable the grant tables again:

sudo killall mysqld_safe
ps ax | grep mysqld # Is it gone?
sudo service mysqld start
mysql -u root -p mysql

Notes

Tested on:
  • Gentoo Linux
  • Red Hat Enterprise Linux 5/6/7

Sep 13, 2014

Quality VPS Server Providers

Last updated: October, 2017

A Root Server or, most commonly, a root virtual private server (VPS) is typically a Linux or Windows based server where you have full control over the operating system.
I take a look at three providers:

TL;DR

At this time, I have dropped Hetzner's services due to drops in performance in new VPS products. I have changed providers to Vultr and have been much happier ever since.
Scaleway is interesting but I have experienced data center issues, among others, so don't recommend them for anything critical.

General Tips

The use of good virtualization software is the first and most important feature of a quality root server, as OpenVZ/Virtuozzo (operating system level virtualization) allows oversubscribing that delivers both lower prices and terrible performance (most of the time). You also can't use swap with OpenVZ, so that doesn't leave a lot of margin for error in the server's configuration for periods of high load. I recommend you to stay away from OpenVZ for these reasons.

KVM and Xen solutions do not allow oversubscribing and deliver much more consistent performance, albeit peak is lower.

Other requirements matched for these providers:
  • No contract termination for full resource usage (CPU, disk).
  • Offline console.
  • Custom ISO install (Vultr).

Providers

Hetzner

This German based provider offers not only root servers of the VPS variety but also dedicated servers, web hosting and collocation services. I have used the VQ7 VPS service, which had the following characteristics:
  • 1 Virtual CPU
  • 512 MiB of RAM
  • 25 GB of HDD space
  • 2 TB of traffic
  • KVM Virtualization
  • Full root access
Hetzner not only provides the offline console but also a Linux rescue system, which then lets you install any distribution or lets you recover the machine from any state.  Offline consoles are especially important if the providers don't have 24/7 support or any kind of management of the instances, as is the case with Hetzner. If you need 24/7 support, you need to contract one of their more expensive root server offerings, which start at €50/$69. Support has always been helpful and problems were with ease.

Hetzner has, in the last few years, upgrade to "CX" plans that have better hardware and a network SSD for disk space. My benchmarks of these machines have been very underwhelming, with incosistent performance on both the I/O and processing. Equivalent plans benchmarked much lower than VQ plans and are generally uninteresting compared to other offers.

Scaleway

A more nimble member of the Online.net french server provider, it has come to market with the very cheap C1 dedicated ARM server. They have been expanding and now offer more powerful ARMv8 servers (up to 64 cores w/ 128GB of RAM) and x86-64 offers of both virtual and dedicated variety.

Always interesting to test software, deploying servers is easy and the online panel is great, as is the pricing. Downsides have been insecure systems that transfer kernel modules unencrypted over network connections and I've experienced network issues with no notice issued.

I wouldn't use them, right now, for anything critical but they may be interesting for testing software or ARMv8 servers.

Vultr

Offering two types of servers over 15 datacenters spread worldwide, Vultr is not the cheapest provider but offers several features many don't:
  • Free disk snapshots.
  • Custom ISO installs.
  • High quality, low latency VNC client over the browser.
  • Network disk add-ons on high redundancy hardware (Block Storage), on the NJ datacenter.
Plans start at $2.50 for VC2 instances, matching most of the competitors, and price doesn't change with datacenter location.
Performance has been great and the control panel is clearly among the best out there.
Windows Server options are also available at a reasonable price, so pretty much anything you need should be covered by Vultr.

May 9, 2014

NGINX - Performance Tuning

Naked Domain Redirect

On most situations, one can use this code to redirect to the www sub-domain:

server {
    ...
    if ( $host !~* ^www\. )
    {
        rewrite ^(.*)$ http://www.domain.com$1;
    }
}

This has performance issues since NGINX has to evaluate the IF block for every request. Instead, you can use server blocks perform a HTTP 301 redirect:

server {
    listen 123.123.123.123;
    server_name domain.com;
    return 301 http://www.domain.com$request_uri;
}

server {
    listen 123.123.123.123;
    server_name www.domain.com;
    ...

}

Apr 28, 2014

Linux Kernel - Forcing a Crash

In software development, it is sometimes important to have resiliency to crashes in the software. It is less impractical though, to induce a crash in a remote machine, which may not be easily power cycled. For this purpose, the Magic SysRq Linux kernel functionality can be tapped into:

echo "b" > /proc/sysrq-trigger # Emulates a crash

The most relevant options, from the Linux kernel manual:
  • b - Reboots the kernel without first unmounting file systems or syncing disks attached to the system.
  • c - Crashes the system without first unmounting file systems or syncing disks attached to the system.
  • o - Shuts off the system.