bramp / Unsafe
Licence: bsd-2-clause
Assorted java classes that make use of sun.misc.Unsafe
Stars: ✭ 74
Programming Languages
java
68154 projects - #9 most used programming language
Labels
Projects that are alternatives of or similar to Unsafe
Scalajs Benchmark
Benchmarks: write in Scala or JS, run in your browser. Live demo:
Stars: ✭ 63 (-14.86%)
Mutual labels: benchmark
Web Components Benchmark
Web Components benchmark for a various Web Components technologies
Stars: ✭ 69 (-6.76%)
Mutual labels: benchmark
Ossf Cve Benchmark
The OpenSSF CVE Benchmark consists of code and metadata for over 200 real life CVEs, as well as tooling to analyze the vulnerable codebases using a variety of static analysis security testing (SAST) tools and generate reports to evaluate those tools.
Stars: ✭ 71 (-4.05%)
Mutual labels: benchmark
Gl vs vk
Comparison of OpenGL and Vulkan API in terms of performance.
Stars: ✭ 65 (-12.16%)
Mutual labels: benchmark
Crypto Bench
Benchmarks for crypto libraries (in Rust, or with Rust bindings)
Stars: ✭ 67 (-9.46%)
Mutual labels: benchmark
Quantum Benchmarks
benchmarking quantum circuit emulators for your daily research usage
Stars: ✭ 70 (-5.41%)
Mutual labels: benchmark
Rb
A thread-safe fixed-size circular buffer written in safe Rust.
Stars: ✭ 59 (-20.27%)
Mutual labels: benchmark
Http Benchmark Tornado
基于Python Tornado的高性能http性能测试工具。Java Netty版: https://github.com/junneyang/http-benchmark-netty 。
Stars: ✭ 67 (-9.46%)
Mutual labels: benchmark
Appdocs
Application Performance Optimization Summary
Stars: ✭ 1,169 (+1479.73%)
Mutual labels: benchmark
Http Benchmarks
Benchmarks for common embedded Java and Kotlin web frameworks
Stars: ✭ 65 (-12.16%)
Mutual labels: benchmark
Evalne
Source code for EvalNE, a Python library for evaluating Network Embedding methods.
Stars: ✭ 67 (-9.46%)
Mutual labels: benchmark
Ncnn Benchmark
The benchmark of ncnn that is a high-performance neural network inference framework optimized for the mobile platform
Stars: ✭ 70 (-5.41%)
Mutual labels: benchmark
Freqbench
Comprehensive CPU frequency performance/power benchmark
Stars: ✭ 65 (-12.16%)
Mutual labels: benchmark
Asr benchmark
Program to benchmark various speech recognition APIs
Stars: ✭ 71 (-4.05%)
Mutual labels: benchmark
Benchmark Websocket
Websocket Client and Server for benchmarks with Millions of concurrent connections.
Stars: ✭ 62 (-16.22%)
Mutual labels: benchmark
Jsperf.com
jsperf.com v2. https://github.com/h5bp/lazyweb-requests/issues/174
Stars: ✭ 1,178 (+1491.89%)
Mutual labels: benchmark
Attabench
Microbenchmarking app for Swift with nice log-log plots
Stars: ✭ 1,167 (+1477.03%)
Mutual labels: benchmark
Unsafe
by Andrew Brampton (bramp.net)
This is a collection of tools that make use of the sun.misc.Unsafe class. This Unsafe class allows direct access to memory within the JVM, which is extremely dangerous, but fun :).
- unsafe-helper - Contains some simple methods that make using sun.misc.Unsafe easier.
- unsafe-collection - An example List modelled on the ArrayList, which instead of storing reference to objects within
the collection, instead copies the elements directly into the list. This has a few interesting properties
- Less total memory is required for the list and contained objects. Reducing GC overheads.
- The objects are guranteed to be contingous in memory, which may provide some good CPU cache benefits.
- Objects are copied into the list, this copy overhead may not be worth it, and you lose many of the reference semantics you would be used t
- unsafe-unroller - At runtimes generates optomal bytecode to copy objects with the Unsafe class.
- unsafe-benchmark - Code to benchmark everything using the JMH framework.
- unsafe-tests - Some simple test classes to help with tests of the other modules.
Read about this in a series of articles:
- Part 1: sun.misc.Unsafe Helper Classes
- Part 2: Using sun.misc.Unsafe to create a contiguous array of objects
- Part 3: Benchmarking a java UnsafeArrayList
Use
Requires Java 7 or higher. To include use the following Maven dependency:
<dependencies>
<dependency>
<groupId>net.bramp.unsafe</groupId>
<artifactId>unsafe-helper</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
Build
To build use maven, e.g mvn
To release to maven central, we use the Sonatype OSS repo, and maven-release-plugin:
mvn release:prepare
mvn release:perform
Benchmarks
Read more about the benchmarks at bramp.net
cd unsafe-benchmark
mvn
java -jar target/benchmarks.jar | tee logs
...
# JMH 1.10.3 (released 9 days ago)
# VM version: JDK 1.8.0_45-internal, VM 25.45-b02
Benchmark Mode Cnt Score Error Units
UnrolledCopierBenchmark.HandUnrolledState.test thrpt 25 438819259.527 ± 14364692.101 ops/s
UnrolledCopierBenchmark.LoopState.test thrpt 25 196408390.244 ± 2173851.339 ops/s
UnrolledCopierBenchmark.UnrolledState.test thrpt 25 458324068.892 ± 6192069.477 ops/s
Benchmark (clazz) (size) Mode Cnt Score Error Units
ArrayListBenchmark.testIterate ArrayList<LongPoint> 80000000 avgt 5 2.266 ± 0.229 s/op
ArrayListBenchmark.testIterate ArrayList<LongPoint> 20000000 avgt 5 0.552 ± 0.019 s/op
ArrayListBenchmark.testIterate ArrayList<LongPoint> 5000000 avgt 5 0.136 ± 0.004 s/op
ArrayListBenchmark.testSort ArrayList<LongPoint> 80000000 avgt 5 70.310 ± 3.939 s/op
ArrayListBenchmark.testSort ArrayList<LongPoint> 20000000 avgt 5 14.754 ± 0.541 s/op
ArrayListBenchmark.testSort ArrayList<LongPoint> 5000000 avgt 5 3.250 ± 0.139 s/op
Benchmark (clazz) (size) Mode Cnt Score Error Units
ArrayListBenchmark.testIterate UnsafeArrayList<LongPoint> 80000000 avgt 5 1.790 ± 0.030 s/op
ArrayListBenchmark.testIterate UnsafeArrayList<LongPoint> 20000000 avgt 5 0.449 ± 0.016 s/op
ArrayListBenchmark.testIterate UnsafeArrayList<LongPoint> 5000000 avgt 5 0.112 ± 0.001 s/op
ArrayListBenchmark.testListIterateInPlace UnsafeArrayList<LongPoint> 80000000 avgt 5 0.442 ± 0.023 s/op
ArrayListBenchmark.testListIterateInPlace UnsafeArrayList<LongPoint> 20000000 avgt 5 0.110 ± 0.003 s/op
ArrayListBenchmark.testListIterateInPlace UnsafeArrayList<LongPoint> 5000000 avgt 5 0.028 ± 0.002 s/op
ArrayListBenchmark.testSort UnsafeArrayList<LongPoint> 80000000 avgt 5 18.690 ± 3.158 s/op
ArrayListBenchmark.testSort UnsafeArrayList<LongPoint> 20000000 avgt 5 3.414 ± 0.034 s/op
ArrayListBenchmark.testSort UnsafeArrayList<LongPoint> 5000000 avgt 5 0.682 ± 0.014 s/op
Benchmark (clazz) (size) Mode Cnt Score Error Units
ArrayListBenchmark.testIterate ArrayList<FourLongs> 80000000 avgt 5 2.277 ± 0.211 s/op
ArrayListBenchmark.testIterate ArrayList<FourLongs> 20000000 avgt 5 0.557 ± 0.023 s/op
ArrayListBenchmark.testIterate ArrayList<FourLongs> 5000000 avgt 5 0.140 ± 0.007 s/op
ArrayListBenchmark.testSort ArrayList<FourLongs> 80000000 avgt 5 79.673 ± 6.119 s/op
ArrayListBenchmark.testSort ArrayList<FourLongs> 20000000 avgt 5 16.705 ± 1.353 s/op
ArrayListBenchmark.testSort ArrayList<FourLongs> 5000000 avgt 5 3.673 ± 0.156 s/op
Benchmark (clazz) (size) Mode Cnt Score Error Units
ArrayListBenchmark.testIterate UnsafeArrayList<FourLongs> 80000000 avgt 5 2.126 ± 0.019 s/op
ArrayListBenchmark.testIterate UnsafeArrayList<FourLongs> 20000000 avgt 5 0.533 ± 0.004 s/op
ArrayListBenchmark.testIterate UnsafeArrayList<FourLongs> 5000000 avgt 5 0.133 ± 0.002 s/op
ArrayListBenchmark.testListIterateInPlace UnsafeArrayList<FourLongs> 80000000 avgt 5 0.648 ± 0.019 s/op
ArrayListBenchmark.testListIterateInPlace UnsafeArrayList<FourLongs> 20000000 avgt 5 0.163 ± 0.005 s/op
ArrayListBenchmark.testListIterateInPlace UnsafeArrayList<FourLongs> 5000000 avgt 5 0.040 ± 0.006 s/op
ArrayListBenchmark.testSort UnsafeArrayList<FourLongs> 80000000 avgt 5 24.822 ± 0.790 s/op
ArrayListBenchmark.testSort UnsafeArrayList<FourLongs> 20000000 avgt 5 4.843 ± 0.075 s/op
ArrayListBenchmark.testSort UnsafeArrayList<FourLongs> 5000000 avgt 5 1.020 ± 0.017 s/op
Benchmark (clazz) (size) Mode Cnt Score Error Units
ArrayListBenchmark.testIterate ArrayList<EightLongs> 80000000 avgt 5 2.792 ± 0.072 s/op
ArrayListBenchmark.testIterate ArrayList<EightLongs> 20000000 avgt 5 0.564 ± 0.022 s/op
ArrayListBenchmark.testIterate ArrayList<EightLongs> 5000000 avgt 5 0.138 ± 0.007 s/op
ArrayListBenchmark.testSort ArrayList<EightLongs> 80000000 avgt 5 97.687 ± 4.860 s/op
ArrayListBenchmark.testSort ArrayList<EightLongs> 20000000 avgt 5 20.084 ± 1.124 s/op
ArrayListBenchmark.testSort ArrayList<EightLongs> 5000000 avgt 5 4.474 ± 0.248 s/op
Benchmark (clazz) (size) Mode Cnt Score Error Units
ArrayListBenchmark.testIterate UnsafeArrayList<EightLongs> 80000000 avgt 5 2.672 ± 0.322 s/op
ArrayListBenchmark.testIterate UnsafeArrayList<EightLongs> 20000000 avgt 5 0.688 ± 0.014 s/op
ArrayListBenchmark.testIterate UnsafeArrayList<EightLongs> 5000000 avgt 5 0.171 ± 0.003 s/op
ArrayListBenchmark.testListIterateInPlace UnsafeArrayList<EightLongs> 80000000 avgt 5 0.941 ± 0.032 s/op
ArrayListBenchmark.testListIterateInPlace UnsafeArrayList<EightLongs> 20000000 avgt 5 0.236 ± 0.008 s/op
ArrayListBenchmark.testListIterateInPlace UnsafeArrayList<EightLongs> 5000000 avgt 5 0.058 ± 0.002 s/op
ArrayListBenchmark.testSort UnsafeArrayList<EightLongs> 80000000 avgt 5 40.697 ± 0.743 s/op
ArrayListBenchmark.testSort UnsafeArrayList<EightLongs> 20000000 avgt 5 7.608 ± 0.267 s/op
ArrayListBenchmark.testSort UnsafeArrayList<EightLongs> 5000000 avgt 5 1.729 ± 0.101 s/op
Further Reading
- Java Objects Memory Structure
- sun.misc.Unsafe Javadoc
- OpenJDK Unsafe source
- The infamous sun.misc.Unsafe explained
- Dangerous Code: How to be Unsafe with Java Classes & Objects in Memory
JMH
Licence (Simplified BSD License)
Copyright (c) 2016, Andrew Brampton
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].