Skip to content

Commit 9069bf1

Browse files
committed
Disable profiling on workers
Browsers don't surface this information either way
1 parent 88d7ba1 commit 9069bf1

File tree

4 files changed

+10
-67
lines changed

4 files changed

+10
-67
lines changed

packages/sqlite_async/lib/src/web/protocol.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@ library;
55
import 'dart:js_interop';
66
import 'package:sqlite3_web/protocol_utils.dart' as proto;
77

8-
@JS()
9-
@anonymous
10-
extension type CustomOpenOptions._(JSObject _) implements JSObject {
11-
external factory CustomOpenOptions({
12-
required JSBoolean? profileQueries,
13-
});
14-
15-
external JSBoolean? get profileQueries;
16-
}
17-
188
enum CustomDatabaseMessageKind {
199
requestSharedLock,
2010
requestExclusiveLock,

packages/sqlite_async/lib/src/web/web_sqlite_open_factory.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:async';
2-
import 'dart:js_interop';
32

43
import 'package:sqlite3/wasm.dart';
54
import 'package:sqlite3_web/sqlite3_web.dart';
@@ -9,7 +8,6 @@ import 'package:sqlite_async/src/web/web_mutex.dart';
98
import 'package:sqlite_async/web.dart';
109

1110
import 'database.dart';
12-
import 'protocol.dart';
1311
import 'worker/worker_utils.dart';
1412

1513
Map<String, FutureOr<WebSqlite>> webSQLiteImplementations = {};
@@ -47,17 +45,6 @@ class DefaultSqliteOpenFactory
4745
);
4846
}
4947

50-
@override
51-
Future<ConnectToRecommendedResult> connectToWorker(
52-
WebSqlite sqlite, String name) {
53-
return sqlite.connectToRecommended(
54-
name,
55-
additionalOptions: CustomOpenOptions(
56-
profileQueries: sqliteOptions.profileQueries.toJS,
57-
),
58-
);
59-
}
60-
6148
/// This is currently not supported on web
6249
@override
6350
CommonDatabase openDB(SqliteOpenOptions options) {

packages/sqlite_async/lib/src/web/worker/throttled_common_database.dart

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,17 @@
11
import 'dart:async';
2-
import 'dart:developer';
32

43
import 'package:sqlite_async/sqlite3_wasm.dart';
5-
import 'package:sqlite_async/src/utils/profiler.dart';
64

75
/// Wrap a CommonDatabase to throttle its updates stream.
86
/// This is so that we can throttle the updates _within_
97
/// the worker process, avoiding mass notifications over
108
/// the MessagePort.
119
class ThrottledCommonDatabase extends CommonDatabase {
1210
final CommonDatabase _db;
13-
final bool profileQueries;
14-
1511
final StreamController<bool> _transactionController =
1612
StreamController.broadcast();
1713

18-
ThrottledCommonDatabase(this._db, this.profileQueries);
19-
20-
T _maybeSync<T>(
21-
T Function() function, {
22-
required String name,
23-
required String sql,
24-
required List<Object?> parameters,
25-
}) {
26-
if (profileQueries) {
27-
final (resolvedName, args) =
28-
profilerNameAndArgs(name, sql: sql, parameters: parameters);
29-
30-
return Timeline.timeSync(resolvedName, function, arguments: args);
31-
} else {
32-
return function();
33-
}
34-
}
14+
ThrottledCommonDatabase(this._db);
3515

3616
@override
3717
int get userVersion => _db.userVersion;
@@ -80,12 +60,7 @@ class ThrottledCommonDatabase extends CommonDatabase {
8060

8161
@override
8262
void execute(String sql, [List<Object?> parameters = const []]) {
83-
_maybeSync(
84-
name: 'execute',
85-
sql: sql,
86-
parameters: parameters,
87-
() => _db.execute(sql, parameters),
88-
);
63+
_db.execute(sql, parameters);
8964
}
9065

9166
@override
@@ -112,20 +87,13 @@ class ThrottledCommonDatabase extends CommonDatabase {
11287

11388
@override
11489
ResultSet select(String sql, [List<Object?> parameters = const []]) {
115-
return _maybeSync(
116-
name: 'select',
117-
sql: sql,
118-
parameters: parameters,
119-
() {
120-
bool preAutocommit = _db.autocommit;
121-
final result = _db.select(sql, parameters);
122-
bool postAutocommit = _db.autocommit;
123-
if (!preAutocommit && postAutocommit) {
124-
_transactionController.add(true);
125-
}
126-
return result;
127-
},
128-
);
90+
bool preAutocommit = _db.autocommit;
91+
final result = _db.select(sql, parameters);
92+
bool postAutocommit = _db.autocommit;
93+
if (!preAutocommit && postAutocommit) {
94+
_transactionController.add(true);
95+
}
96+
return result;
12997
}
13098

13199
@override

packages/sqlite_async/lib/src/web/worker/worker_utils.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ base class AsyncSqliteController extends DatabaseController {
2121
final db = openUnderlying(sqlite3, path, vfs, additionalData);
2222

2323
// Register any custom functions here if needed
24-
final profile = additionalData != null &&
25-
(additionalData as CustomOpenOptions).profileQueries?.toDart == true;
2624

27-
final throttled = ThrottledCommonDatabase(db, profile);
25+
final throttled = ThrottledCommonDatabase(db);
2826

2927
return AsyncSqliteDatabase(database: throttled);
3028
}

0 commit comments

Comments
 (0)