Skip to content

Repository files navigation

FastFloat 0.1.1 [ALPHA-2026-08] — Ultra-Fast Native SIMD Float Parsing & Formatting for Java

Status License: MIT Java Platform JitPack


⚡ 5.1× faster than standard Java's Float.parseFloat / Double.parseDouble. Zero GC. SIMD accelerated. Ryu algorithm formatting.

FastFloat provides high-performance native float and double parsing and formatting for Java, replacing slow string allocations with native AVX2 SIMD vector operations.

Showcase


Quick Start — Example

import fastfloat.FastFloat;
import java.nio.ByteBuffer;

public class Demo {
    public static void main(String[] args) {
        // 1. 5.1× faster parsing — zero allocations
        float f = FastFloat.parseFloat("3.14159");
        double d = FastFloat.parseDouble("2.718281828459045");

        // 2. Zero-GC fast path (no exceptions, packed error/value result)
        long packed = FastFloat.parseFloatZeroGC("3.14159");
        if (FastFloat.unpackError(packed) == FastFloat.ERR_OK) {
            float value = FastFloat.unpackFloat(packed);
        }

        // 3. Ryu high-speed float/double formatting
        String formatted = FastFloat.toString(f);
    }
}

Table of Contents


Why FastFloat?

Standard Java Float.parseFloat() and Double.parseDouble() rely on complex, slow string allocations and Exception-throwing error handling. FastFloat addresses this by:

  • SIMD Vectorization — Uses native C++ AVX2 vector instructions for multi-digit parallel parsing.
  • Ryu Formatting — Implements the Ryu algorithm for ultra-fast, shortest-representation float-to-string conversion.
  • Zero-GC Fast Path — Bit-packed parseFloatZeroGC() eliminates JVM Garbage Collection overhead completely.
Feature Float.parseFloat / Double fast_float (C++ / JNI wrapper) FastFloat
Parsing Throughput ~4.23M ops/s ~12-15M ops/s 21.65M+ ops/s (5.1× speedup)
Error Handling Heavy NumberFormatException JNI boundary checks Zero-GC bit-packed primitive long
Direct Buffer Ingestion Must convert to String first Partial buffer support Direct off-heap ByteBuffer parsing
Formatting Algorithm Slow Grisu / Java Double.toString Standard snprintf / Grisu Ryu shortest-representation engine

Key Features

  • ⚡ Native AVX2 SIMD Acceleration — Leverages 256-bit AVX2 vector registers for ultra-fast digit scanning and conversion.
  • 🚀 5.1× Throughput Speedup — Reaches over 21.6 Million parsing operations per second on standard desktop hardware.
  • 🧠 Zero-GC Bit-Packed API — Returns packed error status and float values inside a primitive long to prevent heap allocations.
  • 🌐 Ryu Algorithm Formatting — Generates exact shortest string representations of floats and doubles with minimum latency.
  • 📦 Direct ByteBuffer Ingestion — Parses floats directly from off-heap ByteBuffer regions without converting to java.lang.String.

Real-World Use Cases

  • 📊 High-Frequency Financial Data Feed: Parse millions of stock quotes, ticks, and floating-point trade prices per second.
  • 🤖 Machine Learning Feature Ingestion: Accelerate CSV and JSON float feature parsing before feeding tensors into ONNX models.
  • 📡 IoT & Telemetry Sensor Streams: Process high-rate sensor readings directly from DMA native memory buffers without GC pauses.
  • 🎮 Game Engine Physics & Graphics: Deserialize 3D vertex positions and transformation matrices in real-time game loops.

Performance Benchmarks

In the official JMH Benchmark, FastFloat measured parsing throughput against standard Float.parseFloat():

Benchmark                             Mode  Cnt        Score   Error  Units
Benchmark.benchmarkFastFloatParse    thrpt    2  21656206.611          ops/s
Benchmark.benchmarkJavaFloatParse    thrpt    2   4236773.465          ops/s

21.6 Million Operations per Second (5.1× Speedup): FastFloat parses floating point strings at 21.65 Million ops/s, achieving a 5.1× hardware speedup over Java's standard Float.parseFloat() (4.23 Million ops/s).


Architecture Overview

FastFloat (This Library — The Native Math Engine)
Provides SIMD-accelerated float/double parsing and Ryu formatting for Java.

FastSIMD (Hardware Acceleration Engine)
Provides cross-platform hardware SIMD primitives (_mm256_cmpeq_epi8, _mm256_fmadd_ps).

FastJSON (Zero-GC JSON Parser)
Integrates FastFloat for sub-microsecond JSON numerical field extraction.


API Quick Reference

Method Description Path
parseFloat(String) Standard 5.1× faster float parsing. Reference 📖
parseFloatZeroGC(String) Bit-packed zero-allocation float parsing. Reference 📖
toString(float) High-speed Ryu float formatting. Reference 📖

Technical Demos & Benchmarks

Run standalone verification demos or execute JMH throughput benchmarks:

Type Target / Launcher Source File Description
Interactive Demo run-demo.bat Demo.java Live float/double parsing, zero-GC bit-packed unpacking, and Ryu formatting
Throughput Benchmark run-benchmark.bat Benchmark.java JMH benchmark comparing SIMD FastFloat.parseFloat against Float.parseFloat

Installation

Option 1: Maven (Recommended)

Add the JitPack repository and the complete dependency stack to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <!-- FastFloat Engine -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastFloat</artifactId>
        <version>0.1.1</version>
    </dependency>

    <!-- FastSIMD Hardware Vector Acceleration Engine -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastSIMD</artifactId>
        <version>0.1.3</version>
    </dependency>

    <!-- FastMemory Aligned Allocator -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastMemory</artifactId>
        <version>0.1.1</version>
    </dependency>

    <!-- FastPointer Address Wrapper -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastPointer</artifactId>
        <version>0.1.1</version>
    </dependency>

    <!-- FastCore Native Loader -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastCore</artifactId>
        <version>0.1.0</version>
    </dependency>
</dependencies>

Option 2: Gradle (via JitPack)

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:FastFloat:0.1.1'
    implementation 'com.github.andrestubbe:FastSIMD:0.1.3'
    implementation 'com.github.andrestubbe:FastMemory:0.1.1'
    implementation 'com.github.andrestubbe:FastPointer:0.1.1'
    implementation 'com.github.andrestubbe:FastCore:0.1.0'
}

Option 3: Direct Download (No Build Tool)

Download the required JARs directly to add them to your classpath:

  1. ⚡ FastFloat-0.1.1.jar (The Core Library)
  2. 🚀 FastSIMD-0.1.3.jar (Hardware Vector Acceleration Engine)
  3. 💾 FastMemory-0.1.1.jar (32-Byte Aligned Allocator)
  4. 📍 FastPointer-0.1.1.jar (Primitive Address Pointer)
  5. ⚙️ fastcore-0.1.0.jar (Mandatory Native Loader)

Important

All JARs must be included in your classpath for the native SIMD JNI bindings to function correctly.


Documentation


Platform Support

Platform Status
Windows 10/11 (x64) ✅ Fully Supported
Linux 🔄 Planned
macOS 🔄 Planned

License

MIT License — See LICENSE file for details.


Related Projects

  • FastMath — SIMD and GPU vector math functions
  • FastJSON — High-speed SIMD JSON parser
  • FastBytes — AVX2 byte array operations
  • FastCore — Native JNI loader for FastJava libraries

Part of the FastJava Ecosystem — Making the JVM faster. Small package. Maximum speed. Zero bloat. ⚡

About

🔢 Ultra‑fast native float/double parsing for Java — SIMD‑accelerated, zero‑GC number decoding, ByteBuffer zero‑copy access, and Ryu‑powered formatting up to 1 GB/s for JSON, CSV, and telemetry pipelines.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages