Skip to main content

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).

offset diagram

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: Single Process Write Performance

Multiprocess Write and Read Performance

Testing the performance of writing and reading 1GB with various allocation sizes and multiple writers: Producer-ConsumerLatency Producer-ConsumerThroughput

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fral-0.0.1-cp312-cp312-macosx_12_0_arm64.whl (42.2 kB view details)

Uploaded CPython 3.12macOS 12.0+ ARM64

fral-0.0.1-cp311-cp311-macosx_12_0_arm64.whl (43.0 kB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

fral-0.0.1-cp310-cp310-macosx_12_0_arm64.whl (43.2 kB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

File details

Details for the file fral-0.0.1-cp312-cp312-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for fral-0.0.1-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 6def2621e0de2eec39a5aed7c424cf78313ddbd6ec3a2a04119551789811b0aa
MD5 5c26e796c2d6ad949d486124afb8fe6e
BLAKE2b-256 776e2718b94fbdfde954ee8e5556a52681a78d82a739373aed75c95e4f2c0014

See more details on using hashes here.

File details

Details for the file fral-0.0.1-cp311-cp311-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for fral-0.0.1-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 38341cf8459a4061563897b9194af63bd270977e0f60e2809f6c0dfd8d4916bf
MD5 3b8c22e06feb456d92f16e28c35fbdfc
BLAKE2b-256 084126b91551683158370a770dff26bafb7468a732cdae32df9250de2182271f

See more details on using hashes here.

File details

Details for the file fral-0.0.1-cp310-cp310-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for fral-0.0.1-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 70d413775f831b714048b564d15426b516ca05bfff9145f30d7855b5261c5b6b
MD5 6320e8f9d2cf9d3a261068426fde7760
BLAKE2b-256 6253dc41caaabc2673b82fdae6d7158c247bedba8f1d4d73708f57bdfd5ef73c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page