On my low-endish server, a mailbox with 4K threads takes ~15s to render the threaded mail view, 99% of that time being spent in functions/imap_messages.php get_parent_level. Appears that almost all of that time is spent calculating the array length at the end clauses of for loops. Calculating the array lengths once before the loops and using those in the exit clauses gives a roughly 10-fold speedup for my workload. Patch attached.
Log in to post a comment.