Skip to content

fix(fetcher): limit fetch chunks#1346

Open
puneetdixit200 wants to merge 1 commit into
floatpane:masterfrom
puneetdixit200:fix/1106-fetch-limit-chunk-size
Open

fix(fetcher): limit fetch chunks#1346
puneetdixit200 wants to merge 1 commit into
floatpane:masterfrom
puneetdixit200:fix/1106-fetch-limit-chunk-size

Conversation

@puneetdixit200
Copy link
Copy Markdown

@puneetdixit200 puneetdixit200 commented May 22, 2026

What?

  • remove the hard 50-message minimum chunk size in FetchMailboxEmails
  • add a TLS IMAP recorder regression that verifies limit=5 fetches only 96:100 from a 100-message mailbox

Why?

When callers request a small page, the fetcher should not over-fetch 50 messages before filtering and trimming. This keeps IMAP bandwidth and server load proportional to the requested limit.

Fixes #1106

@puneetdixit200 puneetdixit200 requested a review from a team as a code owner May 22, 2026 13:57
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @puneetdixit200! Please fix the following issues with your PR:

  • Title: Is too long (40 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

@floatpanebot floatpanebot added area/fetcher IMAP fetch / IDLE / search bug Something isn't working size/L Diff: 201–800 lines labels May 22, 2026
@puneetdixit200 puneetdixit200 changed the title fix(fetcher): respect small fetch limits fix(fetcher): limit fetch chunks May 22, 2026
@floatpanebot floatpanebot dismissed their stale review May 22, 2026 13:58

Formatting issues have been resolved. Thank you!

@andrinoff andrinoff force-pushed the fix/1106-fetch-limit-chunk-size branch from 67f8a5c to a06aed1 Compare May 23, 2026 09:59
@floatpanebot
Copy link
Copy Markdown
Member

floatpanebot commented May 23, 2026

Benchmark report — no significant change

Metrics worse: 0 · better: 0 (threshold: ±3%).

benchstat output
goos: linux
goarch: amd64
pkg: github.com/floatpane/matcha/backend
cpu: AMD EPYC 7763 64-Core Processor                
                           │   old.txt    │               new.txt               │
                           │    sec/op    │    sec/op     vs base               │
ParseSearchQuery_Simple-4    2.822µ ± 20%   2.864µ ± 25%        ~ (p=0.937 n=6)
ParseSearchQuery_Complex-4   7.307µ ± 29%   8.974µ ± 63%        ~ (p=0.093 n=6)
TokenizeSearchQuery-4        4.804µ ± 32%   6.058µ ± 94%        ~ (p=0.132 n=6)
geomean                      4.627µ         5.380µ        +16.27%

                           │  old.txt   │              new.txt               │
                           │    B/op    │    B/op     vs base                │
ParseSearchQuery_Simple-4    26.00 ± 0%   26.00 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   762.0 ± 0%   762.0 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        176.0 ± 0%   176.0 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      151.6        151.6       +0.00%
¹ all samples are equal

                           │  old.txt   │              new.txt               │
                           │ allocs/op  │ allocs/op   vs base                │
ParseSearchQuery_Simple-4    2.000 ± 0%   2.000 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   23.00 ± 0%   23.00 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        9.000 ± 0%   9.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      7.453        7.453       +0.00%
¹ all samples are equal

pkg: github.com/floatpane/matcha/tui
                    │   old.txt    │               new.txt               │
                    │    sec/op    │    sec/op     vs base               │
LogPanelView-4        167.0µ ± 11%   173.3µ ±  8%        ~ (p=0.699 n=6)
SearchOverlayView-4   172.7µ ± 17%   211.7µ ±  9%  +22.57% (p=0.002 n=6)
InboxConstruction-4   814.4µ ± 21%   842.9µ ± 14%        ~ (p=0.818 n=6)
geomean               286.4µ         313.9µ         +9.60%

                    │    old.txt     │               new.txt                │
                    │      B/op      │     B/op       vs base               │
LogPanelView-4        21.79Ki ± 105%   33.23Ki ± 34%        ~ (p=1.000 n=6)
SearchOverlayView-4   56.14Ki ±  41%   56.14Ki ± 41%        ~ (p=0.942 n=6)
InboxConstruction-4   873.9Ki ±   0%   873.9Ki ±  0%        ~ (p=0.515 n=6)
geomean               102.2Ki          117.7Ki        +15.11%

                    │   old.txt   │              new.txt              │
                    │  allocs/op  │  allocs/op   vs base              │
LogPanelView-4         712.0 ± 0%    713.0 ± 0%       ~ (p=1.000 n=6)
SearchOverlayView-4    926.0 ± 0%    926.0 ± 0%       ~ (p=1.000 n=6)
InboxConstruction-4   3.475k ± 0%   3.475k ± 0%       ~ (p=0.455 n=6)
geomean               1.318k        1.319k       +0.05%

auto-generated by benchmarks.yml

@puneetdixit200 puneetdixit200 force-pushed the fix/1106-fetch-limit-chunk-size branch from a06aed1 to 3ad4bb5 Compare May 23, 2026 10:10
@andrinoff andrinoff force-pushed the fix/1106-fetch-limit-chunk-size branch from 3ad4bb5 to 423ceba Compare May 23, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/fetcher IMAP fetch / IDLE / search bug Something isn't working size/L Diff: 201–800 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Fetcher chunkSize over-fetches when caller asks for fewer than 50

2 participants