Skip to content

Dream eml performance boost#397

Open
katel0k wants to merge 4 commits intocamlworks:masterfrom
katel0k:eml_buffer_pool
Open

Dream eml performance boost#397
katel0k wants to merge 4 commits intocamlworks:masterfrom
katel0k:eml_buffer_pool

Conversation

@katel0k
Copy link

@katel0k katel0k commented Jun 1, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant