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

Basic concurrent checking #13049

Merged
merged 3 commits into from
Aug 24, 2024
Merged

Basic concurrent checking #13049

merged 3 commits into from
Aug 24, 2024

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Aug 22, 2024

Summary

This PR makes workspace.check to check the files concurrently.

This PR doesn't explore more advanced scheduling. For example, we could try to not only schedule the workspace files
but also the dependencies of those files. This would give us better performance where a project has few first-party modules but depends on many third-party modules.

The main downside of concurrent checking is that the logs become harder to read, especially when using -vvv because the output of different threads is intertwined. I don't have a good solution for this yet other than using RAYON_NUM_THREADS=1 to explicitly fall-back to a single thread.

Test Plan

Checking black goes down from 108ms to 34ms (12 cores)

Main

black (cold)
Benchmark 1: knot
  Time (mean ± σ):     125.2 ms ±   3.8 ms    [User: 89.3 ms, System: 35.7 ms]
  Range (min … max):   117.7 ms … 133.3 ms    24 runs
 
  Warning: Ignoring non-zero exit code.
 
jinja (cold)
Benchmark 1: knot
  Time (mean ± σ):     139.1 ms ±   9.2 ms    [User: 100.1 ms, System: 38.8 ms]
  Range (min … max):   125.0 ms … 155.7 ms    22 runs
 
  Warning: Ignoring non-zero exit code.
 
isort (cold)
Benchmark 1: knot
  Time (mean ± σ):      85.2 ms ±   2.3 ms    [User: 60.1 ms, System: 25.0 ms]
  Range (min … max):    80.6 ms …  89.1 ms    32 runs
 
  Warning: Ignoring non-zero exit code.

Concurrent

uv run benchmark  --min-runs=3 --knot
black (cold)
Benchmark 1: knot
  Time (mean ± σ):      36.1 ms ±   1.1 ms    [User: 125.6 ms, System: 71.7 ms]
  Range (min … max):    33.3 ms …  39.4 ms    77 runs
 
  Warning: Ignoring non-zero exit code.
 
jinja (cold)
Benchmark 1: knot
  Time (mean ± σ):      32.6 ms ±   1.5 ms    [User: 140.8 ms, System: 88.7 ms]
  Range (min … max):    29.5 ms …  36.4 ms    88 runs
 
  Warning: Ignoring non-zero exit code.
 
isort (cold)
Benchmark 1: knot
  Time (mean ± σ):      30.7 ms ±   1.2 ms    [User: 82.4 ms, System: 46.7 ms]
  Range (min … max):    28.4 ms …  34.4 ms    89 runs
 
  Warning: Ignoring non-zero exit code.

@MichaReiser MichaReiser added the red-knot Multi-file analysis & type inference label Aug 22, 2024
Copy link

codspeed-hq bot commented Aug 22, 2024

CodSpeed Performance Report

Merging #13049 will not alter performance

Comparing concurrent=checking (acbed7c) with main (1f2cb09)

Summary

✅ 32 untouched benchmarks

Copy link
Contributor

github-actions bot commented Aug 22, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser MichaReiser changed the title A very basic prototype for concurrent checking Basic concurrent checking Aug 23, 2024
@MichaReiser MichaReiser marked this pull request as ready for review August 23, 2024 08:17
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Awesome!

@MichaReiser MichaReiser merged commit ecab04e into main Aug 24, 2024
20 checks passed
@MichaReiser MichaReiser deleted the concurrent=checking branch August 24, 2024 08:53
AlexWaygood added a commit that referenced this pull request Aug 28, 2024
Followup to #13049. We check files concurrently now; to get readable logs, you probably want to switch that off
AlexWaygood added a commit that referenced this pull request Aug 28, 2024
…13140)

Followup to #13049. We check files concurrently now; to get readable
logs, you probably want to switch that off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants