Skip to content

Commit

Permalink
added ThreadAdjustment hack according to #19
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldsteinlechner committed Aug 30, 2018
1 parent c899372 commit e259966
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
19 changes: 19 additions & 0 deletions src/Aardvark.UI/MutableApp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ module private Tools =
return (t, Array.append d rest)
}

// https://github.com/aardvark-platform/aardvark.media/issues/19
module ThreadPoolAdjustment =

let adjust () =
let mutable maxThreads,maxIOThreads = 0,0
System.Threading.ThreadPool.GetMaxThreads(&maxThreads,&maxIOThreads)
let mutable minThreads, minIOThreads = 0,0
System.Threading.ThreadPool.GetMinThreads(&minThreads,&minIOThreads)
if minThreads < 12 || minIOThreads < 12 then
Log.warn "[aardvark.media] currently ThreadPool.MinThreads is (%d,%d)" minThreads minIOThreads
let minThreads = max 12 minThreads
let minIOThreads = max 12 minIOThreads
Log.warn "[aardvark.media] unfortunately, currently we need to adjust this to at least (12,12) due to an open issue https://github.com/aardvark-platform/aardvark.media/issues/19"
if not <| System.Threading.ThreadPool.SetMinThreads(minThreads, minIOThreads) then Log.warn "could not set min threads"
if maxThreads < 12 || maxIOThreads < 12 then
Log.warn "[aardvark.media] detected less than 12 threadpool threads: (%d,%d). Be aware that this will result in severe stutters... Consider switching back to the default (65537,1000)." maxThreads maxIOThreads


module MutableApp =
open System.Reactive.Subjects
Expand Down Expand Up @@ -66,6 +83,8 @@ module MutableApp =

let toWebPart' (runtime : IRuntime) (useGpuCompression : bool) (app : MutableApp<'model, 'msg>) =

ThreadPoolAdjustment.adjust ()

let sceneStore =
ConcurrentDictionary<string, Scene * Option<ClientInfo -> seq<'msg>> * (ClientInfo -> ClientState)>()

Expand Down
2 changes: 1 addition & 1 deletion src/Examples (dotnetcore)/02 - RenderControl/.domaincache
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ DC3E848FBE35E5B1F7363DB1EA25EDEA
AssemblyInfo.fs|false|5248332579857429748|ryfjvEYr6fOpO1+GorCmJg==
Model.fs|true|5248389828314444595|hvz6Ko2w8sKsIpZz8HtCbQ==
App.fs|false|5248390407290639153|np4R7x9Tznf0xZMEsUI5XQ==
Program.fs|false|5248361938208833524|9pKnXvcrS7ByQoaml0qRRA==
Program.fs|false|5248398161769845221|hZim/yekwgUpCIYXnHdeBg==
2 changes: 1 addition & 1 deletion src/Examples (dotnetcore)/02 - RenderControl/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let main argv =

// media apps require a runtime, which serves as renderer for your render controls.
// you can use OpenGL or VulkanApplication.
let useVulkan = true
let useVulkan = false

let runtime, disposable =
if useVulkan then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ DC3E848FBE35E5B1F7363DB1EA25EDEA
AssemblyInfo.fs|false|5248332579857429748|ryfjvEYr6fOpO1+GorCmJg==
Model.fs|true|5248395812523217695|eZhCC/RCxr06NJKCfc8kcw==
App.fs|false|5248397498814039718|0Kffd+gUvjlfj180i/S/VQ==
Program.fs|false|5248397506333731365|TEedZcZr9NnRoQ5/T4KabQ==
Program.fs|false|5248398186908310144|rHPpNK/zoEJer4IPX3UsUA==
14 changes: 4 additions & 10 deletions src/Examples (dotnetcore)/18 - CameraControllerSettings/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,15 @@ open RenderControl

[<EntryPoint; STAThread>]
let main argv =
let mutable w = 0
let mutable c = 0
System.Threading.ThreadPool.GetMaxThreads(&w,&c)
printfn "%A %A " w c
System.Threading.ThreadPool.GetMinThreads(&w,&c)
printfn "%A %A " w c
System.Threading.ThreadPool.SetMinThreads(1,1) |> printfn "oida: %A"
System.Threading.ThreadPool.SetMaxThreads(12,12) |> printfn "oida: %A"
Ag.initialize()
printfn "%A" System.Environment.CurrentDirectory

Aardvark.Init()
Ag.initialize()
Aardium.init()

// media apps require a runtime, which serves as renderer for your render controls.
// you can use OpenGL or VulkanApplication.
let useVulkan = true
let useVulkan = false

let runtime, disposable =
if useVulkan then
Expand Down

0 comments on commit e259966

Please sign in to comment.