Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn performance mode into a single boolean #185

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def isNewArchitectureEnabled() {
def useSQLCipher = false
def useLibsql = false
def useCRSQLite = false
def performanceMode = "0"
def performanceMode = false
def sqliteFlags = ""
def enableFTS5 = false
def useSqliteVec = false
Expand All @@ -53,7 +53,7 @@ if(opsqliteConfig) {
useSQLCipher = opsqliteConfig["sqlcipher"]
useCRSQLite = opsqliteConfig["crsqlite"]
useSqliteVec = opsqliteConfig["sqliteVec"]
performanceMode = opsqliteConfig["performanceMode"] ? opsqliteConfig["performanceMode"] : ""
performanceMode = opsqliteConfig["performanceMode"]
sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : ""
enableFTS5 = opsqliteConfig["fts5"]
useLibsql = opsqliteConfig["libsql"]
Expand All @@ -73,12 +73,8 @@ if(useCRSQLite) {
println "[OP-SQLITE] using CR-SQLite 🤖"
}

if(performanceMode == "1") {
println "[OP-SQLITE] Thread unsafe performance mode enabled. Use only transactions! 🚀"
}

if(performanceMode == "2") {
println "[OP-SQLITE] Thread safe performance mode enabled! 🚀"
if(performanceMode) {
println "[OP-SQLITE] Performance mode enabled! 🚀"
}

if(enableFTS5) {
Expand Down Expand Up @@ -151,10 +147,7 @@ android {
cFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
cppFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
}
if(performanceMode == '1') {
cFlags += ["-DSQLITE_DQS=0", "-DSQLITE_THREADSAFE=0", "-DSQLITE_DEFAULT_MEMSTATUS=0", "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1", "-DSQLITE_MAX_EXPR_DEPTH=0", "-DSQLITE_OMIT_DEPRECATED=1", "-DSQLITE_OMIT_PROGRESS_CALLBACK=1", "-DSQLITE_OMIT_SHARED_CACHE=1", "-DSQLITE_USE_ALLOCA=1"]
}
if(performanceMode == '2') {
if(performanceMode) {
cFlags += ["-DSQLITE_DQS=0", "-DSQLITE_THREADSAFE=1", "-DSQLITE_DEFAULT_MEMSTATUS=0", "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1", "-DSQLITE_MAX_EXPR_DEPTH=0", "-DSQLITE_OMIT_DEPRECATED=1", "-DSQLITE_OMIT_PROGRESS_CALLBACK=1", "-DSQLITE_OMIT_SHARED_CACHE=1", "-DSQLITE_USE_ALLOCA=1"]
}
if(enableFTS5) {
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PODS:
- hermes-engine (0.76.1):
- hermes-engine/Pre-built (= 0.76.1)
- hermes-engine/Pre-built (0.76.1)
- op-sqlite (10.0.0-tokenizers-beta9):
- op-sqlite (10.1.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1540,7 +1540,7 @@ PODS:
- React-logger (= 0.76.1)
- React-perflogger (= 0.76.1)
- React-utils (= 0.76.1)
- RNShare (11.0.4):
- RNShare (11.0.3):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1785,7 +1785,7 @@ SPEC CHECKSUMS:
GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
hermes-engine: 46f1ffbf0297f4298862068dd4c274d4ac17a1fd
op-sqlite: 63400939931ca67186f99f8b536a02b048133710
op-sqlite: 09176c1312198acd6da5847bc0003ce641b4c8f0
RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648
RCTDeprecation: fde92935b3caa6cb65cbff9fbb7d3a9867ffb259
RCTRequired: 75c6cee42d21c1530a6f204ba32ff57335d19007
Expand Down Expand Up @@ -1844,7 +1844,7 @@ SPEC CHECKSUMS:
React-utils: 5362bd16a9563f9916e7a56c011ddc533507650f
ReactCodegen: 865bafc5c17ec2181620ced1a32c39c38ab2951d
ReactCommon: 422e364463f33e336fc4db196aeb50fd801d90d6
RNShare: 4305edead1b8f614ab994046c68193e8d50aaadc
RNShare: e1721a8818a3bf111ed686ed5d8c1dc76b91c8ad
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: db69236006b8b1c6d55ab453390c882306cbf219

Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"op-sqlite": {
"sqlcipher": false,
"crsqlite": false,
"performanceMode": "2",
"performanceMode": true,
"sqliteFlags": "-DSQLITE_TEMP_STORE=2",
"iosSqlite": false,
"fts5": true,
Expand Down
35 changes: 35 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# EXAMPLE USAGE:
#
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
#
# pre-push:
# commands:
# packages-audit:
# tags: frontend security
# run: yarn audit
# gems-audit:
# tags: backend security
# run: bundle audit
#
# pre-commit:
# parallel: true
# commands:
# eslint:
# glob: "*.{js,ts,jsx,tsx}"
# run: yarn eslint {staged_files}
# rubocop:
# tags: backend style
# glob: "*.rb"
# exclude: '(^|/)(application|routes)\.rb$'
# run: bundle exec rubocop --force-exclusion {all_files}
# govet:
# tags: backend style
# files: git ls-files -m
# glob: "*.go"
# run: go vet {files}
# scripts:
# "hello.js":
# runner: node
# "any.go":
# runner: go run
17 changes: 6 additions & 11 deletions op-sqlite.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ op_sqlite_config = app_package["op-sqlite"]
use_sqlcipher = false
use_crsqlite = false
use_libsql = false
performance_mode = "0"
performance_mode = false
phone_version = false
sqlite_flags = ""
fts5 = false
Expand All @@ -36,7 +36,7 @@ if(op_sqlite_config != nil)
use_sqlcipher = op_sqlite_config["sqlcipher"] == true
use_crsqlite = op_sqlite_config["crsqlite"] == true
use_libsql = op_sqlite_config["libsql"] == true
performance_mode = op_sqlite_config["performanceMode"] || "0"
performance_mode = op_sqlite_config["performanceMode"] || false
phone_version = op_sqlite_config["iosSqlite"] == true
sqlite_flags = op_sqlite_config["sqliteFlags"] || ""
fts5 = op_sqlite_config["fts5"] == true
Expand Down Expand Up @@ -136,7 +136,7 @@ Pod::Spec.new do |s|
end

other_cflags = '-DSQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION=1'
optimizedCflags = other_cflags + '$(inherited) -DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 -DSQLITE_OMIT_SHARED_CACHE=1 -DSQLITE_USE_ALLOCA=1'
optimizedCflags = '$(inherited) -DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 -DSQLITE_OMIT_SHARED_CACHE=1 -DSQLITE_USE_ALLOCA=1 -DSQLITE_THREADSAFE=1'
frameworks = []

if fts5 then
Expand All @@ -156,14 +156,9 @@ Pod::Spec.new do |s|
s.library = "sqlite3"
end

if performance_mode == '1' then
log_message.call("[OP-SQLITE] Thread unsafe (1) performance mode enabled. Use only transactions! 🚀🚀")
other_cflags = optimizedCflags + ' -DSQLITE_THREADSAFE=0 '
end

if performance_mode == '2' then
log_message.call("[OP-SQLITE] Thread safe (2) performance mode enabled 🚀")
other_cflags = optimizedCflags + ' -DSQLITE_THREADSAFE=1 '
if performance_mode then
log_message.call("[OP-SQLITE] Performance mode enabled, some features might be disabled 🚀")
other_cflags += optimizedCflags
end

if use_crsqlite then
Expand Down
Loading