简体   繁体   English

F#/ MailBoxProcessor在近100%的负载下对PostAndReply无响应

[英]F# / MailBoxProcessor is unresponsive to PostAndReply under nearly 100% load

I have a MailBoxProcessor , which does the following things: 我有一个MailBoxProcessor ,它执行以下操作:

  1. Main loop ( type AsyncRunner : https://github.com/kkkmail/ClmFSharp/blob/master/Clm/ContGen/AsyncRun.fs#L257 – the line number may change as I keep updating the code). 主循环( type AsyncRunnerhttps : //github.com/kkkmail/RTIFSharp/blob/master/ContGen/AsyncRun.fs#L257 –行号可能会随着我不断更新代码而改变)。 It generates some "models", compiles each of them into a model specific folder, spawns them as external processes, and then each model uses WCF to "inform" AsyncRunner about its progress by calling updateProgress . 它生成一些“模型”,将它们每个都编译到模型特定的文件夹中,将它们作为外部进程生成,然后每个模型使用WCF通过调用updateProgress来“通知” AsyncRunner的进度。 A model may take several days to run. 一个模型可能需要几天的时间才能运行。 Once any of the models is completed, the runner generates / spawns more. 一旦完成任何模型,跑步者就会生成/产生更多的东西。 It is designed to run at 100% processor load (but with priority: ProcessPriorityClass.BelowNormal ), though I can specify a smaller number of logical cores to use (some number between 1 and Environment.ProcessorCount ). 尽管我可以指定使用较少数量的逻辑核心(介于1和Environment.ProcessorCount之间的某个数字),但它旨在在100%的处理器负载下运行(但优先级为: ProcessPriorityClass.BelowNormal )。 Currently I "async"-ed almost everything that goes inside MailBoxProcessor by using … |> Async.Start to ensure that I "never ever" block the main loop. 当前,我通过使用… |> Async.Start来“异步” MailBoxProcessor内部几乎所有内容,以确保“永不”阻塞主循环。

  2. I can "ask" the runner (using WCF) about its state by calling member this.getState () = messageLoop.PostAndReply GetState . 我可以通过调用member this.getState () = messageLoop.PostAndReply GetState来“询问”跑步者的状态(使用WCF)。

  3. OR I can send some commands to it (again using WCF), eg member this.start() , member this.stop() , … 或者我可以向它发送一些命令(再次使用WCF),例如, member this.start()member this.stop() ,...

Here is where it gets interesting. 这是有趣的地方。 Everything works! 一切正常! However, if I run a "monitor", which would ask for a state by effectively calling PostAndReply (exposed as this.getState () ) in an infinite loop, the after a while it sort of hangs up. 但是,如果我运行一个“监视器”,它将通过无限循环有效地调用PostAndReply (公开为PostAndReply this.getState () )来请求一个状态, PostAndReply后它就会挂起。 I mean that it does eventually return, but with some unpredictably large delays (like a few minutes). 我的意思是说它确实最终会返回,但是会有一些无法预料的大延迟(例如几分钟)。 At that same time, I can issue commands and they do return fast while getState still has not returned. 同时,我可以发出命令,并且它们会快速返回,而getState仍未返回。

Is it possible to make it responsive at nearly 100% load? 是否可以使它在接近100%的负载下做出响应? Thanks a lot! 非常感谢!

I would suggest not asyncing anything(other than your spawning of processes) in your main program, since your code creates additional processes. 我建议不要在主程序中异步处理任何东西(除了生成进程外),因为代码会创建其他进程。 Your main loop is waiting on the loop return to continue before processing the GetState() method. 您的主循环正在等待循环返回以继续处理GetState()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM