简体   繁体   English

将所有可能的资源分配给程序

[英]Give all possible resources to a program

I created a program in C# to work with 2.5 million records in Oracle Express (local instance), parse/split those records and create an additional 5 million records. 我用C#创建了一个程序,以处理Oracle Express(本地实例)中的250万条记录,解析/拆分这些记录,并另外创建500万条记录。

I added some code to print times on the screen and it seems fairly fast. 我添加了一些代码来在屏幕上打印时间,它看起来相当快。 It is doing all the processing for 1K records every 9 seconds. 它每9秒执行1K记录的所有处理。 Which means it takes more than 6 hours to finish. 这意味着需要6个小时以上才能完成。

Now, with Task Manager I can see the program is using 6% of CPU (max) and around 50MB of memory. 现在,通过任务管理器,我可以看到程序正在使用6%的CPU(最大)和大约50MB的内存。 I understand the OS, and Oracle itself need resources to operate but..... is there a way to tell this little program "hey, it's ok, go ahead and use at least 50% of CPU, there are 4GB of RAM so knock yourself out"? 我了解操作系统,Oracle本身需要资源才能运行,但是.....有一种方法可以告诉这个小程序“嘿,没关系,继续使用至少50%的CPU,有4GB的RAM,所以把自己打昏”?

Note: One of the reasons I'm using a local instance with Oracle Express is to reduce the network bottleneck. 注意:我在Oracle Express中使用本地实例的原因之一是为了减少网络瓶颈。 Also I might not run this process quite often but I was intrigued to see if this was at all possible. 另外,我可能不会经常运行此过程,但是我很想知道这是否完全可能。

Please forgive my noobness, 请原谅我的愚昧

Thanks! 谢谢!

The operating system will give your program all the resources it needs, the reason your process is not consuming all the CPU is probably because it's waiting for the IO sub system more than the processor. 操作系统将为您的程序提供所需的所有资源,原因是您的进程没有消耗所有CPU,这可能是因为它比处理器更需要IO子系统。

If you want to see if you can consume more CPU cycles try writing a program that runs a short infinite loop as fast as possible and you will see the difference in CPU usage. 如果要查看是否可以消耗更多的CPU周期,请尝试编写一个运行尽可能短的无限循环的程序,您会发现CPU使用率的差异。

A number of thoughts, not really answers I guess, but. 我有很多想法,但并不是真正的答案。

  1. You could up the priority of the applications thread, however, its possible that the code maybe less efficient than you think, so.. 您可以提高应用程序线程的优先级,但是,代码的效率可能比您想象的要低,所以。

Have you run a profiler on it? 您在上面运行了探查器吗?

  1. If its currently a single threaded app, you could look to see if you could parse it in batches and therefore run them in parallel. 如果它当前是一个单线程应用程序,则可以查看是否可以批量解析它,然后并行运行它们。

  2. Without knowing a lot of detail of the splitting of records, is it possible to off hand that more to oracle to do? 在不了解记录拆分的很多细节的情况下,是否有可能将更多的工作交给Oracle执行? eg, would matter less about network etc or local or otherwise. 例如,对网络等或本地或其他方面的影响较小。

  3. If you're apps drawing/updating a screen or UI then it will almost certainly slow the progress of the work down. 如果您正在绘制/更新屏幕或UI的应用程序,那么几乎可以肯定会减慢工作进度。 An example. 一个例子。 I ran an app which sorted about 10k emails into around 250k lines into a database, if I added an item to a listbox each line the time went from short to rediculous eg, crash out got bored. 我运行了一个应用程序,该程序将大约1万封电子邮件分类成大约25万行到数据库中,如果我在每行中将一个项目添加到列表框中,则时间从短到冗长,例如,崩溃很无聊。 So, again, offloading to a thread to do the work with as few UI updates to do as possible can help. 因此,再次强调,卸载线程以完成尽可能少的UI更新可以完成工作。

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

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