-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Adds naive parallel formatting implementation #2717
Adds naive parallel formatting implementation #2717
Conversation
6526461
to
757a409
Compare
04597c4
to
3967e67
Compare
3967e67
to
248d834
Compare
c0771e5
to
219f34b
Compare
@TheAngryByrd is the |
I didn't touch it so doubtful. |
Seems to already be running parallel: https://github.com/fsprojects/fantomas/blob/main/src/Fantomas/Format.fs#L118 |
4de0b58
to
2f5e9d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 requirement needed to be redefined but ready to review otherwise.
@@ -52,7 +52,7 @@ end_of_line=cr | |||
""" | |||
) | |||
|
|||
let args = sprintf "%s %s" NormalVerbosity fileFixture.Filename | |||
let args = sprintf "%s %s" DetailedVerbosity fileFixture.Filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed we didn't want to show all exception messages unless they came from specific fantomas exceptions. However, fantomas uses failwith
in many places instead of it's own exceptions. Should we keep this requirement, always show all the exceptions, or rework all the places with failwith
to throw a known Fantomas exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can focus on FormatException
for now. Show that specific message for normal logging.
And print something generic in case it came for failwith
.
Unless we are in verbose mode, then I think we show the full exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work Jimmy! This looks really good!
As always, I had some nitpicks but with some tweaks, we can merge this first version I think.
I think we will need to dogfood this a bit to ensure everything is what we want.
Program.main args |> ignore | ||
|
||
// Currently have to manually pull these repositories | ||
[<Params("FsToolkit.ErrorHandling", "FAKE", "fsharp", "Plotly.NET")>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can re-use some work of regression.fsx
perhaps.
match Array.tryLast fsi.CommandLineArgs with
| Some "--benchmark" ->
printfn "do benchmark stuff"
| _ ->
// Ensure Fantomas dll is built
(wrap fantomasRoot "dotnet" $"build -c Release {fantomasProject}").Wait()
// Run repositories
for repo in repositories do
(run repo).Wait()
and refactor configurtion.fsx
to create a second list with projects we want to use for this benchmark.
printfn $"git reset --hard {projectDir}" | ||
|
||
let psi = | ||
System.Diagnostics.ProcessStartInfo("git", "reset --hard", WorkingDirectory = projectDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would replace this with CliWrap
and just call the regression.fsx
script with the additional argument.
Cli.Wrap("dotnet").WithWorkingDirectory("the correct pwd").WithArguments(@"fsi regressions.fsx --benchmark")
src/Fantomas.Benchmarks/Program.fs
Outdated
|
||
[<EntryPoint>] | ||
let main _ = | ||
|
||
// BenchmarkRunner.Run<ParallelVsSequentialFormatting>() |> ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove old comment.
@@ -52,7 +52,7 @@ end_of_line=cr | |||
""" | |||
) | |||
|
|||
let args = sprintf "%s %s" NormalVerbosity fileFixture.Filename | |||
let args = sprintf "%s %s" DetailedVerbosity fileFixture.Filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can focus on FormatException
for now. Show that specific message for normal logging.
And print something generic in case it came for failwith
.
Unless we are in verbose mode, then I think we show the full exception.
src/Fantomas/Program.fs
Outdated
@@ -17,6 +19,7 @@ type Arguments = | |||
| [<Unique>] Out of string | |||
| [<Unique>] Check | |||
| [<Unique>] Daemon | |||
| [<Unique>] Sequential |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shower thought: do we even need this setting? As we don't have it for --check
right now.
Less is more right? Thoughts @TheAngryByrd @dawedawe @josh-degraw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to go without it.
src/Fantomas/Program.fs
Outdated
| VerbosityLevel.Normal -> | ||
match ex with | ||
| :? Fantomas.Core.FormatException as fe -> fe.Message | ||
| :? CodeFormatException as fe -> fe.Message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think CodeFormatException
is raised anywhere?
72d5915
to
680636e
Compare
Hi all, I made some liberal changes to this PR: Cliffnotes:
This by no means needs to be the final proposal for v6, but I think it is a step in the good direction and allows us to merge @TheAngryByrd's work. What do you think @dawedawe @TheAngryByrd @josh-degraw @edgarfgp? |
I like it a lot. Had something similar in mind but planned to wait for the merge of this one. |
Fix for #2624. Does a rather naive "collect all the async and run at the end" but seems to give really promising numbers.
Test results on my machine
BenchmarkDotNet=v0.13.2, OS=Windows 11 (10.0.22000.1455/21H2)
12th Gen Intel Core i9-12900F, 1 CPU, 24 logical and 16 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2 DEBUG
Job-XAWGZF : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2
Server=True IterationCount=1 RunStrategy=ColdStart
Please verify your pull request is respecting our Pull request ground rules.
You can find more information in our Contributors documentation section.