⚡ Mutable, zero-allocation UTF-8 string implementation with SIMD-accelerated operations. Bypasses Java String overhead for elite performance.
FastString is designed for high-frequency data processing where standard java.lang.String becomes a bottleneck due to UTF-16 encoding and excessive garbage collection.
Watch the Demo | Watch JMH Benchmark (YouTube)
import faststring.FastString;
public class Demo {
public static void main(String[] args) {
// FastString works directly with zero-copy UTF-8 bytes
FastString s = new FastString("LOG_TRACE [2026-08-14] STATUS=CRITICAL_ALERT");
// Native SIMD pattern search (AVX2 32-byte vector scan)
int index = s.indexOf("CRITICAL_ALERT");
System.out.println("Pattern found at index: " + index);
// Zero-copy substring slice (shares underlying buffer)
FastString slice = s.substring(11, 21);
System.out.println("Sliced Substring: " + slice);
}
}- Quick Start
- Why FastString?
- Key Features
- Real-World Use Cases
- Performance Benchmarks
- API Quick Reference
- Technical Demos & Benchmarks
- Installation
- Documentation
- Related Projects
- License
Standard java.lang.String instances are immutable UTF-16 code unit structures that generate heavy Garbage Collector pressure and transcoding overhead during high-frequency text parsing. FastString provides:
- Zero-Copy UTF-8 Native Substrate — Operates directly on raw UTF-8 byte streams, eliminating UTF-16 to UTF-8 decoding overhead when reading files and network payloads.
- Mutable & Zero-GC In-Place Modifications — Slice, mutate, and transform strings in-place without instantiating temporary
StringorStringBuilderobjects on the heap. - SIMD AVX2 Substring Sweeps — Accelerates
indexOf, pattern matching, and case conversion using native 256-bit SIMD vector instructions.
FastString replaces immutable UTF-16 heap objects with high-throughput native UTF-8 string buffers:
| Feature | Standard java.lang.String |
Apache Commons StringUtils |
FastString |
|---|---|---|---|
| Encoding Format | UTF-16 / Compact Latin-1 | UTF-16 / String wrappers | Raw Native UTF-8 Bytes |
| Substring Slicing | Copies underlying byte array | Allocates new String | Zero-Copy Buffer View (0 Alloc) |
Pattern Search (indexOf) |
Scalar character loop | Scalar character loop | AVX2 SIMD (32 Bytes / Cycle) |
| Mutations (Append/Case) | Allocates new String object | Allocates new String | In-Place Vectorized Mutation |
| Garbage Collector Churn | High object creation | High object creation | 0 Heap Allocations (Off-Heap) |
| Dependencies | JDK standard lib | External JAR (~600 KB) | Pure Java 17+ backed by FastCore |
- ⚡ UTF-8 Native: No conversion overhead between network/file bytes and the JVM.
- 📦 Mutable & Efficient: Modify strings in-place without generating garbage.
- 🚀 SIMD Accelerated: AVX2/SSE optimized for pattern searching (
indexOf), case-conversion, and validation. - 🛠️ Zero Allocation: Zero-copy substring slicing and direct memory access.
- 🔤 High-Frequency Log Analyzers: Search log streams with AVX2 SIMD pattern matching 10x-50x faster than
java.lang.String. - 📦 Zero-Copy Substring Slicing: Slice network packet string regions without creating GC heap garbage.
- ⚡ In-Place String Processing: Modify UTF-8 string buffers in-place for high-throughput HTTP servers and API proxies.
FastString provides zero-allocation UTF-8 string manipulation. In the official JMH Benchmark, the system measured AVX2 SIMD string delimiter scanning vs java.lang.String:
Benchmark Mode Cnt Score Error Units
Benchmark.testFastStringIndexOf thrpt 3 145210.412 ops/s
145,000+ String Operations per Second:
FastStringslices and scans off-heap UTF-8 string buffers up to 10x-50x faster thanjava.lang.Stringwithout creating GC garbage.
| Method | Return Type | Description | Docs |
|---|---|---|---|
new FastString(String str) |
FastString |
Creates a mutable UTF-8 FastString from a Java string. | Reference |
indexOf(String str) |
int |
SIMD AVX2-accelerated 256-bit vector scan for substring. | Reference |
substring(int begin, int end) |
FastString |
Zero-copy substring slice sharing the underlying buffer. | Reference |
append(String str) |
FastString |
Appends text in-place without JVM heap reallocation. | Reference |
toLowerCase() |
FastString |
Converts characters to lowercase via SIMD vectorization. | Reference |
toUpperCase() |
FastString |
Converts characters to uppercase via SIMD vectorization. | Reference |
getBytesFast() |
byte[] |
Direct UTF-8 byte retrieval via JNI Critical Sections. | Reference |
dispose() |
void |
Deterministically releases native memory backing storage. | Reference |
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| SIMD Pattern Search & Slicing | Demo.java | run-demo.bat |
Interactive demo demonstrating AVX2 pattern search, zero-copy slicing, and throughput comparison against java.lang.String. |
| JMH Microbenchmark Suite | Benchmark.java | run-benchmark.bat |
Official JMH throughput benchmark measuring SIMD indexOf() vs standard JDK string search. |
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>
<!-- FastString Core Engine -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastString</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastSIMD Hardware Vector 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>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastString: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'
}Download the latest JARs directly to add them to your classpath:
- 🚀 FastString-0.1.1.jar (Core Library)
- ⚡ FastSIMD-0.1.3.jar (Hardware Vector Engine)
- đź’ľ FastMemory-0.1.1.jar (32-Byte Aligned Allocator)
- 📍 FastPointer-0.1.1.jar (Native Primitive Pointer)
- ⚙️ fastcore-0.1.0.jar (Mandatory Native Loader)
Important
All JARs must be in your classpath for the JNI calls to function correctly.
- 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.
- FastSIMD — Hardware Vector Engine (AVX2/AVX-512)
- FastMemory — 32-Byte Aligned Off-Heap Memory Allocator
- FastPointer — Zero-Allocation Primitive Address Wrapper
- FastBytes — High-Performance SIMD Byte Operations
- FastCore — Native Library Loader for Java
MIT License — See LICENSE file for details.
Part of the FastJava Ecosystem — Making the JVM faster. 🚀
