Skip to content

Incorrect thread_safety plus performance tunning #312

Description

@ospfranco

Hi, I was doing some benchmarking between nitro-sqlite and op-sqlite and found the following

nitro-sqlite intends to always run in performance mode — RNNitroSQLite.podspec:8 hardcodes performance_mode = 1 with a comment "Used to create comparable benchmark results", and mode 1 would apply the same optimized flags plus SQLITE_THREADSAFE=0 — mutexes fully disabled, unsafe for concurrent access.

But there's a bug: performance_mode is set to the Ruby Integer 1, then checked against the String '1'/'2' ([lines 49/54]). In Ruby, 1 == '1' is always false — no coercion. So on iOS that branch never fires; nitro-sqlite currently compiles SQLite with no special flags at all, THREADSAFE left at its amalgamation default. On Android it's the same story for a different reason: the flags come from a nitroSqliteFlags Gradle property ([android/build.gradle:76]) that nothing in this project sets.

You also don't want to use SQLITE_THREADSAFE=0 as your ThreadPool implementation is using 3 threads and offers no safety, had to fix already a bunch of issues in op-sqlite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions