Authors: Ludovic Henry, Mark Ryan
Since early 2024, the Go programming language has seen significant progress on the RISC-V architecture, largely due to ongoing efforts within the RISE Project and key contributions to the Go runtime. This article explores the latest developments in Go’s RISC-V integration, focusing on performance enhancements, compiler optimizations, and broader ecosystem improvements.
Strengthening Go’s RISC-V Support Through RISE
The RISE Project (RISC-V Software Ecosystem) has played a critical role in accelerating software development for RISC-V. A major initiative under RISE, Project RP001: Accelerate the Go Runtime on RISC-V, has focused on refining Go’s compiler and runtime for RISC-V platforms. Key areas of improvement include:
- Compiler and Runtime Optimization: Significant efforts have been made to leverage RISC-V’s architectural features, such as the Vector and Bitmanip extensions, improving the efficiency of Go applications running on RISC-V hardware.
- Standard Library Enhancements: Work has been done to ensure that Go’s standard library fully supports RISC-V, including improvements in low-level libraries that interact directly with hardware features.
- Release starting in Go 1.21: Starting with Go 1.21, everyone can download binaries for linux-riscv64 straight from https://go.dev/dl.
These advancements reflect the collective contributions of developers working on Go’s RISC-V support, ensuring that the language remains performant and stable across various implementations of the architecture.
Community Contributions Driving Progress
Much of the progress in Go’s RISC-V support has been driven by a dedicated group of developers refining the standard library and the toolchain, having a tangible impact on performance. Some of the recent enhancements include:
- Expanding RISC-V Vector Support: Contributions to the Go assembler have added support for a broad set of vector operations, including integer arithmetic, floating-point operations, and bitwise manipulation. These changes ensure that Go can take full advantage of RISC-V’s vector capabilities for performance-critical applications.
- Dynamic Hardware Probing: The introduction of runtime detection for available RISC-V extensions allows Go applications to adjust their execution behavior based on hardware capabilities. This feature ensures optimized performance across different RISC-V implementations.
- Refining Memory Operations: Improvements in Go’s internal/bytealg package have introduced vectorized implementations of commonly used functions, such as memory equality checks, and have sped up the existing scalar implementations. These optimizations have contributed to measurable performance gains in Go applications running on RISC-V hardware.
- Enhancing Build-Time Configuration: Updates to the Go toolchain allow developers to specify RISC-V profiles (RVA20, RVA22, RVA23) during the build process, ensuring that generated binaries are optimized for specific hardware configurations.
- Improving Code Generation: The Go compiler now produces more efficient machine code for RISC-V, reducing instruction count and improving execution speed, and leveraging Bitmanip extensions where possible.
- Optimizing arbitrary-precision arithmetic: Handcoded assembler routines have been provided for the math/big package improving the performance of arbitrary-precision arithmetic on riscv64 devices.
- Optimizing crypto algorithms: The performance of various routines in the crypto package, notably md5, sha256 and sha512, on riscv64 devices have been improved by the addition of handcoded scalar assembler routines.
- Adding plugin support: The Go toolchain now supports plugins for the risc64 architecture.
The Road Ahead for Go on RISC-V
While the progress so far has been substantial, several challenges remain. High-performance RISC-V hardware is still in development, and further work is needed to optimize Go’s compiler for RISC-V-specific workloads (better Vector extension support, adding Compressed instructions). Additionally, continued investment in testing infrastructure will be essential to ensure long-term stability and compatibility.
The RISE Project’s efforts, combined with ongoing contributions from the Go developer community, are positioning RISC-V as a viable architecture for Go-based applications. As these advancements continue, Go developers can expect even greater performance and stability on RISC-V platforms, paving the way for broader adoption in cloud environments, and beyond.