mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
On a seeded board of 4,000 cards, 12,000 comments, 20,000 checklist items and 32,000 activities, served from FerretDB with SQLite as the Snap is: closing a card took about 4 s and now takes 0.1 s, the board finished loading in 17.6 s and now in 6.2 s, a card open re-ran about 7,700 computations and now about 1,000, and FerretDB used 13 s of CPU and 724 MB while the board opened, now 3 s and 280 MB. - The client data cache queued one more stop callback each time a helper re-ran, and every check asked Tracker for dependents, which on close was 710 walks of 3 ms; there is now one callback per computation and key and one timer per key (imports/lib/dataCache.js). - Opening a card writes the user's last-viewed card, and avatars, @mentions, list and swimlane headers read the whole user, so everything re-ran; they read only the fields they show. The comment, checklist and subtask indexes were one object every minicard depended on and are now per card (imports/lib/keyedGroupIndex.js). - The lazy card window kept a full copy of every card of a list per window; it keeps the id and the sort keys, runs its id query once instead of five times, and sends comment text only when minicards show comments (server/publications/cardsWindow.js, models/lib/cardWindowFields.js). Comment reactions and legacy attachment lookups come with the opened card only. - Attachment downloads honour Range for filesystem, GridFS and cloud storage (206, 416, If-Range); uploads to cloud storage are spooled to a temporary file and streamed instead of gathered into one Buffer; the API copy checks the size limit before reading; the legacy attachment migration streams, and no longer stores "[object Promise]" as a file; the board export no longer concatenates buffers quadratically. The FerretDB fork pushes dotted-path filters such as meta.cardId down to SQLite (they were each a full scan) and decodes only the fields a count filters on. docs/Features/Admin-Panel/Problems/Large-Boards.md describes how a large board loads and how to size a server with 8 GB of RAM. Thanks to markusst1982 and xet7 ! Fixes #6745.
45 lines
1.8 KiB
JavaScript
45 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
// #6745: which fields the lazy card window (server/publications/cardsWindow.js)
|
|
// reads and sends. Pure, so tests/largeBoardDataLoading.test.cjs runs it
|
|
// without Meteor.
|
|
|
|
// The fields a window's MEMBERSHIP observer keeps per card: the sort keys, so
|
|
// a re-order still re-reads the window. Every other field of every card in the
|
|
// list used to be held by that observer - one full copy of the list per
|
|
// window. Accepts both sort forms Meteor takes: `{ field: 1 }` and
|
|
// `[['field', 'asc']]` / `['field']`. `_id` is always there.
|
|
function windowOrderFields(sort) {
|
|
const fields = { _id: 1 };
|
|
const keys = Array.isArray(sort)
|
|
? sort.map(entry => (Array.isArray(entry) ? entry[0] : entry))
|
|
: Object.keys(sort && typeof sort === 'object' ? sort : {});
|
|
for (const key of keys) {
|
|
// A sort key is a plain (possibly dotted) field name; anything else - an
|
|
// operator, an empty string - is not a field and is not projected.
|
|
if (typeof key === 'string' && key && !key.startsWith('$')) fields[key] = 1;
|
|
}
|
|
return fields;
|
|
}
|
|
|
|
// The comment fields a MINICARD reads: that the comment exists and when it was
|
|
// written (the count and the unread highlight, models/lib/unreadComments.js),
|
|
// plus who wrote it. The text only when the board shows the latest comments
|
|
// on its minicards (allowsCommentsOnMinicard). An opened card reads all of its
|
|
// own comments' fields from the `openCardData` publication.
|
|
const MINICARD_COMMENT_FIELDS = Object.freeze({
|
|
boardId: 1,
|
|
cardId: 1,
|
|
userId: 1,
|
|
createdAt: 1,
|
|
modifiedAt: 1,
|
|
});
|
|
|
|
function windowCommentFields(board) {
|
|
const fields = { ...MINICARD_COMMENT_FIELDS };
|
|
if (board && board.allowsCommentsOnMinicard) fields.text = 1;
|
|
return fields;
|
|
}
|
|
|
|
module.exports = { windowOrderFields, windowCommentFields, MINICARD_COMMENT_FIELDS };
|