@op-engineering/op-sqlite 2.0.9 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,7 +16,7 @@ Created by [@ospfranco](https://twitter.com/ospfranco). **Please consider Sponso
16
16
 
17
17
  ## Benchmarks
18
18
 
19
- You can find the [benchmarking code in the example app](https://github.com/OP-Engineering/op-sqlite/blob/main/example/src/Database.ts#L44). You should expect anywhere between a 5x to an 8x improvement over non-JSI packages, and now a 5x to 8x improvement over quick-sqlite and expo-sqlite. Loading a 300k record database (in milliseconds).
19
+ You can find the [benchmarking code in the example app](https://github.com/OP-Engineering/op-sqlite/blob/main/example/src/Database.ts#L44). This is run using the `OP_SQLITE_PERF` flag which in turns disables some old and unused features of sqlite to squeeze the last drop of performance.
20
20
 
21
21
  ![benchmark](benchmark.png)
22
22
 
@@ -104,7 +104,7 @@ const largeDb = open({
104
104
  });
105
105
  ```
106
106
 
107
- # Speed
107
+ # Performance
108
108
 
109
109
  op-sqlite is already the fastest solution it can be, but it doesn't mean you cannot tweak SQLite to be faster (at the cost of some disadvantages). One possible tweak is turning on [Memory Mapping](https://www.sqlite.org/mmap.html). It allows to read/write to/from the disk without going through the kernel. However, if your queries throw an error your application might crash.
110
110
 
@@ -129,6 +129,14 @@ If you use [prepared statements](#prepared-statements) plus memory mapping and s
129
129
 
130
130
  ![mmkv comparison](mmkv.png)
131
131
 
132
+ # Perf flag
133
+
134
+ You can turn on the performance flag to tweak all possible performance enhancing compilation flags, this greatly affects performance of sqlite itself
135
+
136
+ ```
137
+ OP_SQLITE_PERF=1 npx pod-install
138
+ ```
139
+
132
140
  # SQLite Gotchas
133
141
 
134
142
  ## Strictness
package/cpp/bindings.cpp CHANGED
@@ -38,7 +38,6 @@ void clearState() {
38
38
  sqlite_close_all();
39
39
  // We then join all the threads before the context gets invalidated
40
40
  pool.restartPool();
41
-
42
41
  updateHooks.clear();
43
42
  commitHooks.clear();
44
43
  rollbackHooks.clear();
@@ -422,9 +421,8 @@ void install(jsi::Runtime &rt,
422
421
 
423
422
  auto updateHook = HOSTFN("updateHook", 2) {
424
423
  if (sizeof(args) < 2) {
425
- throw std::runtime_error(
426
- "[op-sqlite][loadFileAsync] Incorrect parameters: "
427
- "dbName and callback needed");
424
+ throw std::runtime_error("[op-sqlite][updateHook] Incorrect parameters: "
425
+ "dbName and callback needed");
428
426
  return {};
429
427
  }
430
428
 
@@ -481,9 +479,8 @@ void install(jsi::Runtime &rt,
481
479
 
482
480
  auto commitHook = HOSTFN("commitHook", 2) {
483
481
  if (sizeof(args) < 2) {
484
- throw std::runtime_error(
485
- "[op-sqlite][loadFileAsync] Incorrect parameters: "
486
- "dbName and callback needed");
482
+ throw std::runtime_error("[op-sqlite][commitHook] Incorrect parameters: "
483
+ "dbName and callback needed");
487
484
  return {};
488
485
  }
489
486
 
@@ -508,7 +505,7 @@ void install(jsi::Runtime &rt,
508
505
  auto rollbackHook = HOSTFN("rollbackHook", 2) {
509
506
  if (sizeof(args) < 2) {
510
507
  throw std::runtime_error(
511
- "[op-sqlite][loadFileAsync] Incorrect parameters: "
508
+ "[op-sqlite][rollbackHook] Incorrect parameters: "
512
509
  "dbName and callback needed");
513
510
  return {};
514
511
  }
package/cpp/bridge.cpp CHANGED
@@ -581,6 +581,9 @@ void sqlite_close_all() {
581
581
  sqlite3_close_v2(x.second);
582
582
  }
583
583
  dbMap.clear();
584
+ updateCallbackMap.clear();
585
+ rollbackCallbackMap.clear();
586
+ commitCallbackMap.clear();
584
587
  }
585
588
 
586
589
  std::string operation_to_string(int operation_type) {
package/op-sqlite.podspec CHANGED
@@ -12,14 +12,14 @@ Pod::Spec.new do |s|
12
12
  s.license = package["license"]
13
13
  s.authors = package["author"]
14
14
 
15
- s.platforms = { :ios => "12.0", :osx => "10.13" }
15
+ s.platforms = { :ios => "13.0", :osx => "10.15" }
16
16
  s.source = { :git => "https://github.com/op-engineering/op-sqlite.git", :tag => "#{s.version}" }
17
17
 
18
18
  s.pod_target_xcconfig = {
19
19
  :GCC_PREPROCESSOR_DEFINITIONS => "HAVE_FULLFSYNC=1",
20
20
  :WARNING_CFLAGS => "-Wno-shorten-64-to-32 -Wno-comma -Wno-unreachable-code -Wno-conditional-uninitialized -Wno-deprecated-declarations",
21
21
  :USE_HEADERMAP => "No",
22
- :CLANG_CXX_LANGUAGE_STANDARD => "c++17"
22
+ :CLANG_CXX_LANGUAGE_STANDARD => "c++17",
23
23
  }
24
24
 
25
25
  s.header_mappings_dir = "cpp"
@@ -37,5 +37,15 @@ Pod::Spec.new do |s|
37
37
  s.exclude_files = "cpp/sqlite3.c", "cpp/sqlite3.h"
38
38
  s.library = "sqlite3"
39
39
  end
40
+
41
+ if ENV['OP_SQLITE_PERF'] == '1' then
42
+ s.pod_target_xcconfig = {
43
+ :GCC_PREPROCESSOR_DEFINITIONS => "HAVE_FULLFSYNC=1",
44
+ :WARNING_CFLAGS => "-Wno-shorten-64-to-32 -Wno-comma -Wno-unreachable-code -Wno-conditional-uninitialized -Wno-deprecated-declarations",
45
+ :USE_HEADERMAP => "No",
46
+ :CLANG_CXX_LANGUAGE_STANDARD => "c++17",
47
+ :OTHER_CFLAGS => '$(inherited) -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'
48
+ }
49
+ end
40
50
 
41
51
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@op-engineering/op-sqlite",
3
- "version": "2.0.9",
3
+ "version": "2.0.12",
4
4
  "description": "Next generation SQLite for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",