Skip to content

Replace :lists.foreach with recursive function#65

Closed
rkallos wants to merge 1 commit intomainfrom
perf/remove-foreach
Closed

Replace :lists.foreach with recursive function#65
rkallos wants to merge 1 commit intomainfrom
perf/remove-foreach

Conversation

@rkallos
Copy link
Copy Markdown
Owner

@rkallos rkallos commented Feb 23, 2026

This is a pretty small change in the hot path. It replaces the use of a :lists.foreach call with a recursive function. It also splits out fetch_measurement/3 into separate function heads, though there's no noticeable change in performance there.

The improvements, as measured by tprof, using a simple microbenchmark

  • :call_time - The fastest experimental run is 3% faster than the fastest control run on my personal computer (~86ms faster)
  • :call_memory - 10% reduction in words allocated (6 words per call to :telemetry.execute) in experimental runs. I suspect this allocated memory is related to the closure that is passed to :lists.foreach.

@hauleth
Copy link
Copy Markdown
Contributor

hauleth commented Feb 23, 2026

I have similar changes as well, but with more extras. However currently these depends on #64 in my repo. I probably could clean this up to make it independent, but it is almost exactly the same as yours.

@rkallos
Copy link
Copy Markdown
Owner Author

rkallos commented Feb 24, 2026

That sounds great! I merged your other PR, so feel free to open a new one.

@rkallos
Copy link
Copy Markdown
Owner Author

rkallos commented Feb 25, 2026

Closing. #69 covered this work and took it further.

@rkallos rkallos closed this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants