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

Fix multiple sources (performance) #2499

Merged
merged 9 commits into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
</PackageReference>
</ItemGroup>

<PropertyGroup>
<PaketCliToolFilePath>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).paket.clitools</PaketCliToolFilePath>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ else
fi
mono packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
fi

Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<Reference Include="System" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Security" />
<Reference Include="System.Xml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ let ``#1635 should tell about auth issue``() =
update "i001635-wrong-pw" |> ignore
failwith "error expected"
with
| exn when exn.Message.Contains("Could not find versions for package Argu") -> ()
| exn when exn.Message.Contains("Unable to retrieve package versions for 'Argu'") ->
exn.Message.Contains "Request to 'https://www.myget.org/F/paket-test/api/v3/index.json' failed with: 'Unauthorized'"
|> shouldEqual true
()


#if INTERACTIVE
Expand Down
51 changes: 48 additions & 3 deletions src/Paket.Core.preview3/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.1.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
Expand All @@ -13,7 +13,52 @@
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.1.1" />
<assemblyIdentity name="System.Collections.NonGeneric" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.Collections.Specialized" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.ComponentModel.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.ComponentModel.TypeConverter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.ObjectModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.13.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.Reflection.Emit.Lightweight" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.Runtime.Serialization.Formatters" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.Runtime.Serialization.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.Text.RegularExpressions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="System.Xml.XmlDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.2.0" />
</dependentAssembly>
</assemblyBinding></runtime></configuration>
67 changes: 65 additions & 2 deletions src/Paket.Core/Common/Async.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ module AsyncExtensions =
open System
open System.Threading.Tasks
open System.Threading

open System.Runtime.ExceptionServices

// This uses a trick to get the underlying OperationCanceledException
let inline getCancelledException (completedTask:Task) (waitWithAwaiter) =
let fallback = new TaskCanceledException(completedTask) :> OperationCanceledException
// sadly there is no other public api to retrieve it, but to call .GetAwaiter().GetResult().
try waitWithAwaiter()
// should not happen, but just in case...
fallback
with
| :? OperationCanceledException as o -> o
| other ->
// shouldn't happen, but just in case...
new TaskCanceledException(fallback.Message, other) :> OperationCanceledException
type Microsoft.FSharp.Control.Async with
/// Runs both computations in parallel and returns the result as a tuple.
static member Parallel (a : Async<'a>, b : Async<'b>) : Async<'a * 'b> =
Expand All @@ -25,6 +38,37 @@ module AsyncExtensions =
let! b'' = b'
return (a'',b'')
}
static member AwaitTaskWithoutAggregate (task:Task<'T>) : Async<'T> =
Async.FromContinuations(fun (cont, econt, ccont) ->
let continuation (completedTask : Task<_>) =
if completedTask.IsCanceled then
let cancelledException =
getCancelledException completedTask (fun () -> completedTask.GetAwaiter().GetResult() |> ignore)
econt (cancelledException)
elif completedTask.IsFaulted then
if completedTask.Exception.InnerExceptions.Count = 1 then
econt completedTask.Exception.InnerExceptions.[0]
else
econt completedTask.Exception
else
cont completedTask.Result
task.ContinueWith(Action<Task<'T>>(continuation)) |> ignore)
static member AwaitTaskWithoutAggregate (task:Task) : Async<unit> =
Async.FromContinuations(fun (cont, econt, ccont) ->
let continuation (completedTask : Task) =
if completedTask.IsCanceled then
let cancelledException =
getCancelledException completedTask (fun () -> completedTask.GetAwaiter().GetResult() |> ignore)
econt (cancelledException)
elif completedTask.IsFaulted then
if completedTask.Exception.InnerExceptions.Count = 1 then
econt completedTask.Exception.InnerExceptions.[0]
else
econt completedTask.Exception
else
cont ()
task.ContinueWith(Action<Task>(continuation)) |> ignore)

static member awaitTaskWithToken (fallBack:unit -> 'T) (item: Task<'T>) : Async<'T> =
async {
let! ct = Async.CancellationToken
Expand Down Expand Up @@ -96,7 +140,26 @@ module AsyncExtensions =

static member map f a =
async { return f a }
static member tryFind (f : 'T -> bool) (tasks : Async<'T> seq) = async {
static member tryFindSequential (f : 'T -> bool) (tasks : Async<'T> seq) =
let work = tasks |> Seq.mapi (fun i item -> i,item) |> Seq.toList
let results = Array.init work.Length (fun _ -> TaskCompletionSource<'T>())
let retResults = results |> Array.map (fun tcs -> tcs.Task)
let rec workNext l = async {
match l with
| [] -> return retResults, None
| (i, nextWork) :: rest ->
let! res = nextWork
results.[i].SetResult res
if f res then
for j in i + 1 .. work.Length - 1 do results.[j].SetCanceled()
return retResults, Some i
else
return! workNext rest
}

workNext work

static member tryFindParallel (f : 'T -> bool) (tasks : Async<'T> seq) = async {
match Seq.toArray tasks with
| [||] -> return [||], None
| [|t|] ->
Expand Down
Loading