-
-
Notifications
You must be signed in to change notification settings - Fork 570
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
Significant memory spike in plugin with each() #2038
Comments
Update: This appears to not be related to |
This is due to the Since your step here is not dependent on plans: {
User: {
totalLanguages() {
const $allLangugages = withPgClient(
executor,
constant(null),
async (pgClient) => {
const { rows } = await pgClient.query({
text: `select language from languages`,
});
return rows;
},
);
$allLangugages.hasSideEffects = false;
return lambda(
$allLangugages,
(allLangugages) => allLangugages.length,
);
},
},
}, However, it would be better to directly address your need, which in this case seems to be counting the number of languages on a per-user basis, so perhaps something like: plans: {
User: {
totalLanguages($user) {
const $agg = user_config.find({ user_id: $user.get("id") }).clone("aggregate");
return $agg.single().select(sql`count(*)`, TYPES.bigint);
},
},
}, Note that |
Summary
Javascript heap memory usage jumps significantly when using a plugin with
loadOne
, . This occurs for relatively "small" rows. ~100 rows will cause a jump from ~40mb on startup to ~250mb. Larger numbers cause higher memory usage.For our usage of Postgraphile V5 in production, this is causing our server to crash due to out of memory errors.
Steps to reproduce
See this repository for a full reproduction:
https://github.com/cjheppell/grafast-memory-spike-repro/tree/main
Expected results
Memory usage does not jump significantly.
Actual results
Memory usage jumps significantly.
Additional context
Postgres 15, Node v20, MacOS M1 32GB, latest Postgraphile v5.
Schema, data and code is available in the reproduction repo above.
Possible Solution
Unknown. I'm too unfamiliar with the internals of Grafast/Postgraphile to suggest how this might be resolved.
The text was updated successfully, but these errors were encountered: