From 356c4ae36a3e9e533bc8129bfeda06460cd111dd Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 22 Aug 2022 14:58:50 +0100 Subject: [PATCH 1/5] update --times logic and remove tests for this internal option --- FSharp.Profiles.props | 4 ++ FSharpBuild.Directory.Build.props | 1 + src/Compiler/Checking/CheckExpressions.fsi | 1 - src/Compiler/Driver/CompilerOptions.fs | 59 +++++++++++-------- src/Compiler/FSharp.Compiler.Service.fsproj | 2 +- src/Compiler/Utilities/illib.fs | 2 +- src/fsc/App.config | 2 +- src/fsc/fsc.targets | 2 +- .../Source/CompilerOptions/fsc/times/env.lst | 13 ---- .../CompilerOptions/fsc/times/error_01.fs | 4 -- .../CompilerOptions/fsc/times/error_02.fs | 4 -- .../CompilerOptions/fsc/times/error_04.fs | 5 -- .../CompilerOptions/fsc/times/times01.fs | 50 ---------------- .../CompilerOptions/fsi/times/asargument.fsx | 4 -- .../Source/CompilerOptions/fsi/times/env.lst | 13 ---- .../CompilerOptions/fsi/times/error_02.fs | 4 -- .../CompilerOptions/fsi/times/error_03.fs | 4 -- .../CompilerOptions/fsi/times/error_04.fs | 5 -- .../CompilerOptions/fsi/times/times01.fs | 4 -- tests/fsharpqa/Source/test.lst | 2 - 20 files changed, 45 insertions(+), 140 deletions(-) delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/times/env.lst delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/times/error_01.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/times/error_02.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/times/error_04.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/times/times01.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsi/times/asargument.fsx delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsi/times/env.lst delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsi/times/error_02.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsi/times/error_03.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsi/times/error_04.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsi/times/times01.fs diff --git a/FSharp.Profiles.props b/FSharp.Profiles.props index 4222cace487..1aad8497d1d 100644 --- a/FSharp.Profiles.props +++ b/FSharp.Profiles.props @@ -14,4 +14,8 @@ + + + $(MSBuildThisFileDirectory)src\fsc\runtimeconfig.template.json + diff --git a/FSharpBuild.Directory.Build.props b/FSharpBuild.Directory.Build.props index 9358ae23153..7e719d6cc13 100644 --- a/FSharpBuild.Directory.Build.props +++ b/FSharpBuild.Directory.Build.props @@ -21,6 +21,7 @@ 4.4.0 1182;0025;$(WarningsAsErrors) $(OtherFlags) --nowarn:3384 + $(OtherFlags) --times --nowarn:75 diff --git a/src/Compiler/Checking/CheckExpressions.fsi b/src/Compiler/Checking/CheckExpressions.fsi index 3b70a5caa1e..0bbaca89177 100644 --- a/src/Compiler/Checking/CheckExpressions.fsi +++ b/src/Compiler/Checking/CheckExpressions.fsi @@ -126,7 +126,6 @@ val TcFieldInit: range -> ILFieldInit -> Const val LightweightTcValForUsingInBuildMethodCall: g: TcGlobals -> vref: ValRef -> vrefFlags: ValUseFlag -> vrefTypeInst: TTypes -> m: range -> Expr * TType - /// Indicates whether a syntactic type is allowed to include new type variables /// not declared anywhere, e.g. `let f (x: 'T option) = x.Value` type ImplicitlyBoundTyparsAllowed = diff --git a/src/Compiler/Driver/CompilerOptions.fs b/src/Compiler/Driver/CompilerOptions.fs index c2e89e7c2c2..123eb60db2d 100644 --- a/src/Compiler/Driver/CompilerOptions.fs +++ b/src/Compiler/Driver/CompilerOptions.fs @@ -5,6 +5,7 @@ module internal FSharp.Compiler.CompilerOptions open System +open System.Diagnostics open System.IO open Internal.Utilities.Library open Internal.Utilities.Library.Extras @@ -2241,8 +2242,8 @@ let PrintWholeAssemblyImplementation (tcConfig: TcConfig) outfile header expr = // ReportTime //---------------------------------------------------------------------------- -let mutable tPrev = None -let mutable nPrev = None +let mutable tPrev: (DateTime * DateTime * float * int[]) option = None +let mutable nPrev: string option = None let ReportTime (tcConfig: TcConfig) descr = @@ -2278,29 +2279,41 @@ let ReportTime (tcConfig: TcConfig) descr = if (tcConfig.showTimes || verbose) then // Note that timing calls are relatively expensive on the startup path so we don't // make this call unless showTimes has been turned on. - let timeNow = - System.Diagnostics.Process.GetCurrentProcess().UserProcessorTime.TotalSeconds - + let p = Process.GetCurrentProcess() + let utNow = p.UserProcessorTime.TotalSeconds + let tNow = DateTime.Now let maxGen = GC.MaxGeneration let gcNow = [| for i in 0..maxGen -> GC.CollectionCount i |] - let ptime = System.Diagnostics.Process.GetCurrentProcess() - let wsNow = ptime.WorkingSet64 / 1000000L - - match tPrev, nPrev with - | Some (timePrev, gcPrev: int[]), Some prevDescr -> - let spanGC = [| for i in 0..maxGen -> GC.CollectionCount i - gcPrev[i] |] - dprintf "TIME: %4.1f Delta: %4.1f Mem: %3d" timeNow (timeNow - timePrev) wsNow - - dprintf - " G0: %3d G1: %2d G2: %2d [%s]\n" - spanGC[Operators.min 0 maxGen] - spanGC[Operators.min 1 maxGen] - spanGC[Operators.min 2 maxGen] - prevDescr - - | _ -> () - - tPrev <- Some(timeNow, gcNow) + let wsNow = p.WorkingSet64 / 1000000L + + let tStart = + match tPrev, nPrev with + | Some (tStart, tPrev, utPrev, gcPrev), Some prevDescr -> + let spanGC = [| for i in 0..maxGen -> GC.CollectionCount i - gcPrev[i] |] + let t = tNow - tStart + let tDelta = tNow - tPrev + let utDelta = utNow - utPrev + + printf + "Real: %4.1f Realdelta: %4.1f Cpu: %4.1f Cpudelta: %4.1f Mem: %3d" + t.TotalSeconds + tDelta.TotalSeconds + utNow + utDelta + wsNow + + printfn + " G0: %3d G1: %2d G2: %2d [%s]" + spanGC[Operators.min 0 maxGen] + spanGC[Operators.min 1 maxGen] + spanGC[Operators.min 2 maxGen] + prevDescr + + tStart + + | _ -> DateTime.Now + + tPrev <- Some(tStart, tNow, utNow, gcNow) nPrev <- Some descr diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index 5f53b8b610d..2efe648a3be 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -14,7 +14,7 @@ true $(DefineConstants);COMPILER $(DefineConstants);USE_SHIPPED_FSCORE - $(OtherFlags) --extraoptimizationloops:1 --times + $(OtherFlags) --extraoptimizationloops:1 $(OtherFlags) --warnon:1182 diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index eb86fce0030..6eab1b08508 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -104,7 +104,7 @@ module internal PervasiveAutoOpens = t) | Some t -> t - printf "ilwrite: TIME %10.3f (total) %10.3f (delta) - %s\n" (t - first) (t - prev) descr + printf " ilwrite: Cpu %4.1f (total) %4.1f (delta) - %s\n" (t - first) (t - prev) descr tPrev <- Some t let foldOn p f z x = f z (p x) diff --git a/src/fsc/App.config b/src/fsc/App.config index eb256128200..c1a8dd9b745 100644 --- a/src/fsc/App.config +++ b/src/fsc/App.config @@ -11,4 +11,4 @@ - \ No newline at end of file + diff --git a/src/fsc/fsc.targets b/src/fsc/fsc.targets index 9e4e4e48067..3096e71367e 100644 --- a/src/fsc/fsc.targets +++ b/src/fsc/fsc.targets @@ -22,7 +22,7 @@ - + {{FSCoreVersion}} $(FSCoreVersion) diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/times/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/times/env.lst deleted file mode 100644 index a66f99f264f..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/times/env.lst +++ /dev/null @@ -1,13 +0,0 @@ -# Functional: the option does what it is meant to do - SOURCE=times01.fs COMPILE_ONLY=1 SCFLAGS="--times" - SOURCE=times01.fs COMPILE_ONLY=1 TAILFLAGS="--times" - -# Last one wins... - SOURCE=times01.fs COMPILE_ONLY=1 SCFLAGS="--times --times" - -# Option is case sentitive - -# Mispelled options - -# Missing argument - SOURCE=error_04.fs COMPILE_ONLY=1 TAILFLAGS="--times:0" diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/times/error_01.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/times/error_01.fs deleted file mode 100644 index 3df58150e86..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/times/error_01.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #NoMT #CompilerOptions -//Unrecognized option: '--Times' -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/times/error_02.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/times/error_02.fs deleted file mode 100644 index 7232ba1d293..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/times/error_02.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #NoMT #CompilerOptions -//Unrecognized option: '--times-' -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/times/error_04.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/times/error_04.fs deleted file mode 100644 index 01735176c60..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/times/error_04.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #Regression #NoMT #CompilerOptions -//Unrecognized option: '--times' -// See FSHARP1.0:2850 (IMO, this is a bug!) -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/times/times01.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/times/times01.fs deleted file mode 100644 index 63a3663ff4d..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/times/times01.fs +++ /dev/null @@ -1,50 +0,0 @@ -// #NoMT #CompilerOptions -#light - -namespace N - module M = - let f x = () - f 10 - -namespace N2 - module M2 = - let f2 x = () - f2 10 - - module M3 = - exit 0 - -//TIME:.+Delta:.+Mem:.+G0:.+G1:.+G2:.+\[Import mscorlib and FSharp.Core.dll\] -//TIME:.+Delta:.+Mem:.+G0:.+G1:.+G2:.+\[Parse inputs\] -//TIME:.+Delta:.+Mem:.+G0:.+G1:.+G2:.+\[Import non-system references\] -//TIME:.+Delta:.+Mem:.+G0:.+G1:.+G2:.+\[Typecheck\] -//TIME:.+Delta:.+Mem:.+G0:.+G1:.+G2:.+\[Typechecked\] -//TIME:.+Delta:.+Mem:.+G0:.+G1:.+G2:.+\[Write XML docs\] -//TIME:.+Delta:.+Mem:.+G0:.+G1:.+G2:.+\[Encode Interface Data\] -//TIME:.+Delta:.+Mem:.+G0:.+G1:.+G2:.+\[TAST -> IL\] -//ilwrite: TIME.+Write Started -//ilwrite: TIME.+Module Generation Preparation -//ilwrite: TIME.+Module Generation Pass 1 -//ilwrite: TIME.+Module Generation Pass 2 -//ilwrite: TIME.+Module Generation Pass 3 -//ilwrite: TIME.+Module Generation Pass 4 -//ilwrite: TIME.+Finalize Module Generation Results -//ilwrite: TIME.+Generated Tables and Code -//ilwrite: TIME.+Layout Header of Tables -//ilwrite: TIME.+Build String/Blob Address Tables -//ilwrite: TIME.+Sort Tables -//ilwrite: TIME.+Write Header of tablebuf -//ilwrite: TIME.+Write Tables to tablebuf -//ilwrite: TIME.+Layout Metadata -//ilwrite: TIME.+Write Metadata Header -//ilwrite: TIME.+Write Metadata Tables -//ilwrite: TIME.+Write Metadata Strings -//ilwrite: TIME.+Write Metadata User Strings -//ilwrite: TIME.+Write Blob Stream -//ilwrite: TIME.+Fixup Metadata -//ilwrite: TIME.+Generated IL and metadata -//ilwrite: TIME.+Layout image -//ilwrite: TIME.+Writing Image -//ilwrite: TIME.+Finalize PDB -//ilwrite: TIME.+Signing Image -//TIME:.+Delta:.+Mem:.+G0:.+G1:.+G2:.+\[Write .NET Binary\] diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/times/asargument.fsx b/tests/fsharpqa/Source/CompilerOptions/fsi/times/asargument.fsx deleted file mode 100644 index a06a2fa3adb..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/times/asargument.fsx +++ /dev/null @@ -1,4 +0,0 @@ -// #NoMT #CompilerOptions -// -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/times/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsi/times/env.lst deleted file mode 100644 index 2f1494e0696..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/times/env.lst +++ /dev/null @@ -1,13 +0,0 @@ -# As argument, after -- - SOURCE=asargument.fsx COMPILE_ONLY=1 TAILFLAGS="-- --times" FSIMODE=EXEC - -# Last one wins... - SOURCE=times01.fs COMPILE_ONLY=1 SCFLAGS="--times --times" FSIMODE=PIPE - -# Mispelled options - SOURCE=error_02.fs SCFLAGS="--times-" FSIMODE=EXEC - SOURCE=error_03.fs SCFLAGS="--times+" FSIMODE=EXEC - -# Missing argument - SOURCE=error_04.fs TAILFLAGS="--times:0" FSIMODE=EXEC - diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/times/error_02.fs b/tests/fsharpqa/Source/CompilerOptions/fsi/times/error_02.fs deleted file mode 100644 index 7232ba1d293..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/times/error_02.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #NoMT #CompilerOptions -//Unrecognized option: '--times-' -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/times/error_03.fs b/tests/fsharpqa/Source/CompilerOptions/fsi/times/error_03.fs deleted file mode 100644 index 40b5dfee963..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/times/error_03.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #NoMT #CompilerOptions -//Unrecognized option: '--times\+' -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/times/error_04.fs b/tests/fsharpqa/Source/CompilerOptions/fsi/times/error_04.fs deleted file mode 100644 index 01735176c60..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/times/error_04.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #Regression #NoMT #CompilerOptions -//Unrecognized option: '--times' -// See FSHARP1.0:2850 (IMO, this is a bug!) -#light -exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/times/times01.fs b/tests/fsharpqa/Source/CompilerOptions/fsi/times/times01.fs deleted file mode 100644 index e30ea7ad563..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/times/times01.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #NoMT #CompilerOptions -//TIME.+Optimizations - -exit 0;; diff --git a/tests/fsharpqa/Source/test.lst b/tests/fsharpqa/Source/test.lst index 0932c7a1f49..31eac0a00f9 100644 --- a/tests/fsharpqa/Source/test.lst +++ b/tests/fsharpqa/Source/test.lst @@ -29,7 +29,6 @@ CompilerOptions01,NoMT,NoHostedCompiler CompilerOptions\fsc\staticlink CompilerOptions01,NoMT CompilerOptions\fsc\subsystemversion CompilerOptions01,NoMT CompilerOptions\fsc\tailcalls CompilerOptions01,NoMT CompilerOptions\fsc\target -CompilerOptions01,NoMT,NoHostedCompiler CompilerOptions\fsc\times CompilerOptions01,NoMT,NoHostedCompiler CompilerOptions\fsc\tokenize CompilerOptions01,NoMT CompilerOptions\fsc\responsefile CompilerOptions01,NoMT,help CompilerOptions\fsi\help @@ -37,7 +36,6 @@ CompilerOptions01,NoMT CompilerOptions\fsi\highentropyva CompilerOptions01,NoMT CompilerOptions\fsi\langversion CompilerOptions01,NoMT CompilerOptions\fsi\nologo CompilerOptions01,NoMT CompilerOptions\fsi\subsystemversion -CompilerOptions01,NoMT CompilerOptions\fsi\times CompilerOptions02,NoMT CompilerOptions\fsi\exename CompilerOptions01,NoMT,Determinism CompilerOptions\fsc\determinism From d3206c9ed46062fdfa047f1a766e59648361ef16 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 23 Aug 2022 01:38:02 +0100 Subject: [PATCH 2/5] Update fsc.targets --- src/fsc/fsc.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsc/fsc.targets b/src/fsc/fsc.targets index 3096e71367e..9e4e4e48067 100644 --- a/src/fsc/fsc.targets +++ b/src/fsc/fsc.targets @@ -22,7 +22,7 @@ - + {{FSCoreVersion}} $(FSCoreVersion) From 627d839ad47e8401653d7b9aaae57ee338b2a441 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 23 Aug 2022 01:38:25 +0100 Subject: [PATCH 3/5] Update FSharp.Profiles.props --- FSharp.Profiles.props | 4 ---- 1 file changed, 4 deletions(-) diff --git a/FSharp.Profiles.props b/FSharp.Profiles.props index 1aad8497d1d..4222cace487 100644 --- a/FSharp.Profiles.props +++ b/FSharp.Profiles.props @@ -14,8 +14,4 @@ - - - $(MSBuildThisFileDirectory)src\fsc\runtimeconfig.template.json - From 9ca95691a8123c4e8317283efe9d292a7b15ea80 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 23 Aug 2022 01:38:56 +0100 Subject: [PATCH 4/5] Update App.config From f7355722d9070f8ef5ef9d2eb6ef2791f4bf78c6 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 23 Aug 2022 01:39:23 +0100 Subject: [PATCH 5/5] Update CheckExpressions.fsi --- src/Compiler/Checking/CheckExpressions.fsi | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Compiler/Checking/CheckExpressions.fsi b/src/Compiler/Checking/CheckExpressions.fsi index 0bbaca89177..3b70a5caa1e 100644 --- a/src/Compiler/Checking/CheckExpressions.fsi +++ b/src/Compiler/Checking/CheckExpressions.fsi @@ -126,6 +126,7 @@ val TcFieldInit: range -> ILFieldInit -> Const val LightweightTcValForUsingInBuildMethodCall: g: TcGlobals -> vref: ValRef -> vrefFlags: ValUseFlag -> vrefTypeInst: TTypes -> m: range -> Expr * TType + /// Indicates whether a syntactic type is allowed to include new type variables /// not declared anywhere, e.g. `let f (x: 'T option) = x.Value` type ImplicitlyBoundTyparsAllowed =