Skip to content

Conversation

@aseigo
Copy link
Contributor

@aseigo aseigo commented Dec 23, 2025

Currently, the benchmarks do not run due to changes in Benchee (specifically the removals of formatter_options). This PR brings the benchmark code up to par with current Bench and:

  • adds a helper module which standardizes the formatters
  • adds HTML output
  • uses Stream where appropriate
  • adds a control run where helpful to disambiguate overhead from Ecto.SQL code

Stream removes some of the overhead jitter of Enum, and having a
control test helps one understand what the overhead of the test itself
is versus what sort of time is being spent in EctoSQL modules
1..100_000
|> Enum.map(fn _ -> %{name: "Alice", uuid: Ecto.UUID.bingenerate()} end)
|> Stream.map(fn _ -> %{name: "Alice", uuid: Ecto.UUID.bingenerate()} end)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep on using Enum, because it is likely that you will spend even more time on streams (streams are more CPU intensive, less memory intensive). Enum will use more memory but it is allocated outside of the benchmark.

Another suggestion is to use Enum.each in the benchmarks below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Enum.each is slightly faster here than Stream.map |> Stream.run (though Enum.map is considerably slower, probably due to allocations and building rather large lists).

My goal with this change was to minimize the amount of overhead there is in the tests so improvements to performance are more visible and don't get lost in "noise" due to overhead dominating too much.

See b98e6ac

Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment and we can ship it!

@aseigo aseigo requested a review from josevalim December 23, 2025 18:16
@josevalim josevalim merged commit 82e2eb3 into elixir-ecto:master Dec 23, 2025
11 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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