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

IlxGen parallelization #14372

Merged
merged 53 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
d73ab48
Revive ilxgen para
T-Gro Nov 22, 2022
e136beb
formatting applied
T-Gro Nov 22, 2022
7cd191d
Merge branch 'main' into parallel-il-gen-revive
T-Gro Nov 22, 2022
a4a31db
Safer stack handling in recursive scenarios
T-Gro Nov 22, 2022
eff765a
reformatted
T-Gro Nov 22, 2022
bfacdf4
GenerateResourcesForQuotations
T-Gro Nov 22, 2022
6968abf
cleanup
T-Gro Nov 23, 2022
5feacea
fsc.exe test switch added
T-Gro Nov 23, 2022
b811356
formatted
T-Gro Nov 23, 2022
480a54d
Automatically enabled experimental features (based on env var)
T-Gro Nov 23, 2022
e48fc45
Improved dict defaults to avoid collisions
T-Gro Nov 24, 2022
b53b1e5
format
T-Gro Nov 24, 2022
0751cae
more aggressive ilxgen parallelization
T-Gro Nov 24, 2022
327b418
Reducing locks in certain paths
T-Gro Nov 24, 2022
013c93b
thread safety comments
T-Gro Nov 24, 2022
6f877cf
formatted
T-Gro Nov 24, 2022
801115a
Merge branch 'main' into parallel-il-gen-revive
T-Gro Nov 24, 2022
422c168
A few more concurrency related changes
T-Gro Nov 25, 2022
1c63f9e
formatting
T-Gro Nov 25, 2022
5810320
Thread safety in AnonTypeGenerationTable and AssemblyBuilder
T-Gro Nov 25, 2022
41facc4
TypeDefsBuilder made concurrent
T-Gro Nov 25, 2022
9425fa1
Making sure we emit IL methods for AnnonTypes in same order as before
T-Gro Nov 25, 2022
de85e92
format
T-Gro Nov 25, 2022
fa3bc30
Thread safe security attribute check caching and removing unused Asyn…
T-Gro Nov 25, 2022
3fda470
cleanups and unused deletions
T-Gro Nov 25, 2022
ea32830
NiceNameGenerator without explicit locks
T-Gro Nov 25, 2022
6493ede
Lock prevention in name generation
T-Gro Nov 28, 2022
57c1493
Simplify queue of delayed code
T-Gro Nov 28, 2022
fe4cbb0
Code review - comments added
T-Gro Nov 29, 2022
827055b
Code review comments added
T-Gro Nov 29, 2022
f538ad7
StampedDictionary.Update -> UpdateIfExists
T-Gro Nov 29, 2022
16a7373
Merge branch 'main' into parallel-il-gen-revive
T-Gro Nov 29, 2022
2053441
Naming improvements
T-Gro Nov 29, 2022
e8ef317
Apply suggestions from code review
T-Gro Nov 29, 2022
c50a3d3
Update comments
T-Gro Nov 29, 2022
3922eaf
Removing commented-out code
T-Gro Nov 29, 2022
5c4212e
Code review feedback
T-Gro Nov 29, 2022
019b002
Automated command ran: fantomas
github-actions[bot] Nov 29, 2022
c86d030
Spelling corrections
T-Gro Nov 29, 2022
ffa51f0
Merge branch 'main' into parallel-il-gen-revive
T-Gro Nov 30, 2022
53e59ce
Update src/Compiler/CodeGen/IlxGen.fs
T-Gro Nov 30, 2022
0b4dbb5
Testing enablement via -p:AdditionalFscCmdFlags
T-Gro Dec 5, 2022
95c1acc
Merge branch 'main' into parallel-il-gen-revive
T-Gro Dec 5, 2022
452135f
Preventing "enqueue within enqueue"
T-Gro Dec 7, 2022
f4b4568
Merge branch 'main' into parallel-il-gen-revive
T-Gro Dec 8, 2022
661bfe1
Merge branch 'main' into parallel-il-gen-revive
T-Gro Dec 14, 2022
7e89825
Merge branch 'main' into parallel-il-gen-revive
T-Gro Dec 16, 2022
25dc3b0
Merge branch 'main' into parallel-il-gen-revive
T-Gro Jan 5, 2023
b0a94c2
Drive signature file parallel checking based on new flag as well
T-Gro Jan 5, 2023
7e242e7
Adding FSHARP_EXPERIMENTAL_FEATURES regular and deterministic builds
T-Gro Jan 5, 2023
ebec2eb
When running a deterministic build, parallel ilxgen is disabled (to h…
T-Gro Jan 6, 2023
f7f2ee1
fantomas
T-Gro Jan 6, 2023
4eeb56e
Deduplicating build definitions into matrix
T-Gro Jan 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 22 additions & 29 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ stages:
name: $(DncEngPublicBuildPool)
demands: ImageOverride -equals $(WindowsMachineQueueName)
timeoutInMinutes: 90
strategy:
maxParallel: 2
matrix:
regular:
_experimental_flag: null
experimental_features:
_experimental_flag: 1
steps:
- checkout: self
clean: true
Expand All @@ -229,6 +236,8 @@ stages:
workingDirectory: $(Build.SourcesDirectory)
installationPath: $(Build.SourcesDirectory)/.dotnet
- script: .\eng\test-determinism.cmd -configuration Debug
env:
FSHARP_EXPERIMENTAL_FEATURES: $(_experimental_flag)
displayName: Determinism tests with Debug configuration
- task: PublishPipelineArtifact@1
displayName: Publish Determinism Logs
Expand Down Expand Up @@ -492,11 +501,22 @@ stages:
pool:
name: $(DncEngPublicBuildPool)
demands: ImageOverride -equals $(WindowsMachineQueueName)
strategy:
maxParallel: 2
matrix:
regular:
_experimental_flag: null
experimental_features:
_experimental_flag: 1
steps:
- checkout: self
clean: true
- script: .\Build.cmd -c Release -pack
env:
FSHARP_EXPERIMENTAL_FEATURES: $(_experimental_flag)
- script: .\tests\EndToEndBuildTests\EndToEndBuildTests.cmd -c Release
env:
FSHARP_EXPERIMENTAL_FEATURES: $(_experimental_flag)
displayName: End to end build tests

# Up-to-date - disabled due to it being flaky
Expand All @@ -512,35 +532,8 @@ stages:
# filePath: eng\tests\UpToDate.ps1
# arguments: -configuration $(_BuildConfig) -ci -binaryLog

# Run Build with --test:ParallelCheckingWithSignatureFilesOn
- job: ParallelCheckingWithSignatureFiles
condition: eq(variables['Build.Reason'], 'PullRequest')
variables:
- name: _SignType
value: Test
pool:
name: $(DncEngPublicBuildPool)
demands: ImageOverride -equals $(WindowsMachineQueueName)
timeoutInMinutes: 90
steps:
- checkout: self
clean: true
- task: UseDotNet@2
displayName: install SDK
inputs:
packageType: sdk
useGlobalJson: true
includePreviewVersions: false
workingDirectory: $(Build.SourcesDirectory)
installationPath: $(Build.SourcesDirectory)/.dotnet
- script: .\build.cmd -c Release -binaryLog /p:ParallelCheckingWithSignatureFilesOn=true
displayName: ParallelCheckingWithSignatureFiles build with Debug configuration
- task: PublishPipelineArtifact@1
displayName: Publish ParallelCheckingWithSignatureFiles Logs
inputs:
targetPath: '$(Build.SourcesDirectory)/artifacts/log/Release'
artifactName: 'ParallelCheckingWithSignatureFiles Attempt $(System.JobAttempt) Logs'
continueOnError: true
# Run Build with Fsharp Experimental Features
# Possible change: --times:$(Build.SourcesDirectory)/artifacts/log/Release/compiler_timing.csv

# Plain build Windows
- job: Plain_Build_Windows
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3902,7 +3902,7 @@ let prependInstrsToCode (instrs: ILInstr list) (c2: ILCode) =
// If there is a sequence point as the first instruction then keep it at the front
| I_seqpoint _ as i0 ->
let labels =
let dict = Dictionary.newWithSize c2.Labels.Count
let dict = Dictionary.newWithSize (c2.Labels.Count * 2) // Decrease chance of collisions by oversizing the hashtable
T-Gro marked this conversation as resolved.
Show resolved Hide resolved

for kvp in c2.Labels do
dict.Add(kvp.Key, (if kvp.Value = 0 then 0 else kvp.Value + n))
Expand All @@ -3915,7 +3915,7 @@ let prependInstrsToCode (instrs: ILInstr list) (c2: ILCode) =
}
| _ ->
let labels =
let dict = Dictionary.newWithSize c2.Labels.Count
let dict = Dictionary.newWithSize (c2.Labels.Count * 2) // Decrease chance of collisions by oversizing the hashtable

for kvp in c2.Labels do
dict.Add(kvp.Key, kvp.Value + n)
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/AbstractIL/ilmorph.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let code_instr2instrs f (code: ILCode) =
adjust[old] <- nw

let labels =
let dict = Dictionary.newWithSize code.Labels.Count
let dict = Dictionary.newWithSize (code.Labels.Count * 2) // Decrease chance of collisions by oversizing the hashtable

for kvp in code.Labels do
dict.Add(kvp.Key, adjust[kvp.Value])
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/Checking/AttributeChecking.fs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ let CheckRecdFieldInfoAttributes g (x:RecdFieldInfo) m =
CheckRecdFieldAttributes g x.RecdFieldRef m

// Identify any security attributes
let IsSecurityAttribute (g: TcGlobals) amap (casmap : Dictionary<Stamp, bool>) (Attrib(tcref, _, _, _, _, _, _)) m =
let IsSecurityAttribute (g: TcGlobals) amap (casmap : IDictionary<Stamp, bool>) (Attrib(tcref, _, _, _, _, _, _)) m =
// There's no CAS on Silverlight, so we have to be careful here
match g.attrib_SecurityAttribute with
| None -> false
Expand All @@ -533,7 +533,7 @@ let IsSecurityAttribute (g: TcGlobals) amap (casmap : Dictionary<Stamp, bool>) (
match casmap.TryGetValue tcs with
| true, c -> c
| _ ->
let exists = ExistsInEntireHierarchyOfType (fun t -> typeEquiv g t (mkAppTy attr.TyconRef [])) g amap m AllowMultiIntfInstantiations.Yes (mkAppTy tcref [])
let exists = ExistsInEntireHierarchyOfType (fun t -> typeEquiv g t (mkAppTy attr.TyconRef [])) g amap m AllowMultiIntfInstantiations.Yes (mkAppTy tcref [])
casmap[tcs] <- exists
exists
| ValueNone -> false
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/AttributeChecking.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ val CheckValAttributes: g: TcGlobals -> x: ValRef -> m: range -> OperationResult
val CheckRecdFieldInfoAttributes: g: TcGlobals -> x: RecdFieldInfo -> m: range -> OperationResult<unit>

val IsSecurityAttribute:
g: TcGlobals -> amap: Import.ImportMap -> casmap: Dictionary<Stamp, bool> -> Attrib -> m: range -> bool
g: TcGlobals -> amap: Import.ImportMap -> casmap: IDictionary<Stamp, bool> -> Attrib -> m: range -> bool

val IsSecurityCriticalAttribute: g: TcGlobals -> Attrib -> bool

Expand Down
6 changes: 3 additions & 3 deletions src/Compiler/Checking/MethodCalls.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1806,9 +1806,9 @@ module ProvidedMethodCalls =
expr: Tainted<ProvidedExpr>) =

let varConv =
// note: using paramVars.Length as assumed initial size, but this might not
// be the optimal value; this wasn't checked before obsoleting Dictionary.ofList
let dict = Dictionary.newWithSize paramVars.Length
// note: Assuming the size based on paramVars
// Doubling to decrease chance of collisions
let dict = Dictionary.newWithSize (paramVars.Length*2)
for v, e in Seq.zip (paramVars |> Seq.map (fun x -> x.PUntaint(id, m))) (Option.toList thisArg @ allArgs) do
dict.Add(v, (None, e))
dict
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/QuotationTranslator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open System.Collections.Generic

module QP = QuotationPickler

let verboseCReflect = condition "VERBOSE_CREFLECT"
let verboseCReflect = isEnvVarSet "VERBOSE_CREFLECT"

[<RequireQualifiedAccess>]
type IsReflectedDefinition =
Expand Down
Loading