Hot memory access for Haxe
Created to provide significantly boosted performance for typed arrays. Reduce amount of memory.
Target | Array | Array<->Bytes | ArrayBytes | HotBytes | Implementation |
---|---|---|---|---|---|
cpp | + | + | + | + | hxcpp_memory / pointer |
flash | + | + | + | + | Memory Domain |
js | + | + | + | + | Parallel Typed Arrays |
nodejs | + | + | + | + | Parallel Typed Arrays* |
cs | + | - | + | + | NativeArray_T / Unsafe |
java | + | - | + | + | NativeArray_T / Unsafe |
neko | + | - | - | + | NativeArray_T / String |
Define -D hotmem_debug
enabling bounds checking, traces and additional asserts
Create your static dense fixed-length typed arrays before performance critical operations.
Use ArrayBytes
if you need access to hot-array memory
For haxe.io.BytesData
memory use HotMemory::lock
and HotBytes
Targets unification:
- All operations should be type-size aligned.
- All
HotMemory::lock
operations requireHotMemory::unlock
at the end. - For
flash
target you should be careful withApplicationDomain.current.memoryDomain
hotmem.U8
: 8-bit unsigned inthotmem.U16
: 16-bit unsigned inthotmem.I32
: 32-bit signed inthotmem.F32
: 32-bit floating-point
For each types continuous memory fixed-length array is available (buffer)
hotmem.U8Array
: 8-bit unsigned int arrayhotmem.U16Array
: 16-bit unsigned int arrayhotmem.I32Array
: 32-bit signed int arrayhotmem.F32Array
: 32-bit floating-point array
Each hot array could be wrapped for memory read/write operations:
var view = array.view(?atElement);
view.setU8(bytePosition, value);
view.setU16(bytePosition, value);
view.setI32(bytePosition, value);
view.setF32(bytePosition, value);
value = view.getU8(bytePosition);
value = view.getU16(bytePosition);
value = view.getI32(bytePosition);
value = view.getF32(bytePosition);
For platform-specific fast memory access to the haxe.io.BytesData
content.
$hotmem> haxelib run hxmake generate
- More tests
- Missing types: I8, I16, U32, F64
- NodeJS buffers implementation
- More documentation on HotBytes (lock / unlock flow)
- Dox documentation