Latest News

NavPi memory issues resolved

NavPi memory issues resolved

Mike Delucchi
30 Jul 2018

As most veteran NavPi users know, there has been a significant issue with the memory resources being completely maxed out while running the NavCoin daemon. It’s been a frustrating issue and the core team has been focused on solving the problem by engineering both short and long term solutions.

As most veteran NavPi users know, there has been a significant issue with the memory resources being completely maxed out while running the NavCoin daemon. It’s been a frustrating issue and the core team has been focused on solving the problem by engineering both short and long term solutions.

The problem; memory is maxed

When the NavCoin daemon starts, it loads the chainstate database — containing information on the entire blockchain — in memory. This causes the NavPi’s RAM usage to peak until that operation is complete, resulting in sluggish performance and occasional crashes. Advanced users of the NavPi have made various tweaks to their systems for optimised performance, but for new users the initial setup and configuration mods are most certainly daunting tasks.

The short term solution; add swap space

Creating dedicated swap space was the key to resolving the memory issue, and we focused on these three approaches; ZRAM swap, USB swap, and SD card swap.

What is the function of swap space?

The swap space is an area on the Raspberry Pi’s SD card (or additional USB drive) intended as a place the operating system can store data temporarily for quick access. This allows the Raspberry Pi to function as as if it has higher RAM (memory) than it actually does.

How does NavPi use swap space?

NavPi uses the swap space to increase the amount of information it can process “in memory” while syncing the blockchain and performing other essential operations.

ZRAM swap

The initial approach to the problem was to enable ZRAM on the NavPi as a temporary fix. For many users it seemed to help, but during the core team’s testing cycles there were still resource issues on the initial load of the chain state in memory.

SD swap

As another temporary solution, we created an article on the Knowledge Base demonstrating how to enable the swap space on the SD card of the NavPi. The steps in the article were based on an article written by Justin Ellingwood of Digital Ocean and tested successfully on the NavPi. While this approach did result in added stability for both the NavCoin daemon and the Chromium WebUI, it is not our recommended approach long-term as this may cause the NavPi’s SD Card to wear out faster.

USB swap

For best results, it’s recommended to utilize a USB drive as your swap space, since repeated reads/writes to the SD card may wear it out. There are multiple articles, posts and resources from the linux and Raspbian community demonstrating how to setup a swap space on a USB. We tested many approaches and created our own version intended for the NavPi, which is now documented Knowledge Base.

Long-term solutions

There are plans to enhance the NavPi to remedy the memory issue long term, including:

  • Optimise NavCoin core (specifically it’s levelDB databases)
  • Support the new Raspberry Pi 3b + (OS upgrade)
  • Updated to run NavCoin v4.2.1
  • Includes fully-synced blockchain
  • ZRAM swap space enabled and prioritised
  • Default SD swap space increased to 500MB

This version has been optimised, removing many of the non-essential Raspbian applications that come pre-installed. The end result is a much smaller disk image (6GB) that will auto-expand upon initial boot of the NavPi.

This release can be downloaded from the NavPi Project Page

Installation notes

After downloading v1.0.9, you’ll need to use a program like Etcher to flash the new image onto your SD card. After booting up the NavPi with the updated card installed, the NavCoin daemon should start automatically. If you have a keyboard and mouse connected, you can launch Chromium and use the WebUI.

The memory usage will initially spike as the chainstate database is loaded, but it should stabilise within about 10 minutes. Enjoy the new update and please report any problems to the NavPi project’s issues on GitHub or post in the #navpi-support channel in the NavCoin Discord server.

Mike Delucchi
30 Jul 2018