Replacing Java's native sort with a Rust JNI engine (38x faster)

fbcouto1 pts0 comments

GitHub - fbcouto/java-multimerge-dll: This repository contains the high-performance native extension for the Java Virtual Machine (JVM) using the Multimerge parallel sorting algorithm. Β· GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

fbcouto

java-multimerge-dll

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

main

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>3 Commits<br>3 Commits

Images

Images

src

src

.gitignore

.gitignore

BenchmarkSort.java

BenchmarkSort.java

Cargo.toml

Cargo.toml

LICENSE

LICENSE

README.md

README.md

View all files

Repository files navigation

πŸš€ Adaptive Parallel Multimerge Sort (Java Native Extension via JNI)

This repository contains the high-performance native extension for the Java Virtual Machine (JVM) using the Multimerge parallel sorting algorithm.

By leveraging JNI (Java Native Interface) and the Rust toolchain, the core engine is compiled into a high-performance Dynamic Link Library (.dll on Windows / .so on Linux). This allows Java applications to offload intensive sorting workloads to multi-threaded hardware with absolute zero-copy memory overhead.

πŸ”— Core Algorithm & Academic Background

πŸ“Œ Note: The mathematical foundations, dynamic heuristics, and exhaustive standalone benchmarks of the Multimerge engine are fully detailed and tested in the primary repository:

πŸ‘‰ Core Multimerge Sorting Repository

The core theoretical foundation of this parallel architecture is based on the original research and paper:

Title: Multimerge

Authors: Fernando B. Couto & FΓ‘bio S. Couto

Conference: PDPTA'11 β€” The 2011 International Conference on Parallel and Distributed Processing Techniques and Applications

Lecture Series: WorldComp'11 (The 2011 World Congress in Computer Science, Computer Engineering, and Applied Computing)

The architecture implements a hybrid processing model based on the original Multimerge paper published in PDPTA'11 (The 2011 International Conference on Parallel and Distributed Processing Techniques and Applications).

It modernizes those multi-merge paradigms by utilizing runtime entropy sampling (an Adaptive Oscillation Heuristic) and Rayon's work-stealing parallel scheduler.

πŸ“Š Performance Demonstration

This engine serves as a candidate to augment or replace Java's standard Arrays.sort() in high-throughput data pipelines.

The following charts compare the performance of the Multimerge Rust engine versus native Java across four data scales:

πŸ”’ Numeric Dataset Benchmark

!images/javanumaleat.png

πŸ“ Text Dataset Benchmark

!images/javatextoaleat.png

πŸ› οΈ Engineering Implementation

The integration utilizes critical JNI memory pinning to eliminate Garbage Collector interference:

Zero-Copy Architecture: By using get_array_elements_critical, the engine accesses the JVM heap memory directly, preventing redundant data serialization.

Rust Core: The sorting logic is written in Rust, ensuring memory safety and massive parallelism via Rayon.

πŸ› οΈ Compilation & DLL Generation Guide

To bridge the gap between the Java Virtual Machine and Rust, the project compiles the core logic into a high-performance native library (.dll on Windows / .so on Linux). Java interfaces with this library using the Java Native Interface (JNI).

1. Prerequisites

Ensure your local environment has the following toolchains installed:

Rust Toolchain: Stable channel (cargo, rustc >= 1.70)

JDK: Version 8 or higher (javac, java)

2. Layout Structure

multimerge-Java-dll/<br>β”œβ”€β”€ Cargo.toml # Rust compilation manifest<br>β”œβ”€β”€ BenchmarkSort.java # Automated Java benchmark suite<br>└── src/<br>└── lib.rs # JNI Bindings + Core Algorithm

πŸ“œ License

This project is licensed under the Apache License, Version 2.0.

About

This repository contains the high-performance native extension for the Java Virtual Machine (JVM) using the Multimerge parallel sorting algorithm.

Resources

Readme

License

Apache-2.0 license

Uh oh!

There was an error while loading. Please reload this page.

Activity

Stars

stars

Watchers

watching

Forks

forks

Report...

java multimerge native rust parallel performance

Related Articles