Re: Idea for ECMA/C# Standard - compile time hash for performance
- From: WXS <WXS@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 7 Apr 2005 06:33:11 -0700
Just to give an idea of scale of the problem imagine I have an object that
contains 100 fields that I do hash lookups on to get and set the values. Now
imagine I need to populate, read and process 3000-6000 of these per second.
So for populating it is 300,000 operations per second (hashing) and an
equivalent number of reads. So we'll say 600,000 operations. On a 1.8GHZ box
600,000 calls to GetHashCode is about 1/4 of a second in and of itself not
counting the lookup then and processing. So when all is said and done the
hashing in this case in and of itself accounts for 25-35% of processor time
or more depending on how many times those members need to be accessed. If
this could be done with a straight array lookup using the minimal memory
possible we could probably cut this down to 1% processor time or so. A huge
savings since we do much more than just populate and read the data, we do
calculations and comparisons so having that extra 24-34% of CPU would help us
quite a bit.
"WXS" wrote:
> The example I gave was just that an example and the reality is those enums
> can be almost anything in an integer range so sparse array really isn't an
> answer, especially allocating the whole array. And if done as a lookup tree
> hash or map requires that lookup time, which in the financial industry I work
> in with thousands of market data messages (with lots of data in each), or
> more comming in, it is becoming less and less viable by the day (although
> increasing processor speeds help mitigate a bit - when a customer is willing
> to upgrade).
>
> The key is I don't want to burn a huge amount of memory and I want to incur
> the minimal amount of lookup time possible. In this case the only way to
> handle this is with a language change I believe. Because having the compiler
> do the mapping at compile time saves me from burning huge memory and
> virtually any lookup time at run time.
>
>
> Thanks,
> Dave
>
>
> "Bruce Wood" wrote:
>
> > If your original enum type does not have values up into four digits or
> > more, why not just use an array directly, even if it's a sparse array?
> > What difference does it make, on a machine with 500 MB of memory, if
> > you waste 80 entries in an array of 100?
> >
> > It seems hardly worth a change to the language (or a hash table for
> > that matter) to save such a small amount of memory. (The hash table
> > would probably consume as much overhead as that anyway.)
> >
> >
.
- Follow-Ups:
- Re: Idea for ECMA/C# Standard - compile time hash for performance
- From: Bruce Wood
- Re: Idea for ECMA/C# Standard - compile time hash for performance
- From: Bruce Wood
- Re: Idea for ECMA/C# Standard - compile time hash for performance
- References:
- Prev by Date: Generating SQL Script for Job - (Spliting the script like the following Creation of Job, JobSteps and JobSchedules)
- Next by Date: Windows Mobile, Pocket PC, PDA, etc. question
- Previous by thread: Re: Idea for ECMA/C# Standard - compile time hash for performance
- Next by thread: Re: Idea for ECMA/C# Standard - compile time hash for performance
- Index(es):
Relevant Pages
|