Skip to content

feat: --maildir option, keep message sources once in memory - #104

Merged
andris9 merged 2 commits into
masterfrom
feat/maildir
Nov 30, 2026
Merged

andris9 merged 2 commits into
masterfrom
feat/maildir

Conversation

@andris9

@andris9 andris9 commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator
  • imapkit --maildir=<path> (IMAPKIT_MAILDIR) loads the mailboxes from a Maildir++ directory (flags from file names, .Name folders, new as \Recent) or from a directory of .eml files (subdirectories with mail become mailboxes). imapkit/lib/maildir exports loadMaildir().
  • The storage option is no longer copied with structuredClone, which kept every message source twice. Strings are shared, and Buffer sources become binary strings once.
  • The MIME parser keeps bodies and epilogues as slices of the source instead of joined copies. The parsed trees are identical on all 12,771 files of the synthetic email corpus.
  • A message given in storage as a bare Uint8Array was stored empty, now fixed.

Heap for a 710 MB corpus (11,637 messages): 1159 MB after load to 470 MB, 2036 MB after parsing every message to 714 MB.

🤖 Generated with Claude Code

andris9 and others added 2 commits November 30, 2026 14:28
The server copied the storage option with structuredClone, which also copies
strings, so every message source was kept twice (the copy for control.reset()
and the live one). The copy now shares strings, and Buffer sources are turned
into binary strings once, so the copies share them too.

The MIME parser joined the body lines of every part into a new string, and
nested message/rfc822 parts copied their content again. Bodies and epilogues
are now slices of the source, which V8 shares with it.

A 710 MB corpus of 11,637 messages now takes 714 MB of heap once parsed,
down from 2036 MB. A message given in storage as a bare Uint8Array was
stored empty, it now keeps its source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l files

imapkit --maildir=<path> (IMAPKIT_MAILDIR) builds the storage from a
Maildir++ directory (cur and new, flags from the file names, .Name folders)
or from a directory of *.eml files, whose subdirectories with mail become
mailboxes. The file modification time is the internal date, line breaks are
converted to CRLF, and the files are only read. imapkit/lib/maildir exports
loadMaildir() for use from code. A large corpus can not go through
--storage, as Node.js can not read a JSON file over about 512 MB into one
string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andris9
andris9 merged commit 0cf5d97 into master Nov 30, 2026
9 checks passed
@andris9
andris9 deleted the feat/maildir branch November 30, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant