-
Notifications
You must be signed in to change notification settings - Fork 30
Description
From some basic testing, when running an instance using MongoDB for both the source database and bucket storage, disabling the Postgres and MySQL modules could reduce memory usage by around 30MB. It may also reduce startup time.
In my tests I specifically disabled the registration of these 3 modules, as well as their associated imports:
powersync-service/service/src/entry.ts
Lines 24 to 26 in 57f7660
| new MySQLModule(), | |
| new PostgresModule(), | |
| new PostgresStorageModule() |
See these heap snapshots - note the differences in (compiled code) and (string).
And it's not a very scientific measurement, but heap usage for the replication process differed by around 30MB on my machine, which is a little more than the difference measured in (compiled code) and (string).
All modules enabled:
Proposal: Make the modules load their dependencies dynamically when needed, instead of importing everything upfront.
Alternatively, instead of doing this for all dependencies, focus on specific bigger ones, such as node-sql-parser, and perhaps the database drivers. Either way, this may require refactoring some synchronous methods to async.
