静态HashTables和类对CPU有什么影响? [英] What Impact Do Static HashTables and Classes have on the CPU?

查看:56
本文介绍了静态HashTables和类对CPU有什么影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我用C#编写了一个高性能的Web应用程序,它完全依赖于

静态哈希表(使用同步)和类。在现实世界的压力下,这个

应用程序每秒处理每个CPU 5个请求。


我已经从单核/单进程中解决了,对于双核/单一进程到双核/双进程,并且因为我怀疑每秒每秒请求的数量
CPU不会增加它仍然是每个CPU 5个。


我读取IIS线程表明,每秒10-12个请求可以从非静态类中获得
基于应用程序如果这个假设是正确的,那么你对我如何能够每秒增加

请求的数量有什么建议吗?


TIA

Hello,

I''ve written a high performance web app with C# and it completely relies on
static hash tables (using sync) and classes. Under real world stress this
app is handling 5 get requests per CPU per second.

I''ve gone from a single-core/single-proc, to a dual-core/single-proc to a
dual-core/dual-proc and as I suspected the number of requests per second per
CPU does not increase it remains at 5 per CPU.

My reading of IIS threading suggests that 10-12 per requests per second can
be expected from a non-static class based app. If this assumption is
correct, do you have any suggestions on how I might be able to increase the
number of requests per second?

TIA

推荐答案




我认为你的问题可能是因为你需要同步对

静态元素的访问,在这个场景中只有一个线程可以访问给定的

资源。当然这是一个很大的限制。添加更多的处理器解决了没有任何问题,甚至可能使事情变得更糟,因为更多的线程可能会有效。

等待资源。


为什么你需要使用静态资源管理器?


" Mark S." < ma *** @ yahoo.com写了留言

新闻:uv ************** @ TK2MSFTNGP03.phx.gbl ...
Hi,

I think that your problem may be that you need to sync the access to the
static elements, in this escenario only one thread can access a given
resource. of course this is a BIG constrains. Adding more processors solve
nothing and may even make the things worse as more thread can be potentally
be waiting for the resource.

why you need to use static resourcers?

"Mark S." <ma***@yahoo.comwrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl...

你好,


我用C#写了一个高性能的网络应用程序,它完全依赖

在静态哈希表(使用同步)和类。在现实世界的压力下

这个应用程序每秒处理每个CPU 5个请求。


我已经从单核/单进程,双核/单程序到双核/双处理器,因为我怀疑每秒的请求数量每个CPU
不会增加它仍然是每CPU 5个。


我读取IIS线程表明,每个请求每秒10-12个

可以从非静态类中获得基于应用程序如果这个假设是正确的,那么你对我如何能够每秒增加请求数量有什么建议吗?


TIA
Hello,

I''ve written a high performance web app with C# and it completely relies
on static hash tables (using sync) and classes. Under real world stress
this app is handling 5 get requests per CPU per second.

I''ve gone from a single-core/single-proc, to a dual-core/single-proc to a
dual-core/dual-proc and as I suspected the number of requests per second
per CPU does not increase it remains at 5 per CPU.

My reading of IIS threading suggests that 10-12 per requests per second
can be expected from a non-static class based app. If this assumption is
correct, do you have any suggestions on how I might be able to increase
the number of requests per second?

TIA



" Mark S." < ma *** @ yahoo.com写了留言

新闻:uv ************** @ TK2MSFTNGP03.phx.gbl ...
"Mark S." <ma***@yahoo.comwrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl...

我用C#编写了一个高性能的Web应用程序,它在静态哈希表上完全依赖

(使用同步)[...]任何关于我怎么可能的建议

能否增加每秒的请求数量?
I''ve written a high performance web app with C# and it completely relies
on static hash tables (using sync) [...] any suggestions on how I might be
able to increase the number of requests per second?



如果你使用的是System.Collections.Hashtable对象并且大部分都在阅读它们,那么你可以利用Hashtable的特性对于多个读者或只有一个作者来说,它是线程安全的
。而不是使用同步,

使用ReaderWrtiterLock,这将为您提供更好的并发性。

If you are using System.Collections.Hashtable objects and mostly reading
them, you can make use of the characteristic of the Hashtable of being
thread-safe for multiple readers or only one writer. Instead of using sync,
use a ReaderWrtiterLock, which will give you better concurrency.


嗨Mark,


因为你正在讨论静态哈希表,我想你正在使用

所有请求共享的共享数据。

当然,你有同步对这些数据的访问,但你应该尝试

来最小化每个请求被锁定的时间。对于同一个锁定对象锁定的所有代码将被锁定,就好像它们在一个线程上一样。因此,在你的代码的这一部分,双核/双进程将有绝对没有优势。


HTH

Christof


" Mark S." < ma *** @ yahoo.comschrieb im Newsbeitrag

news:uv ************** @ TK2MSFTNGP03.phx.gbl ...
Hi Mark,

since you are tolking about static hashtables, I suppose you are using
shared data that is shared by all requests.
Surely, you have to synchronize the access to this data, but you should try
to minimize the time, during wich each request is locked. All codeparts wich
are locked against the same lock-object will be executed, as if they were on
one thread. So fore this part of your code the dual-core/dual-proc will have
absolutly no advantage.

HTH
Christof

"Mark S." <ma***@yahoo.comschrieb im Newsbeitrag
news:uv**************@TK2MSFTNGP03.phx.gbl...

你好,


我用C#写了一个高性能的网络应用程序,它完全依赖

在静态哈希表(使用同步)和类。在现实世界的压力下

这个应用程序每秒处理每个CPU 5个请求。


我已经从单核/单进程,双核/单程序到双核/双处理器,因为我怀疑每秒的请求数量每个CPU
不会增加它仍然是每CPU 5个。


我读取IIS线程表明,每个请求每秒10-12个

可以从非静态类中获得基于应用程序如果这个假设是正确的,那么你对我如何能够每秒增加请求数量有什么建议吗?


TIA
Hello,

I''ve written a high performance web app with C# and it completely relies
on static hash tables (using sync) and classes. Under real world stress
this app is handling 5 get requests per CPU per second.

I''ve gone from a single-core/single-proc, to a dual-core/single-proc to a
dual-core/dual-proc and as I suspected the number of requests per second
per CPU does not increase it remains at 5 per CPU.

My reading of IIS threading suggests that 10-12 per requests per second
can be expected from a non-static class based app. If this assumption is
correct, do you have any suggestions on how I might be able to increase
the number of requests per second?

TIA



这篇关于静态HashTables和类对CPU有什么影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆