Skip to content

FDB api should be called off main thread #46

@ex3ndr

Description

@ex3ndr

We have very small test:

let buffer = Buffer.alloc(0);
await db.doTn(async (tx) => {
    for (let i = 0; i < 10000; i++) {
        let id = uuid();
        tx.set(id, buffer);
    }
})

We found that with this code js thread is blocked by FDB for ~160ms (of 180ms overal).

Further investigation shows that the issue is within FDB C library.

We changed code to use versionstampkeys

let buffer = Buffer.alloc(0);
await db.doTn(async (tx) => {
    for (let i = 0; i < 10000; i++) {
        tx.setVersionstampSuffixedKey(buffer, buffer);
    }
})

Blocked time inside of a transaction went down to just 30ms, but commit time was increased by 150ms. I suppose that FDB library is offloading some computation to the end for atomic operations and just blocks thread later.

Isn't we should avoid blocking event loop and have a separate thread and schedule all FDB operations there?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions