Hello!
I have a list of singleton classes (model managers) that store objects
internally using hashtables. Each of these classes use a single hashtable to
store e.g. users, pages, elements and so on (I have complete control of the
objects stored). I am currently using a set of abstract cache classes that
my model managers subclass.
The hashtable in a model managers could, potentially, store more than 25.000
objects (let's imagine 50.000 for sake of the discussion). The hashtables
are accessed very frequently (they store objects that are cloned and handed
to the client context services).
I am tinkering about creating a central cache, but have yet to figure out
when (or if) a hashtable breaks down, or when it becomes a bad decision to
go this way.
Obviously, using a central cache does implicit ask for synchronization
(which I also use in abstract cache classes), but sharing the cache could
sacrifice additional speed.
For testing purposes, I tried populating a hashtable with 650.000 instances
(ate up around 75MB of RAM), and it worked all right. I haven't done any
tests on how the size of the hashtable actually affects lookup times (I
belive to have read that the lookup time is almost constant, regardless of
the size).
The caching mechanism in ASP.NET is built around a hashtable. I haven't
found any recommendations for number of items stored here, so I be on the
right track.
Any comments and ideas are very welcome!
--
venlig hilsen / with regards
anders borum
-- 4 8338
The only performance issues I've ever found with the Hashtable were in
pre-V1, when the Terrarium was using over 1 million records. They have
a precomputed primes list up to that point, and when we hit the threshold
and had to compute a new prime, we ran into some problems. So basically
growing the Hashtable at very large record counts could pose a problem
for you.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Anders Borum" <a@b.dk> wrote in message
news:eT**************@TK2MSFTNGP10.phx.gbl... Hello!
I have a list of singleton classes (model managers) that store objects internally using hashtables. Each of these classes use a single hashtable to store e.g. users, pages, elements and so on (I have complete control of the objects stored). I am currently using a set of abstract cache classes that my model managers subclass.
The hashtable in a model managers could, potentially, store more than 25.000 objects (let's imagine 50.000 for sake of the discussion). The hashtables are accessed very frequently (they store objects that are cloned and handed to the client context services).
I am tinkering about creating a central cache, but have yet to figure out when (or if) a hashtable breaks down, or when it becomes a bad decision to go this way.
Obviously, using a central cache does implicit ask for synchronization (which I also use in abstract cache classes), but sharing the cache could sacrifice additional speed.
For testing purposes, I tried populating a hashtable with 650.000 instances (ate up around 75MB of RAM), and it worked all right. I haven't done any tests on how the size of the hashtable actually affects lookup times (I belive to have read that the lookup time is almost constant, regardless of the size).
The caching mechanism in ASP.NET is built around a hashtable. I haven't found any recommendations for number of items stored here, so I be on the right track.
Any comments and ideas are very welcome!
-- venlig hilsen / with regards anders borum --
Hello
The performance will depend on the data types you use as keys for the hash
table. If you use many types as keys for a single hashtable, it is more
likely that GetHashCode of one type can be similar to that of another type,
although they are not equal. Therefore you may have a lot of collisions in
the hash table that cal affect performance.
Sorry for my bad english
Best regards,
Sherif
"Anders Borum" <a@b.dk> wrote in message
news:eT**************@TK2MSFTNGP10.phx.gbl... Hello!
I have a list of singleton classes (model managers) that store objects internally using hashtables. Each of these classes use a single hashtable
to store e.g. users, pages, elements and so on (I have complete control of
the objects stored). I am currently using a set of abstract cache classes that my model managers subclass.
The hashtable in a model managers could, potentially, store more than
25.000 objects (let's imagine 50.000 for sake of the discussion). The hashtables are accessed very frequently (they store objects that are cloned and
handed to the client context services).
I am tinkering about creating a central cache, but have yet to figure out when (or if) a hashtable breaks down, or when it becomes a bad decision to go this way.
Obviously, using a central cache does implicit ask for synchronization (which I also use in abstract cache classes), but sharing the cache could sacrifice additional speed.
For testing purposes, I tried populating a hashtable with 650.000
instances (ate up around 75MB of RAM), and it worked all right. I haven't done any tests on how the size of the hashtable actually affects lookup times (I belive to have read that the lookup time is almost constant, regardless of the size).
The caching mechanism in ASP.NET is built around a hashtable. I haven't found any recommendations for number of items stored here, so I be on the right track.
Any comments and ideas are very welcome!
-- venlig hilsen / with regards anders borum --
Hello! The only performance issues I've ever found with the Hashtable were in pre-V1, when the Terrarium was using over 1 million records. They have a precomputed primes list up to that point, and when we hit the threshold and had to compute a new prime, we ran into some problems. So basically growing the Hashtable at very large record counts could pose a problem for you.
Thanks for getting back to me on this subject. As always it's interesting
information you guys pass back.
I don't think I'll ever reach 1 million entried in a single hashtable, and
the memory requirements for such large amounts of objects are definately
quite high (I have been looking at expiring items from the cache, similar to
the ASP.NET cache model - and it works quite well, but I need to design the
architecture around worst case scenarios).
Any idea why the ASP.NET cache was not made a seperate part of the
framework? It seems like many people have had to create their own caches,
quite similar to the one in ASP.NET.
Microsoft have provided the cache application block, but I was more looking
for a .NET framework core class feature. Perhaps this will be provided with
the next .NET release.
I will give the central cache some more thoughts, but the fact alone that
there could be concurrent access to the central hashtable (when two or more
modelmanagers try to access the share cache at the same time), there will be
a quite high performance penaulty, compared to providing each model manager
with its own cache context (i.e hashtable).
Caching is king!
Btw. sorry for replying so late - I have been playing a golf tournament :-)
--
venlig hilsen / with regards
anders borum
--
Hello! The performance will depend on the data types you use as keys for the hash table. If you use many types as keys for a single hashtable, it is more likely that GetHashCode of one type can be similar to that of another
type, although they are not equal. Therefore you may have a lot of collisions in the hash table that cal affect performance.
I will be storing objects of the same superclass called "CmsObject", and
index the objects in the hashtable using an integer currently, but will soon
switch to guids as that allows me to create the identifiers directly within
my model managers.
I am, btw., not overriding the virtual GetHashCode() method in my
superclass.
Thanks in advance.
--
venlig hilsen / with regards
anders borum
-- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Anders Borum |
last post by:
Hello!
Now that generics are introduces with the next version of C#, I was
wondering what kind of performance gains we're going to see, when switching
from e.g. the general hashtable to a...
|
by: Matt C. |
last post by:
I bet I know the answer already.
I have a hashtable (hMaster) that holds several hashtables ("hTables") each
of which holds other hashtables ("hColumns"). Presently, I am getting at
the info I...
|
by: Saradhi |
last post by:
Hi All,
Here I am facing a performance problem with the TreeView Node renaming.
I am displaying a hierarchy Data in a treeview in my Windows C# Application.
My tree view represents an...
|
by: JackRazz |
last post by:
Is it possible to create a hashtable that doesn't store the key? I have a very large
hashtable and I just want it to store the HashCode and the Value (two Int16s).
Thanks - JackRazz
|
by: Rachel Suddeth |
last post by:
I have an application where some forms have many (say 100) UserControls on
them (each of which contain a label, an image, and a data entry control),
and each UserControl has a ToolTip provider...
|
by: Ken Foster |
last post by:
I have a hashtable keyed by some name, holding an instance of an object. Most
of the time I use the hashtable in the traditional sense, given a name, I
lookup the object, then I run a method on...
|
by: Tom Jastrzebski |
last post by:
Hello,
I was just testing VB.Net on Framework.Net 2.0 performance when I run into
the this problem.
This trivial code attached below executed hundreds, if not thousand times
faster in VB 6.0...
|
by: PAzevedo |
last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from
multiple threads, now the Hashtable object is thread safe for reading,
but not for writing, so I lock the object every time I...
|
by: John Smith |
last post by:
Hello people,
I have a performance query regarding LINQ that I would like some opinions.
Currently we have a business logic framework that is used in n-tier
applications. We read data from a...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |