What would be a faster alternative to boxing/unboxing?

R

Richard A. Lowe

Hmmm, I'm not convinced that we can make any real conclusions about the
performance of such an application as this one without having the parameters
nailed down a bit better. For example, I wrote another sample that used
multiple arrays like Frank wisely proposed and it was 80% faster than a
similar object[] sample I wrote. I guess with all of us writing our own
samples to test ideas, we're probably not making the same assumptions about
anything (the proportion of reference types to value types, the *size* of
the objects and value types etc.)

Since I'm so deep in this, MBG, could you post your object array sample that
show the baseline performance that you want to improve?
(Or not, if you have ideas your are happy with already)...

Richard
 
M

Mountain Bikn' Guy

Hi Richard,

I certainly would like to reach a conclusion on this, if for no other reason
than for the benefit of anyone reading this thread who may be interested in
general solutions that could improve upon boxing/unboxing when different
types are stored in a (hetereogeneous) array. I am sending you an email with
more detail (I used the corrected version of <[email protected]>).

I do not yet have a good solution. Here is the issue I'm thinking through at
the moment. In order to use Franks very nice suggestion, I have to create
yet another index (I think). We already have about 100MB of indexes on this
object[]. Right now, each data item is indexed 0 to N for an array of
object[N+1]. Let's say we use Frank's approach and there are just 3 types:
ints, doubles and a "myObj" type. There will be 3 "pools" as Frank called
them. However, the original index values will have mapped from 0 to N to
three new index sets: 0 to n1, 0 to n2, 0 to n3.

We already have some added complexity of needing a switch statement to
select the "pool". The addition of another index mapping scheme (on top of
100MB of existing indexes) has me discouraged at the moment. And 100's test
seemed to indicate that this solution may not yield strong performance
gains. So I'm brainstorming at the moment. Your test is encouraging and I
would like to explore this until we reach a definitive conclusion (and
hopefully the holiday interruption won't kill momentum).

Regards,
Mountain



Richard A. Lowe said:
Hmmm, I'm not convinced that we can make any real conclusions about the
performance of such an application as this one without having the parameters
nailed down a bit better. For example, I wrote another sample that used
multiple arrays like Frank wisely proposed and it was 80% faster than a
similar object[] sample I wrote. I guess with all of us writing our own
samples to test ideas, we're probably not making the same assumptions about
anything (the proportion of reference types to value types, the *size* of
the objects and value types etc.)

Since I'm so deep in this, MBG, could you post your object array sample that
show the baseline performance that you want to improve?
(Or not, if you have ideas your are happy with already)...

Richard


--
Veuillez m'excuser, mon Français est très pauvre. Cependant, si vous voyez
mauvais C #, c'est mon défaut!
Mountain Bikn' Guy said:
Hi 100,
See my comments inline.
Regards,
Mountain
method
is

Yes, reading occurs more often than writing. The ratio is about 2:1.
unboxing
if

Yes, I'm interested in taking a look at it. I appreciate you following
up
on
this in so much depth. Please email it to me.

the first part of my address is "Number_235"
and the domain is yahoo dot com
 
1

100

Hi Richard,
You are right.
There are a lot of factors that may lead to different results. I played a
bit more with my test program and I kind of give up of the conclusion I made
in my previous post. It seems like unbox method suffers
worse performance if a structure has reference type field(s) for example
(which may have some reasonable explanation, but I can't come up with any).
Anyway I'm not sure even of the correctness of the results I got.
So now I'm leaning against the method Frank suggests because even if in some
cases unboxing might be a bit faster the difference wouldn't be that big,
however writing operation using boxing, though, is big times slower.

Mountaing, stick with Frank's idea it is better than unboxing.

B\rgds
100

Richard A. Lowe said:
Hmmm, I'm not convinced that we can make any real conclusions about the
performance of such an application as this one without having the parameters
nailed down a bit better. For example, I wrote another sample that used
multiple arrays like Frank wisely proposed and it was 80% faster than a
similar object[] sample I wrote. I guess with all of us writing our own
samples to test ideas, we're probably not making the same assumptions about
anything (the proportion of reference types to value types, the *size* of
the objects and value types etc.)

Since I'm so deep in this, MBG, could you post your object array sample that
show the baseline performance that you want to improve?
(Or not, if you have ideas your are happy with already)...

Richard


--
Veuillez m'excuser, mon Français est très pauvre. Cependant, si vous voyez
mauvais C #, c'est mon défaut!
Mountain Bikn' Guy said:
Hi 100,
See my comments inline.
Regards,
Mountain
method
is

Yes, reading occurs more often than writing. The ratio is about 2:1.
unboxing
if

Yes, I'm interested in taking a look at it. I appreciate you following
up
on
this in so much depth. Please email it to me.

the first part of my address is "Number_235"
and the domain is yahoo dot com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top