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

[WIP] [CompilerPerf] Seq - the next generation. #2745

Closed
wants to merge 122 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
cb219a8
Added ISeq module
manofstick Mar 13, 2017
3173bdc
Updated remaining SurfaceArea files
manofstick Mar 14, 2017
960d6ff
Copied Seq tests and converted to ISeq
manofstick Mar 15, 2017
d684fa0
Fix ordering in append
manofstick Mar 17, 2017
b46e411
mod test until cache is implemented
manofstick Mar 17, 2017
241e67e
Fix indexing for iteri2
manofstick Mar 17, 2017
1faecf8
fix scan to include initialState
manofstick Mar 17, 2017
3cf2d64
fixed tryItem when index > size of input seq
manofstick Mar 17, 2017
19e67a6
Stubbed in remaining functions
manofstick Mar 18, 2017
a68ac41
Expanded tests to cover previous missing ISeq functions
manofstick Mar 18, 2017
deb7a70
Derived AppendEnumerable from ConcatEnumerable
manofstick Mar 20, 2017
fcc9ee3
Made CachedSeq an ISeq
manofstick Mar 20, 2017
90e369f
Fix error message
manofstick Mar 21, 2017
627d9b4
implemented chunkBySize
manofstick Mar 21, 2017
4486265
Removed checkNonNull as ISeq can't be null
manofstick Mar 21, 2017
7e403ec
type checks for cast
manofstick Mar 21, 2017
f9eab21
Removed type comparisons due to Choice<>
manofstick Mar 22, 2017
55c66cf
Restore somewhat dubious, I think, singleton
manofstick Mar 23, 2017
c235d1b
Removed <summary> tag
manofstick Mar 26, 2017
2919c62
Provided some comments around public interface
manofstick Mar 26, 2017
4925e6c
Capitalized type names (of IIterate implementations)
manofstick Mar 26, 2017
09896e5
Removed wrapping on Append to Empty
manofstick Mar 26, 2017
add013d
Collapsed all the wrap specific modules into one
manofstick Mar 26, 2017
17b0b17
Add special handling for length
manofstick Mar 27, 2017
e67bc21
use UnfoldEnumerable directly in cache
manofstick Mar 27, 2017
c315ee7
Added IReadOnlyCollection to length handling
manofstick Mar 27, 2017
39a8928
On 'take 0' set halted; check HaltedIdx up front
manofstick Mar 28, 2017
2453142
Conditional around IReadOnlyCollection
manofstick Mar 28, 2017
302dfbf
Use InitEnumerable for replicate
manofstick Mar 29, 2017
ea813d4
singleton
manofstick Mar 29, 2017
d137a88
Add ArgumentOutOfRangeException for replicate
manofstick Mar 29, 2017
6927cfd
Added thin wrappers for array, list, ResizeArray
manofstick Mar 31, 2017
12098c8
call correct GetEnumerator on array
manofstick Mar 31, 2017
1c68b01
scan use singleton
manofstick Apr 1, 2017
8c9a933
Created Fold for Concat
manofstick Apr 1, 2017
08cefa8
Removed debugging WriteLines
manofstick Apr 1, 2017
5e7715a
Added executeConcatThin
manofstick Apr 1, 2017
cdacfb0
Cleaning API surface; removed stopTailCall
manofstick Apr 5, 2017
6aa55b4
Cleaning API surface; remove 'State from Fold
manofstick Apr 5, 2017
18b78c8
Moved minimal ISeq into seqcore.fsi
manofstick Apr 5, 2017
8eb6444
Moved internal parts of ISeq into seqcore
manofstick Apr 6, 2017
44417b0
GeneratedSequenceBase inherit EnumerableBase
manofstick Apr 6, 2017
2051bdf
Promoted ISeq to prim_types
manofstick Apr 7, 2017
34fcd2b
Spread ISeq into simpleIntegralRange
manofstick Apr 7, 2017
79c77cb
Composed/Identity in prim_types didn't work (??)
manofstick Apr 8, 2017
143a0c2
internal List.ofISeq
manofstick Apr 8, 2017
b848755
Removed Fold.(execute|executeThin)
manofstick Apr 8, 2017
cd0c264
Optimize nested concat
manofstick Apr 8, 2017
8b51c80
Fix nested concat
manofstick Apr 12, 2017
e27ee1a
Updated SurfaceArea files
manofstick Apr 12, 2017
96fa636
Save tmp copy of Result
manofstick Apr 17, 2017
62eb1e5
Removed Folder.StopFurtherProcessing
manofstick Apr 18, 2017
7cb86e9
Changed Folder style; HaltedIdx read only
manofstick Apr 18, 2017
bb91bd0
Add listening for StopFurtherProcessing
manofstick Apr 18, 2017
e03bd2d
Fixed concat (for good! ... hopefully)
manofstick Apr 19, 2017
75ffc53
Used LanguagePrimitives.IntrinsicOperators.(&&)
manofstick Apr 20, 2017
6de24b2
Remove temp copies of Folder.Result
manofstick Apr 20, 2017
f34f0cf
Minimize stack usage for List Folds
manofstick Apr 20, 2017
be889eb
Updated surface area files
manofstick Apr 20, 2017
86befda
Force capture of common folding closure
manofstick Apr 20, 2017
9c5c130
throw away input on take 0
manofstick Apr 21, 2017
0215aed
Added null check for except's itemsToExclude
manofstick Apr 21, 2017
d4d6586
Added check on negative input for take
manofstick Apr 21, 2017
4dfebe1
Natively support ISeq on list
manofstick Apr 24, 2017
820fc4d
Added list specific overloads
manofstick Apr 26, 2017
40201d3
Optimization for 0/1 element arrays
manofstick Apr 29, 2017
2e09a43
Map/Set use Seq.fold to utilize ISeq implementation
manofstick Apr 29, 2017
70ee40f
ISeq.length optimized for list.length
manofstick May 1, 2017
7032a75
Removed Upcast hack due to #2972
manofstick May 3, 2017
60ee9a3
Consolidated common factory code
manofstick May 5, 2017
844efa2
Converted TransformFactory into interface
manofstick May 5, 2017
2bde79a
Moved list/array before seq in compilation order
manofstick May 6, 2017
6f69c78
Removed duplicate code in Thin implementations
manofstick May 6, 2017
9fd9683
Added EnumerableBase.GetRaw
manofstick May 7, 2017
6d07c5a
made EnumerableBase internal
manofstick May 7, 2017
37eafeb
Fix surface area
manofstick May 7, 2017
0166801
Moved ISeq.length into Basics
manofstick May 8, 2017
0cf6fa0
Added ISeq support in Array.ofSeq
manofstick May 8, 2017
14fb0cb
Added IReadOnlyCollection to Array.ofSeq
manofstick May 8, 2017
8301832
Merged EnumeratorBase and Result
manofstick May 13, 2017
8486a27
Use list for small ISeqs
manofstick May 13, 2017
4d5374b
Thin direct calls to IEnumerable.GetEnumerator
manofstick May 15, 2017
56525a5
Provided an optimized GetEnumerator for scan
manofstick May 18, 2017
cebfaab
Stubbed in remaining functions
manofstick Mar 18, 2017
ee3db4e
Most Seq implementation to ISeq
manofstick May 9, 2017
003e83d
fix tailcalls.NoNeedToTailcall.output.test.bsl
manofstick May 9, 2017
6911fe9
Fixed for new namespace
manofstick May 9, 2017
aaf8ffb
restored error-on-delay functionality groupBy
manofstick May 9, 2017
451b5d5
Modified test; previous equality check was dubious
manofstick May 9, 2017
0d58836
Deleted unused code from seq.fs
manofstick May 9, 2017
5f5d8b2
Removed Upcast hack due to #2972
manofstick May 9, 2017
f9876e0
Seq defer to List/Array where it can
manofstick May 9, 2017
af27a28
Fix misdirected ISeq.length
manofstick May 15, 2017
f8b7dbf
Updated Linq101Aggregates01
manofstick Aug 17, 2017
ce84fa1
Code review changes from dsyme
manofstick Aug 17, 2017
cc54afc
ISeq implementation made internal where possible
manofstick Sep 2, 2017
53d36ec
#if'd out the ISeq testing (internal Seq impl)
manofstick Sep 12, 2017
23fff01
Fixed build order in FSharp.Core.BuildFromSource
manofstick Sep 12, 2017
849bd66
Fix after rebase
manofstick Sep 12, 2017
9757a7a
Updated Linq101Aggregates01.il.bsl
manofstick Sep 12, 2017
8c2105a
Fixed SurfaceArea file
manofstick Sep 12, 2017
9735bd1
Matched signature argument names
manofstick Sep 12, 2017
8551cd2
Matching arguments to signature file names
manofstick Sep 12, 2017
28e8dc9
More matching arguments names to signatures
manofstick Sep 12, 2017
b812c58
Yet more arg names to signatures
manofstick Sep 12, 2017
3722079
And more matching arg names
manofstick Sep 12, 2017
ea5f04e
Final (hopefully) changes for arg names
manofstick Sep 12, 2017
8606e4e
Set.fs matching arg names
manofstick Sep 12, 2017
148f3ca
Added extra comment re: code review
manofstick Sep 12, 2017
ed86b3a
Made FinaliseConstruct public
manofstick Sep 13, 2017
dc70212
type-based optimizations for toList, toArray, rev
manofstick Sep 14, 2017
dc1d61b
Optimization for toArray for ICollection
manofstick Sep 23, 2017
05c37b0
Tighter Fold operation for GeneratedSequenceXXX
manofstick Sep 26, 2017
cb13d05
Lost in checkin...
manofstick Sep 26, 2017
d4a53a0
Remove temp array in rev
manofstick Sep 26, 2017
574aabc
Refactoring cleanup of GeneratedSequenceBase
manofstick Sep 26, 2017
a2d3896
merge master
dsyme May 8, 2018
7e2736d
merge master
dsyme May 8, 2018
2b3c658
integrate and apply renamings
dsyme May 8, 2018
ff55a3c
a little cleanup
dsyme May 8, 2018
8275872
cleanup seqcore.fsi a little
dsyme May 8, 2018
03694e3
fix build
dsyme May 9, 2018
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
20 changes: 19 additions & 1 deletion src/buildfromsource/FSharp.Core/FSharp.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,30 @@
<Compile Include="$(FsCoreDir)\collections.fs">
<Link>Collections/collections.fs</Link>
</Compile>
<Compile Include="$(FsCoreDir)\list.fsi">
<Link>Collections/list.fsi</Link>
</Compile>
<Compile Include=$(FsCoreDir)\"list.fs">
<Link>Collections/list.fs</Link>
</Compile>
<Compile Include="$(FsCoreDir)\array.fsi">
<Link>Collections/array.fsi</Link>
</Compile>
<Compile Include="$(FsCoreDir)\array.fs">
<Link>Collections/array.fs</Link>
</Compile>
<Compile Include="$(FsCoreDir)\seqcore.fsi">
<Link>Collections/seqcore.fsi</Link>
</Compile>
<Compile Include="$(FsCoreDir)\seqcore.fs">
<Link>Collections/seqcore.fs</Link>
</Compile>
<Compile Include="$(FsCoreDir)\iseq.fsi">
<Link>Collections/iseq.fsi</Link>
</Compile>
<Compile Include="$(FsCoreDir)\iseq.fs">
<Link>Collections/iseq.fs</Link>
</Compile>
<Compile Include="$(FsCoreDir)\seq.fsi">
<Link>Collections/seq.fsi</Link>
</Compile>
Expand All @@ -95,7 +113,7 @@
<Link>Collections/array.fs</Link>
</Compile>
<Compile Include="$(FsCoreDir)\array3.fsi">
<Link>Collections/array3.fsi</Link>
<Link>Collections/array.fsi</Link>
</Compile>
<Compile Include="$(FsCoreDir)\array3.fs">
<Link>Collections/array3.fs</Link>
Expand Down
30 changes: 18 additions & 12 deletions src/fsharp/FSharp.Core/FSharp.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,30 @@
<Compile Include="collections.fs">
<Link>Collections/collections.fs</Link>
</Compile>
<Compile Include="list.fsi">
<Link>Collections/list.fsi</Link>
</Compile>
<Compile Include="list.fs">
<Link>Collections/list.fs</Link>
</Compile>
<Compile Include="array.fsi">
<Link>Collections/array.fsi</Link>
</Compile>
<Compile Include="array.fs">
<Link>Collections/array.fs</Link>
</Compile>
<Compile Include="seqcore.fsi">
<Link>Collections/seqcore.fsi</Link>
</Compile>
<Compile Include="seqcore.fs">
<Link>Collections/seqcore.fs</Link>
</Compile>
<Compile Include="iseq.fsi">
<Link>Collections/iseq.fsi</Link>
</Compile>
<Compile Include="iseq.fs">
<Link>Collections/iseq.fs</Link>
</Compile>
<Compile Include="seq.fsi">
<Link>Collections/seq.fsi</Link>
</Compile>
Expand All @@ -110,18 +128,6 @@
<Compile Include="string.fs">
<Link>Collections/string.fs</Link>
</Compile>
<Compile Include="list.fsi">
<Link>Collections/list.fsi</Link>
</Compile>
<Compile Include="list.fs">
<Link>Collections/list.fs</Link>
</Compile>
<Compile Include="array.fsi">
<Link>Collections/array.fsi</Link>
</Compile>
<Compile Include="array.fs">
<Link>Collections/array.fs</Link>
</Compile>
<Compile Include="array3.fsi">
<Link>Collections/array3.fsi</Link>
</Compile>
Expand Down
29 changes: 14 additions & 15 deletions src/fsharp/FSharp.Core/array.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Microsoft.FSharp.Collections
open Microsoft.FSharp.Core
open Microsoft.FSharp.Collections
open Microsoft.FSharp.Core.Operators
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators
#if FX_RESHAPED_REFLECTION
open System.Reflection
Expand Down Expand Up @@ -97,12 +96,22 @@ namespace Microsoft.FSharp.Collections
j <- j + len
res

[<CompiledName("ToSeq")>]
let toSeq array =
checkNonNull "array" array
Microsoft.FSharp.Primitives.Basics.Array.toSeq array

[<CompiledName("OfSeq")>]
let ofSeq source =
checkNonNull "source" source
Microsoft.FSharp.Primitives.Basics.Array.ofSeq source

[<CompiledName("Concat")>]
let concat (arrays: seq<'T[]>) =
checkNonNull "arrays" arrays
match arrays with
| :? ('T[][]) as ts -> ts |> concatArrays // avoid a clone, since we only read the array
| _ -> arrays |> Seq.toArray |> concatArrays
| _ -> arrays |> ofSeq |> concatArrays

[<CompiledName("Replicate")>]
let replicate count initial =
Expand Down Expand Up @@ -182,7 +191,7 @@ namespace Microsoft.FSharp.Collections
let countByValueType (projection:'T->'Key) (array:'T[]) = countByImpl HashIdentity.Structural<'Key> projection id array

// Wrap a StructBox around all keys in case the key type is itself a type using null as a representation
let countByRefType (projection:'T->'Key) (array:'T[]) = countByImpl RuntimeHelpers.StructBox<'Key>.Comparer (fun t -> RuntimeHelpers.StructBox (projection t)) (fun sb -> sb.Value) array
let countByRefType (projection:'T->'Key) (array:'T[]) = countByImpl StructBox<'Key>.Comparer (fun t -> StructBox (projection t)) (fun sb -> sb.Value) array

[<CompiledName("CountBy")>]
let countBy (projection:'T->'Key) (array:'T[]) =
Expand Down Expand Up @@ -432,7 +441,7 @@ namespace Microsoft.FSharp.Collections
let groupByValueType (keyf:'T->'Key) (array:'T[]) = groupByImpl HashIdentity.Structural<'Key> keyf id array

// Wrap a StructBox around all keys in case the key type is itself a type using null as a representation
let groupByRefType (keyf:'T->'Key) (array:'T[]) = groupByImpl RuntimeHelpers.StructBox<'Key>.Comparer (fun t -> RuntimeHelpers.StructBox (keyf t)) (fun sb -> sb.Value) array
let groupByRefType (keyf:'T->'Key) (array:'T[]) = groupByImpl StructBox<'Key>.Comparer (fun t -> StructBox (keyf t)) (fun sb -> sb.Value) array

[<CompiledName("GroupBy")>]
let groupBy (projection:'T->'Key) (array:'T[]) =
Expand Down Expand Up @@ -1051,16 +1060,6 @@ namespace Microsoft.FSharp.Collections
let inline compareDescending a b = compare b a
sortWith compareDescending array

[<CompiledName("ToSeq")>]
let toSeq array =
checkNonNull "array" array
Seq.ofArray array

[<CompiledName("OfSeq")>]
let ofSeq source =
checkNonNull "source" source
Seq.toArray source

[<CompiledName("FindIndex")>]
let findIndex predicate (array : _[]) =
checkNonNull "array" array
Expand Down Expand Up @@ -1256,7 +1255,7 @@ namespace Microsoft.FSharp.Collections
checkNonNull "arrays" arrays
match arrays with
| :? ('T[][]) as ts -> ts |> transposeArrays // avoid a clone, since we only read the array
| _ -> arrays |> Seq.toArray |> transposeArrays
| _ -> arrays |> Microsoft.FSharp.Primitives.Basics.Array.ofSeq |> transposeArrays

[<CompiledName("Truncate")>]
let truncate count (array:'T[]) =
Expand Down
9 changes: 9 additions & 0 deletions src/fsharp/FSharp.Core/collections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,12 @@ namespace Microsoft.FSharp.Collections
{ new IComparer<'T> with
member __.Compare(x,y) = comparer.Invoke(x,y) }

[<Struct; NoComparison; NoEquality>]
type internal StructBox<'T when 'T:equality>(value:'T) =
member x.Value = value
static member Comparer =
let gcomparer = HashIdentity.Structural<'T>
{ new IEqualityComparer<StructBox<'T>> with
member __.GetHashCode(v) = gcomparer.GetHashCode(v.Value)
member __.Equals(v1,v2) = gcomparer.Equals(v1.Value,v2.Value) }

6 changes: 5 additions & 1 deletion src/fsharp/FSharp.Core/collections.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ namespace Microsoft.FSharp.Collections
// inline justification: allows inlining of hash functions
val inline FromFunctions<'T> : hasher:('T -> int) -> equality:('T -> 'T -> bool) -> IEqualityComparer<'T>


[<Struct; NoComparison; NoEquality>]
type internal StructBox<'T when 'T : equality> =
new : value:'T -> StructBox<'T>
member Value : 'T
static member Comparer : IEqualityComparer<StructBox<'T>>
2 changes: 1 addition & 1 deletion src/fsharp/FSharp.Core/fslib-extra-pervasives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ module ExtraTopLevelOperators =
let dictValueType (l:seq<'Key*'T>) = dictImpl HashIdentity.Structural<'Key> id id l

// Wrap a StructBox around all keys in case the key type is itself a type using null as a representation
let dictRefType (l:seq<'Key*'T>) = dictImpl RuntimeHelpers.StructBox<'Key>.Comparer (fun k -> RuntimeHelpers.StructBox k) (fun sb -> sb.Value) l
let dictRefType (l:seq<'Key*'T>) = dictImpl StructBox<'Key>.Comparer (fun k -> StructBox k) (fun sb -> sb.Value) l

[<CompiledName("CreateDictionary")>]
let dict (keyValuePairs:seq<'Key*'T>) : IDictionary<'Key,'T> =
Expand Down
Loading