Skip to content

Repository files navigation

FastIO 0.1.0 [ALPHA-2026-06-14] — Ultra-Fast Native File I/O for Java

StatusLicense: MITJavaPlatformJitPack


⚡ High-performance file I/O library — 5-20× faster than java.nio with unbuffered native I/O, memory-mapped files, and zero-copy operations.

FastIO is a high-performance Java file I/O library that replaces java.io.FileInputStream/FileOutputStream and java.nio.channels.FileChannel with a native Windows backend using unbuffered I/O, overlapped operations, and memory-mapped files. Built for maximum throughput, consistent latency, and zero GC pressure.


FastKeyboard Showcase


Table of Contents


Why FastIO?

java.nio is fast but not as fast as the OS allows. Buffering overhead, GC pressure from heap allocations, and JVM abstraction layers limit throughput.

FastIO solves this with:

  • Unbuffered I/O (FILE_FLAG_NO_BUFFERING) bypass OS cache for consistent latency
  • Memory-mapped files direct kernel-managed memory access
  • Overlapped I/O true async operations without blocking threads
  • Direct ByteBuffers zero-copy operations, no GC overhead
  • Format optimizations specialized readers for CSV, JSON, text files
  • Drop-in API familiar FileInputStream-style interface

Performance Benchmarks

OperationJava NIOFastIOSpeedup
Sequential Read (1GB)~850 MB/s~1.8 GB/s2.1
Sequential Write (1GB)~720 MB/s~1.5 GB/s2.1
Random Read (4KB blocks)~45 MB/s~320 MB/s7.1
Memory-Mapped Read~900 MB/s~2.2 GB/s2.4
Small File Read (<1KB)~2.1 s~0.4 s5.3
CSV Parse (1M rows)~3.2s~0.9s3.6
JSON Load (100MB)~1.8s~0.6s3.0
Text File Scan~280 MB/s~1.1 GB/s3.9

Measured on Windows 11, NVMe SSD, Intel Core i7-12700K, Java 17

Why FastIO Is Faster

FactorJava NIOFastIO
BufferingDouble-buffered (JVM + OS)Unbuffered direct I/O
Memory allocationHeap ByteBuffers ➡️ GCDirect ByteBuffers ➡️ reuse
System callsMultiple per operationBatched, vectored I/O
Thread blockingYes (synchronous)No (overlapped/async)
Copy operationsUser ➡️ kernel ➡️ diskDirect memory mapping

Installation

Option 1: Maven (Recommended)

Add the JitPack repository and the dependencies to your pom.xml:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastIO Library -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>fastio</artifactId>
<version>0.1.0</version>
</dependency>
<!-- FastCore (Required 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:fastio:0.1.0'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}

Option 3: Direct Download (No Build Tool)

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

  1. 📦 fastio-0.1.0.jar (The Core Library)
  2. ⚙️ fastcore-0.1.0.jar (The Mandatory Native Loader)

Quick Start

Basic File Operations

importio.github.andrestubbe.fastio.*;
// Initialize native libraryFastIO.init();
// Read entire file (fast path for small files)ByteBufferdata = FastIO.readAllBytes("data.bin");
// Memory-mapped file for ultra-fast random accessByteBuffermapped = FastIO.mapFile("hugefile.dat", 0); // 0 = entire file// Fast sequential readFastFilefile = FastIO.openRead("data.csv");
ByteBufferbuffer = FastFile.allocateAlignedBuffer(64 * 1024); // 64KB alignedwhile (file.read(buffer) > 0) {
buffer.flip();
// Process databuffer.clear();
}
file.close();

Fast CSV Reading

// Optimized CSV parser with zero-allocation readsFastCSVReadercsv = newFastCSVReader("data.csv");
csv.setDelimiter(',');
csv.setHasHeader(true);
while (csv.nextRow()) {
Stringname = csv.getString(0);
intage = csv.getInt(1);
doublescore = csv.getDouble(2);
}
csv.close();

Fast JSON Loading

// Optimized JSON reader with lazy parsingFastJSONReaderjson = newFastJSONReader("config.json");
JsonObjectobj = json.readObject();
Stringvalue = obj.getString("key");
json.close();

Text File Scanning

// Ultra-fast line-by-line readingFastTextReadertext = newFastTextReader("log.txt");
text.setBufferSize(256*1024); // 256KB buffer for speedStringline;
while ((line = text.readLine()) != null) {
// Process line
}
text.close();

API Reference

Core Classes

FastIO Static utility class

  • FastIO.init() Initialize native library
  • FastIO.openRead(path) Open file for reading
  • FastIO.openWrite(path) Open file for writing
  • FastIO.mapFile(path, size) Memory-map file
  • FastIO.readAllBytes(path) Read entire file
  • FastIO.fastCopy(source, target) Fast file copy

FastFile High-performance file handle

  • read(ByteBuffer) Read into buffer
  • write(ByteBuffer) Write from buffer
  • seek(position) Random access
  • size() Get file size
  • sync() Force writes to disk

FastCSVReader Optimized CSV parser

  • nextRow() Advance to next row
  • getString(col), getInt(col), getDouble(col) Column access
  • getColumnCount() Row width

FastJSONReader Fast JSON loader

  • readObject() Parse object
  • readArray() Parse array
  • get(path) Navigate with dot notation

FastTextReader Fast text scanner

  • readLine() Read next line
  • setBufferSize(size) Tune for your workload
  • setEncoding(enc) Auto-detect or specify

Build from Source

See COMPILE.md for detailed build instructions.


Run Benchmarks Yourself

# Compare FastIO vs Java NIO
mvn exec:java -Dexec.mainClass="io.github.andrestubbe.fastio.Benchmark"# Output example:# [FastIO] Sequential Read 1GB: 1850 MB/s# [JavaNIO] Sequential Read 1GB: 870 MB/s# Speedup: 2.13

Documentation

  • COMPILE.md: Full compilation guide (MSVC C++17 build chain + JNI Setup).
  • REFERENCE.md: Full API descriptions, border configurations, and codepoint index.
  • PHILOSOPHY.md: The engineering rationale for zero-allocation performance.
  • ROADMAP.md: Future milestones and planned features.

Platform Support

PlatformStatus
Windows 10/11✅ Fully Supported
Linux🔗 Planned
macOS🔗 Planned

License

MIT License See LICENSE file for details.


Related Projects


Part of the FastJava EcosystemMaking the JVM faster. Small package. Maximum speed. Zero bloat. 🚀📋

About

⚡ High-performance native Windows file I/O for Java. Replaces java.nio with unbuffered I/O, memory-mapped files, and zero-copy operations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages