Skip to content

Commit

Permalink
Merge pull request #43 from xerial/feature/buffer
Browse files Browse the repository at this point in the history
Split LArray into Java-based projects and Scala API
  • Loading branch information
xerial committed Dec 11, 2013
2 parents 28e9e60 + bd7bd95 commit 3cc8a6a
Show file tree
Hide file tree
Showing 75 changed files with 1,556 additions and 1,643 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
language: scala
scala:
- 2.10.3

script: sbt ++$TRAVIS_SCALA_VERSION test -Dloglevel=debug

branches:
only:
- develop
16 changes: 3 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ all: larray
include Makefile.common


SRC:=src/main/scala
SRC:=larray-mmap/src/main/scala

LARRAY_OUT:=$(TARGET)/larray-$(os_arch)
LARRAY_SRC_DIR:=$(SRC)/xerial/larray/impl
Expand All @@ -14,7 +14,6 @@ LARRAY_OBJ:=$(LARRAY_OUT)/LArrayNative.o
VERSION:=$(shell perl -npe "s/version in ThisBuild\s+:=\s+\"(.*)\"/\1/" version.sbt | sed -e "/^$$/d")



CFLAGS:=$(CFLAGS) -I$(LARRAY_SRC_DIR)

LARRAY_HEADER:=$(SRC)/xerial/larray/impl/LArrayNative.h
Expand All @@ -28,17 +27,8 @@ $(LARRAY_HEADER): $(SRC)/xerial/larray/impl/LArrayNative.java $(TARGET)/classes
@mkdir -p $(TARGET)/classes
$(JAVAH) -classpath $(TARGET)/classes -o $@ xerial.larray.impl.LArrayNative

bytecode: src/main/resources/xerial/larray/LArrayNativeLoader.bytecode

src/main/resources/xerial/larray/LArrayNativeLoader.bytecode: src/main/resources/xerial/larray/LArrayNativeLoader.java
@mkdir -p $(TARGET)/temp
$(JAVAC) -source 1.5 -target 1.5 -d $(TARGET)/temp $<
cp $(TARGET)/temp/xerial/larray/LArrayNativeLoader.class $@

VERSION_FILE:=src/main/resources/xerial/larray/VERSION

$(VERSION_FILE):
echo "version=$(VERSION)" > $@


$(LARRAY_OUT)/%.o : $(LARRAY_SRC_DIR)/%.c
Expand All @@ -55,12 +45,12 @@ clean-native:
clean:
rm -rf $(TARGET)

NATIVE_DIR:=src/main/resources/xerial/larray/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_DIR:=larray-mmap/src/main/resources/xerial/larray/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_TARGET_DIR:=$(TARGET)/classes/xerial/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME)

native: osinfo $(NATIVE_DLL)
larray: native $(VERSION_FILE) $(TARGET)/larray-$(VERSION).jar
larray: native $(TARGET)/larray-$(VERSION).jar

SBT:=./sbt

Expand Down
4 changes: 2 additions & 2 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TARGET:=target
SRC:=src/main/scala
TARGET:=larray-mmap/target
SRC:=larray-mmap/src/main/scala

ifndef JAVA_HOME
$(error Set JAVA_HOME environment variable)
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ A library for managing large off-heap arrays that can hold more than 2G (2^31) e
* Supports Memory-mapped file larger than 2GB
* Use `LArray.mmap`
* It can create memory regions that can be shared between processes.

## Performance

Here is a simple benchmark result that compares concurrent memory-allocation performances of LArray (with or without zero-filling), java arrays, `ByteBuffer.allocate` and `ByteBuffer.allocateDirect`, using Mac OS X with 2.9GHz Intelli Core i7. This test allocates 100 x 1MB of memory space concurrently using multiple threads, and repeats this process 20 times. All allocators except LArray are orders of magnitude slower than LArray, and consumes CPUs because they need to fill the allocated memory with zeros due to their specification.

```
-concurrent allocation total:2.426 sec. , count: 10, avg:0.243 sec. , core avg:0.236 sec. , min:0.159 sec. , max:0.379 sec.
-without zero-filling total:0.126 sec. , count: 20, avg:6.279 msec., core avg:2.096 msec., min:1.405 msec., max:0.086 sec.
-with zero-filling total:0.476 sec. , count: 20, avg:0.024 sec. , core avg:0.023 sec. , min:0.017 sec. , max:0.037 sec.
-java array total:0.423 sec. , count: 20, avg:0.021 sec. , core avg:0.021 sec. , min:0.014 sec. , max:0.029 sec.
-byte buffer total:1.028 sec. , count: 20, avg:0.051 sec. , core avg:0.044 sec. , min:0.014 sec. , max:0.216 sec.
-direct byte buffer total:0.360 sec. , count: 20, avg:0.018 sec. , core avg:0.018 sec. , min:0.015 sec. , max:0.026 sec.
```

## Limitations

Expand Down
198 changes: 0 additions & 198 deletions larray-buffer/src/main/java/xerial/larray/buffer/Buffer.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @author Taro L. Saito
*/
public class LArrayBuffer {
public class BufferConfig {

public static MemoryAllocator allocator = new OffHeapMemoryAllocator();
}
Loading

0 comments on commit 3cc8a6a

Please sign in to comment.