Skip to content

Unused modules take up memory #410

@rkistner

Description

@rkistner

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:

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:

Image

Postgres and MySQL disabled:
Image

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.

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