Skip to content

Commit c070a10

Browse files
authored
Merge branch 'main' into async2
2 parents a2d2575 + c193b34 commit c070a10

File tree

13 files changed

+52
-26
lines changed

13 files changed

+52
-26
lines changed

azure-pipelines-PR.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ stages:
321321

322322
- script: eng\CIBuildNoPublish.cmd -compressallmetadata -buildnorealsig -testDesktop -configuration Release -testBatch $(System.JobPositionInPhase)
323323
env:
324+
FSharp_CacheEvictionImmediate: true
324325
DOTNET_DbgEnableMiniDump: 1
325326
DOTNET_DbgMiniDumpType: 3 # Triage dump, 1 for mini, 2 for Heap, 3 for triage, 4 for full. Don't use 4 unless you know what you're doing.
326327
DOTNET_DbgMiniDumpName: $(Build.SourcesDirectory)\artifacts\log\Release\$(Build.BuildId)-%e-%p-%t.dmp
@@ -456,11 +457,13 @@ stages:
456457
fsharpqa_release:
457458
_configuration: Release
458459
_testKind: testFSharpQA
460+
FSharp_CacheEvictionImmediate: true
459461
transparentCompiler:
460462
vs_release:
461463
_configuration: Release
462464
_testKind: testVs
463465
setupVsHive: true
466+
FSharp_CacheEvictionImmediate: true
464467
transparentCompiler:
465468
transparent_compiler_release:
466469
_configuration: Release
@@ -559,6 +562,7 @@ stages:
559562

560563
- script: eng\CIBuildNoPublish.cmd -compressallmetadata -configuration Release -testDesktop -testBatch $(System.JobPositionInPhase)
561564
env:
565+
FSharp_CacheEvictionImmediate: true
562566
DOTNET_DbgEnableMiniDump: 1
563567
DOTNET_DbgMiniDumpType: 3 # Triage dump, 1 for mini, 2 for Heap, 3 for triage, 4 for full. Don't use 4 unless you know what you're doing.
564568
DOTNET_DbgMiniDumpName: $(Build.SourcesDirectory)\artifacts\log\Release\$(Build.BuildId)-%e-%p-%t.dmp

docs/release-notes/.FSharp.Core/10.0.100.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
### Fixed
22

3+
* Correct a typo in docs for List.sort ([PR #18938](https://github.com/dotnet/fsharp/pull/18938))
4+
35
### Added
46

57
* Enable more `string` optimizations by adding `when 'T : Enum` library-only library-only static optimization constraint. ([PR #18546](https://github.com/dotnet/fsharp/pull/18546))

src/Compiler/Checking/InfoReader.fs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,9 @@ type InfoReader(g: TcGlobals, amap: Import.ImportMap) as this =
727727
/// Make a cache for function 'f' keyed by type (plus some additional 'flags') that only
728728
/// caches computations for monomorphic types.
729729
730-
let MakeInfoCache f (flagsEq : IEqualityComparer<_>) =
730+
let MakeInfoCache name f (flagsEq : IEqualityComparer<_>) =
731731
MemoizationTable<_, _>
732-
(compute=f,
732+
(name, compute=f,
733733
// Only cache closed, monomorphic types (closed = all members for the type
734734
// have been processed). Generic type instantiations could be processed if we had
735735
// a decent hash function for these.
@@ -803,18 +803,18 @@ type InfoReader(g: TcGlobals, amap: Import.ImportMap) as this =
803803
member _.GetHashCode((ad, nm)) = AccessorDomain.CustomGetHashCode ad + hash nm
804804
member _.Equals((ad1, nm1), (ad2, nm2)) = AccessorDomain.CustomEquals(g, ad1, ad2) && (nm1 = nm2) }
805805

806-
let methodInfoCache = MakeInfoCache GetIntrinsicMethodSetsUncached hashFlags0
807-
let propertyInfoCache = MakeInfoCache GetIntrinsicPropertySetsUncached hashFlags0
808-
let recdOrClassFieldInfoCache = MakeInfoCache GetIntrinsicRecdOrClassFieldInfosUncached hashFlags1
809-
let ilFieldInfoCache = MakeInfoCache GetIntrinsicILFieldInfosUncached hashFlags1
810-
let eventInfoCache = MakeInfoCache GetIntrinsicEventInfosUncached hashFlags1
811-
let namedItemsCache = MakeInfoCache GetIntrinsicNamedItemsUncached hashFlags2
812-
let mostSpecificOverrideMethodInfoCache = MakeInfoCache GetIntrinsicMostSpecificOverrideMethodSetsUncached hashFlags0
813-
814-
let entireTypeHierarchyCache = MakeInfoCache GetEntireTypeHierarchyUncached HashIdentity.Structural
815-
let primaryTypeHierarchyCache = MakeInfoCache GetPrimaryTypeHierarchyUncached HashIdentity.Structural
816-
let implicitConversionCache = MakeInfoCache FindImplicitConversionsUncached hashFlags3
817-
let isInterfaceWithStaticAbstractMethodCache = MakeInfoCache IsInterfaceTypeWithMatchingStaticAbstractMemberUncached hashFlags4
806+
let methodInfoCache = MakeInfoCache "methodInfoCache" GetIntrinsicMethodSetsUncached hashFlags0
807+
let propertyInfoCache = MakeInfoCache "propertyInfoCache" GetIntrinsicPropertySetsUncached hashFlags0
808+
let recdOrClassFieldInfoCache = MakeInfoCache "recdOrClassFieldInfoCache" GetIntrinsicRecdOrClassFieldInfosUncached hashFlags1
809+
let ilFieldInfoCache = MakeInfoCache "ilFieldInfoCache" GetIntrinsicILFieldInfosUncached hashFlags1
810+
let eventInfoCache = MakeInfoCache "eventInfoCache" GetIntrinsicEventInfosUncached hashFlags1
811+
let namedItemsCache = MakeInfoCache "namedItemsCache" GetIntrinsicNamedItemsUncached hashFlags2
812+
let mostSpecificOverrideMethodInfoCache = MakeInfoCache "mostSpecificOverrideMethodInfoCache" GetIntrinsicMostSpecificOverrideMethodSetsUncached hashFlags0
813+
814+
let entireTypeHierarchyCache = MakeInfoCache "entireTypeHierarchyCache" GetEntireTypeHierarchyUncached HashIdentity.Structural
815+
let primaryTypeHierarchyCache = MakeInfoCache "primaryTypeHierarchyCache" GetPrimaryTypeHierarchyUncached HashIdentity.Structural
816+
let implicitConversionCache = MakeInfoCache "implicitConversionCache" FindImplicitConversionsUncached hashFlags3
817+
let isInterfaceWithStaticAbstractMethodCache = MakeInfoCache "isInterfaceWithStaticAbstractMethodCache" IsInterfaceTypeWithMatchingStaticAbstractMemberUncached hashFlags4
818818

819819
// Runtime feature support
820820

src/Compiler/CodeGen/IlxGen.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,7 @@ and AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbuf
23342334
// A memoization table for generating value types for big constant arrays
23352335
let rawDataValueTypeGenerator =
23362336
MemoizationTable<CompileLocation * int, ILTypeSpec>(
2337+
"rawDataValueTypeGenerator",
23372338
(fun (cloc, size) ->
23382339
let name =
23392340
CompilerGeneratedName("T" + string (newUnique ()) + "_" + string size + "Bytes") // Type names ending ...$T<unique>_37Bytes

src/Compiler/FSharp.Compiler.Service.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
</EmbeddedResource>
115115
<Compile Include="Utilities\Activity.fsi" />
116116
<Compile Include="Utilities\Activity.fs" />
117+
<Compile Include="Utilities\Caches.fsi" />
118+
<Compile Include="Utilities\Caches.fs" />
117119
<Compile Include="Utilities\illib.fsi" />
118120
<Compile Include="Utilities\illib.fs" />
119121
<Compile Include="Utilities\sformat.fsi" />
@@ -148,8 +150,6 @@
148150
<Compile Include="Utilities\lib.fsi" />
149151
<Compile Include="Utilities\lib.fs" />
150152
<Compile Include="Utilities\DependencyGraph.fs" />
151-
<Compile Include="Utilities\Caches.fsi" />
152-
<Compile Include="Utilities\Caches.fs" />
153153
<Compile Include="Utilities\LruCache.fsi" />
154154
<Compile Include="Utilities\LruCache.fs" />
155155
<Compile Include="Utilities\ImmutableArray.fsi" />

src/Compiler/TypedTree/TcGlobals.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ type TcGlobals(
687687

688688
// Build the memoization table for files
689689
let v_memoize_file =
690-
MemoizationTable<int, ILSourceDocument>(compute, keyComparer = HashIdentity.Structural)
690+
MemoizationTable<int, ILSourceDocument>("v_memoize_file", compute, keyComparer = HashIdentity.Structural)
691691

692692
let v_and_info = makeIntrinsicValRef(fslib_MFIntrinsicOperators_nleref, CompileOpName "&" , None , None , [], mk_rel_sig v_bool_ty)
693693
let v_addrof_info = makeIntrinsicValRef(fslib_MFIntrinsicOperators_nleref, CompileOpName "~&" , None , None , [vara], ([[varaTy]], mkByrefTy varaTy))

src/Compiler/Utilities/Caches.fs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,23 @@ type CacheOptions<'Key> =
194194
}
195195

196196
module CacheOptions =
197+
let forceImmediate =
198+
try
199+
Environment.GetEnvironmentVariable("FSharp_CacheEvictionImmediate") <> null
200+
with _ ->
201+
false
202+
203+
let defaultEvictionMode =
204+
if forceImmediate then
205+
EvictionMode.Immediate
206+
else
207+
EvictionMode.MailboxProcessor
197208

198209
let getDefault comparer =
199210
{
200211
CacheOptions.TotalCapacity = 1024
201212
CacheOptions.HeadroomPercentage = 50
202-
CacheOptions.EvictionMode = EvictionMode.MailboxProcessor
213+
CacheOptions.EvictionMode = defaultEvictionMode
203214
CacheOptions.Comparer = comparer
204215
}
205216

src/Compiler/Utilities/illib.fs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ open System.Threading
1111
open System.Threading.Tasks
1212
open System.Runtime.CompilerServices
1313

14+
open FSharp.Compiler.Caches
15+
1416
[<Class>]
1517
type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) =
1618
let syncObj = obj ()
@@ -950,10 +952,11 @@ type UniqueStampGenerator<'T when 'T: equality and 'T: not null>() =
950952
member _.Table = encodeTable.Keys
951953

952954
/// memoize tables (all entries cached, never collected)
953-
type MemoizationTable<'T, 'U when 'T: not null>(compute: 'T -> 'U, keyComparer: IEqualityComparer<'T>, ?canMemoize) =
955+
type MemoizationTable<'T, 'U when 'T: not null>(name, compute: 'T -> 'U, keyComparer: IEqualityComparer<'T>, ?canMemoize) =
954956

955-
let table = new ConcurrentDictionary<'T, Lazy<'U>>(keyComparer)
956-
let computeFunc = Func<_, _>(fun key -> lazy (compute key))
957+
let options = CacheOptions.getDefault keyComparer |> CacheOptions.withNoEviction
958+
let table = new Cache<'T, Lazy<'U>>(options, name)
959+
let computeFunc key = lazy compute key
957960

958961
member t.Apply x =
959962
if

src/Compiler/Utilities/illib.fsi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ type internal UniqueStampGenerator<'T when 'T: equality and 'T: not null> =
386386
type internal MemoizationTable<'T, 'U when 'T: not null> =
387387

388388
new:
389-
compute: ('T -> 'U) * keyComparer: IEqualityComparer<'T> * ?canMemoize: ('T -> bool) -> MemoizationTable<'T, 'U>
389+
name: string * compute: ('T -> 'U) * keyComparer: IEqualityComparer<'T> * ?canMemoize: ('T -> bool) ->
390+
MemoizationTable<'T, 'U>
390391

391392
member Apply: x: 'T -> 'U
392393

src/FSharp.Core/list.fsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ module List =
19781978
///
19791979
/// List.sort input
19801980
/// </code>
1981-
/// Evaluates to <c>[1; 1 3; 4; 6; 8]</c>.
1981+
/// Evaluates to <c>[1; 1; 3; 4; 6; 8]</c>.
19821982
/// </example>
19831983
[<CompiledName("Sort")>]
19841984
val sort: list:'T list -> 'T list when 'T : comparison

0 commit comments

Comments
 (0)