Commit 8ec4fbc
committed
net_imap: Make untagged EXISTS more efficient for COPY/MOVE/APPEND.
The current process for generating untagged EXISTS in response
to new messages is very message-specific; the callback is
executed every single time for every single message, no matter
how many messages are part of the operation. This can be very
inefficient when a user does a batch operation, such as appending
a large number of messages to a mailbox, or copying/moving
messages between mailboxes. This was further exacerbated by
existing inefficiencies in this process, such as counting the
number of messages in the maildir every time the untagged EXISTS
callback is triggered. This meant adding a large number of messages
e.g. via COPY/MOVE resulted in a polynomial number of passes over
the contents of the maildir.
Furthermore, a large number of EXISTS updates (e.g. thousands)
can potentially fill up imap->pfd[1].
To make this more efficient, we now ensure that this callback is
only triggered once for batch operations, by doing the following:
* COPY/MOVE operations now trigger EVENT_MESSAGE_APPEND, not
EVENT_MESSAGE_NEW. This allows net_imap to ignore all
the APPEND events (but the NEW events), and also seems to be
a more correct interpretation of RFC 5423 Section 4.
* net_imap now ignores EVENT_MESSAGE_APPEND.
* Add a new pseudo-event, EVENT_MESSAGE_APPEND_MULTIPLE, which is
fired off only at the end of a batch APPEND/COPY/MOVE operation.
This way, as far as untagged EXIST goes, we only need to send
a single update, instead of a linear number of updates.
* net_imap now now manually fires the EVENT_MESSAGE_APPEND_MULTIPLE
event with the UIDs that were impacted.
Overall, this yields a significant performance improvement when
appending/copying/moving lots of messages (about 10x, from some
performance benchmarks before/after this change).1 parent e69809e commit 8ec4fbc
File tree
4 files changed
+49
-11
lines changed- include
- modules
- nets
4 files changed
+49
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
216 | 218 | | |
217 | 219 | | |
218 | 220 | | |
| |||
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
282 | | - | |
| 284 | + | |
283 | 285 | | |
284 | 286 | | |
285 | 287 | | |
| |||
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
311 | | - | |
| 313 | + | |
312 | 314 | | |
313 | 315 | | |
314 | 316 | | |
315 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
316 | 323 | | |
317 | 324 | | |
318 | 325 | | |
| |||
1710 | 1717 | | |
1711 | 1718 | | |
1712 | 1719 | | |
1713 | | - | |
| 1720 | + | |
1714 | 1721 | | |
1715 | 1722 | | |
1716 | 1723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
209 | 215 | | |
210 | 216 | | |
211 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
808 | 808 | | |
809 | 809 | | |
810 | 810 | | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
811 | 815 | | |
812 | 816 | | |
813 | 817 | | |
| |||
2044 | 2048 | | |
2045 | 2049 | | |
2046 | 2050 | | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
2047 | 2064 | | |
2048 | 2065 | | |
2049 | 2066 | | |
| |||
2114 | 2131 | | |
2115 | 2132 | | |
2116 | 2133 | | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
2117 | 2137 | | |
2118 | 2138 | | |
2119 | 2139 | | |
| |||
2122 | 2142 | | |
2123 | 2143 | | |
2124 | 2144 | | |
2125 | | - | |
2126 | | - | |
2127 | 2145 | | |
2128 | 2146 | | |
2129 | 2147 | | |
| |||
2223 | 2241 | | |
2224 | 2242 | | |
2225 | 2243 | | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
2226 | 2247 | | |
2227 | 2248 | | |
2228 | 2249 | | |
2229 | 2250 | | |
2230 | | - | |
2231 | | - | |
2232 | | - | |
2233 | | - | |
| 2251 | + | |
2234 | 2252 | | |
2235 | 2253 | | |
2236 | 2254 | | |
| |||
2636 | 2654 | | |
2637 | 2655 | | |
2638 | 2656 | | |
2639 | | - | |
| 2657 | + | |
2640 | 2658 | | |
2641 | 2659 | | |
2642 | 2660 | | |
| |||
2652 | 2670 | | |
2653 | 2671 | | |
2654 | 2672 | | |
| 2673 | + | |
| 2674 | + | |
2655 | 2675 | | |
2656 | 2676 | | |
2657 | 2677 | | |
| |||
3078 | 3098 | | |
3079 | 3099 | | |
3080 | 3100 | | |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
3081 | 3105 | | |
3082 | 3106 | | |
3083 | 3107 | | |
| |||
0 commit comments