dream icon indicating copy to clipboard operation
dream copied to clipboard

Dream eml performance boost

Open katel0k opened this issue 6 months ago • 0 comments

This pr aims to improve dream eml performance after this issue. During testing it was determined that the main cause of slow performance is excessive buffers allocations. The fix is a simple pool of buffers, created once per file. This pr also introduces 2 new options for dream eml executable: buffer-size and pool-size. They are self-explanatory: buffer-size is the size of each of the buffers created and pool-size is the initial amount of buffers created.

I have considered doing a project-wide pool, but that seems to be impossible as dream_eml is launched per file and is not imported for .eml files. Hopefully due to ocaml multithreading model, not placing a mutex on the buffer was a correct solution (please correct me if I'm wrong)

Test is done via simple benchmark, an eml file generating lots of repeating divs is created. After eml preprocessing, time is measured using ocaml-benchmark for different volumes of html. I have then plotted relative time of executions. Here is a plot of relative speed up, comparing previous and newer iterations. On average, 2.6x speed up is observed.

It is mostly related to major heap allocations, and reducing those, especially for bigger values, resulted in the speedup

ratio

katel0k avatar Jun 01 '25 20:06 katel0k