Skip to content
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

log-server: reduce store's getLogs memory footprint #220

Merged
merged 5 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/old-zebras-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lightmill/log-server': minor
---

Add a select query result limit for SQliteStore to prevent too many logs to be loaded in memory at the same time. Once the limit is attained logs are yielded and the next logs are loaded once their done being processed.
135 changes: 135 additions & 0 deletions packages/log-server/__tests__/__snapshots__/sqlite-store.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`SQLiteStore#getLogs (selectQueryLimit: 2) > should return the logs in order of experimentId, runId, and ascending number 2`] = `
[
{
"experimentId": "experiment1",
"number": 1,
"runId": "run1",
"type": "log1",
"values": {
"msg": "hello",
"recipient": "Anna",
},
},
{
"experimentId": "experiment1",
"number": 2,
"runId": "run1",
"type": "log1",
"values": {
"msg": "bonjour",
"recipient": "Jo",
},
},
{
"experimentId": "experiment1",
"number": 3,
"runId": "run1",
"type": "log3",
"values": {
"foo": true,
"x": 25,
"y": 0,
},
},
{
"experimentId": "experiment1",
"number": 1,
"runId": "run2",
"type": "log1",
"values": {
"bar": null,
"message": "hola",
},
},
{
"experimentId": "experiment1",
"number": 2,
"runId": "run2",
"type": "log2",
"values": {
"foo": false,
"x": 12,
},
},
{
"experimentId": "experiment2",
"number": 1,
"runId": "run1",
"type": "log2",
"values": {
"foo": true,
"x": 25,
"y": 0,
},
},
]
`;

exports[`SQLiteStore#getLogs (selectQueryLimit: 10000) > should return the logs in order of experimentId, runId, and ascending number 2`] = `
[
{
"experimentId": "experiment1",
"number": 1,
"runId": "run1",
"type": "log1",
"values": {
"msg": "hello",
"recipient": "Anna",
},
},
{
"experimentId": "experiment1",
"number": 2,
"runId": "run1",
"type": "log1",
"values": {
"msg": "bonjour",
"recipient": "Jo",
},
},
{
"experimentId": "experiment1",
"number": 3,
"runId": "run1",
"type": "log3",
"values": {
"foo": true,
"x": 25,
"y": 0,
},
},
{
"experimentId": "experiment1",
"number": 1,
"runId": "run2",
"type": "log1",
"values": {
"bar": null,
"message": "hola",
},
},
{
"experimentId": "experiment1",
"number": 2,
"runId": "run2",
"type": "log2",
"values": {
"foo": false,
"x": 12,
},
},
{
"experimentId": "experiment2",
"number": 1,
"runId": "run1",
"type": "log2",
"values": {
"foo": true,
"x": 25,
"y": 0,
},
},
]
`;
Loading