Fast Random Access Log
Project description
Fast Random Access Log (FRAL)
FRAL is a concurrency-friendly log structure allocated over shared memory. Reads are random access and writes are non-blocking. The current shared-memory framework uses memory-mapped files. The core engine is written in C++ and Python bindings are provided for higher level and less performance-constrained usage. Utilizing Python's struct library can easily extend the log to a language-agnostic shared memory framework as demonstrated here. Early workings for syncing FRALs over standard networking (using gRPC and Protobuf) in a non-intrusive and reliable way are also provided. To normalize virtual memory addressing, allocation offsets from the start of the contiguous shared-memory space are stored in a fixed-sized array (see below).
Experimental findings show that the FRAL engine allows for completion of the parallel production and consumption of log entries at a nanosecond scale. With two writers and a single reader, the C++ implementation showed to support writing and reading over five million 100-byte log entries per second. Additionally, the FRAL engine saw a ~60x performance multiple over a similar interface written with SQLite.
For more detail on the implementation and performance, see this presentation.
Example Usage
The following simple usage is shown using two processes in parallel. Both the C++ and Python examples yield the below standard output:
TEST
TEST
DEST
C++
// Appender Process
auto ralA = fral::FRAL("test.bin");
const char *TEST_STR = "TEST";
auto blob = (char *) ralA.allocate(strlen(TEST_STR) + 1);
strcpy(blob, TEST_STR);
printf("%s\n", blob);
ralA.append(blob);
// Reader Process
auto ralB = fral::FRAL("test.bin");
for(;;){
auto blob2 = (char *) ralB[0];
if(blob2){
break;
}
}
printf("%s\n", blob2);
blob2[0] = 'D';
auto blob3 = (char *) ralB[0];
printf("%s\n", blob3);
Python
# Appender Process
ral_A = FRAL("test.bin")
test_bytes = "TEST".encode()
test_blob = ral_A.allocate(len(test_bytes))
test_blob[:len(test_bytes)] = test_bytes
print(bytes(test_blob).decode())
ral_A.append(test_blob)
# Reader Process
ral_B = FRAL("test.bin")
while True:
test_blob2 = ral_B[0]
if test_blob2:
break
print(bytes(test_blob2).decode())
test_blob2[0:1] = 'D'.encode()
test_blob3 = ral_B[0]
print(bytes(test_blob3).decode())
Performance Testing
Single Process Write Performance (1GB)
Testing the performance of writing 1GB with various allocation sizes and only one writer:
Multiprocess Write and Read Performance
Testing the performance of writing and reading 1GB with various allocation
sizes and multiple writers:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fral-0.0.1-cp312-cp312-macosx_12_0_arm64.whl.
File metadata
- Download URL: fral-0.0.1-cp312-cp312-macosx_12_0_arm64.whl
- Upload date:
- Size: 42.2 kB
- Tags: CPython 3.12, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6def2621e0de2eec39a5aed7c424cf78313ddbd6ec3a2a04119551789811b0aa
|
|
| MD5 |
5c26e796c2d6ad949d486124afb8fe6e
|
|
| BLAKE2b-256 |
776e2718b94fbdfde954ee8e5556a52681a78d82a739373aed75c95e4f2c0014
|
File details
Details for the file fral-0.0.1-cp311-cp311-macosx_12_0_arm64.whl.
File metadata
- Download URL: fral-0.0.1-cp311-cp311-macosx_12_0_arm64.whl
- Upload date:
- Size: 43.0 kB
- Tags: CPython 3.11, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38341cf8459a4061563897b9194af63bd270977e0f60e2809f6c0dfd8d4916bf
|
|
| MD5 |
3b8c22e06feb456d92f16e28c35fbdfc
|
|
| BLAKE2b-256 |
084126b91551683158370a770dff26bafb7468a732cdae32df9250de2182271f
|
File details
Details for the file fral-0.0.1-cp310-cp310-macosx_12_0_arm64.whl.
File metadata
- Download URL: fral-0.0.1-cp310-cp310-macosx_12_0_arm64.whl
- Upload date:
- Size: 43.2 kB
- Tags: CPython 3.10, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70d413775f831b714048b564d15426b516ca05bfff9145f30d7855b5261c5b6b
|
|
| MD5 |
6320e8f9d2cf9d3a261068426fde7760
|
|
| BLAKE2b-256 |
6253dc41caaabc2673b82fdae6d7158c247bedba8f1d4d73708f57bdfd5ef73c
|