Repository navigation
perf(mail): build the throwaway-domain set once for every caller - #3349
Merged
Merged
Conversation
isDisposableEmailDomain from disposable-email-domains-js builds its set of about 9,000 domains on every call. scoreGroup called it once per sender, so scoring 20,000 senders spent about 7 s on it. #3347 had already cached the set inside domain-organizations.ts; the cache now lives in mail/score.ts as isDisposableDomain, next to FREE_MAIL, and both callers use it. Synthetic run, 20,000 senders of 3 emails each: 7.0 s -> 0.21 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
Follow-up to #3347: its PR body noted that
isDisposableEmailDomain(disposable-email-domains-js) builds its whole list on every call, and thatsrc/mail/score.tsstill called it once per sender.Why
The library's
isDisposableEmailDomainturns its array of about 9,000 domains into a newSeton each call.scoreGroupcalls it for every sender group, so scoring a large mailbox spent most of its time rebuilding the same set.What
src/mail/score.ts: newisDisposableDomain(domain), which builds the set once (disposableEmailBlocklistSet) on first use.scoreGroupuses it.src/store/sqlite/domain-organizations.ts: its private cache from feat(people): organizations from mail domains #3347 is gone;companyDomainOfimportsisDisposableDomainfrom the same module it already takesFREE_MAILandregistrableOffrom.Decision (owner asleep): the shared helper lives in
mail/score.ts, next toFREE_MAIL, rather than in a new module. Both callers already import from there. The input is not lower-cased or trimmed, unlike the library function: both callers passregistrableOfoutput, which is lower case already.Testing
Measured, synthetic case: 20,000 senders, 3 emails each (every tenth at
mailinator.com),scoreGroupover all of them, 5 runs in one process, vitest--maxWorkers=1, Node 24.19, 24 cores, load average about 5. The timing file was a throwaway test, not committed.origin/main)About 0.35 ms per sender before, 0.01 ms after (that is the whole score, not only the check).
src/mail/score.test.ts:isDisposableDomainis true formailinator.comandguerrillamail.com, false forgmail.comand a company domain. The existingdisposable_domainsignal test still passes.src/mail/score.test.ts,src/store/domain-organizations.test.ts: 22 passed.pnpm typecheck,pnpm lint(no new warnings),pnpm docs:check,pnpm schema:check.🤖 Generated with Claude Code