Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve usage of Tasks #1111

Merged
merged 4 commits into from
Jan 17, 2024
Merged

Improve usage of Tasks #1111

merged 4 commits into from
Jan 17, 2024

Conversation

novaugust
Copy link
Contributor

@novaugust novaugust commented Jan 12, 2024

Similar to #1077, optimizes the use of streams of tasks in credo in a few more places.

in addition to swapping Enum.map(&Task.async(...)) -> Task.async_stream, this pr also removes ordering from the streams (where possible) for more slight performance gains (h/t @milmazz)

@rrrene
Copy link
Owner

rrrene commented Jan 12, 2024

Seems to improve performance 👍

Can we have some real-world numbers regarding speed difference, like in #1077?

@novaugust
Copy link
Contributor Author

running against 3842 files, it's negligible but there.

here's credo master, with credo's default checks enabled:

> # credo master
> hyperfine 'mix credo' -i --warmup 1
Benchmark 1: mix credo
  Time (mean ± σ):     24.770 s ±  0.331 s    [User: 187.391 s, System: 13.010 s]
  Range (min … max):   24.340 s … 25.235 s    10 runs

and here's against this branch:

> # Task.async_stream refactor
> hyperfine 'mix credo' -i --warmup 1
Benchmark 1: mix credo
  Time (mean ± σ):     24.077 s ±  0.421 s    [User: 182.291 s, System: 10.692 s]
  Range (min … max):   23.674 s … 24.633 s    10 runs

still, negligible enough that i'd understand not merging.

looking at just DuplicatedCode, a single-run test took it from 17412ms to 15451ms, but running it in isolation probably isn't the best test.
the crux here is that the checks that are slow in my codebase aren't really affected by these changes, so i don't see much of a difference :)

@rrrene
Copy link
Owner

rrrene commented Jan 13, 2024

I'm sure merging this is worth the performance benefit. My preliminary tests all show good results.

I was just looking for some real world data (and maybe a check that earlier OTP versions are not getting slower). 👍

@rrrene rrrene merged commit 41d7f20 into rrrene:master Jan 17, 2024
14 checks passed
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