Objects are slow ?

E

Eric Sosman

AndrewMcDonagh wrote On 08/04/06 18:12,:
Patricia said:
Eric Sosman wrote:
...
Memory saved by using parallel arrays: 18*N*N - 60*N - 16
bytes -- roughly speaking, 18*"huge" bytes. A savings of
18*"huge" bytes isn't a "micro"-optimization.

Note, also, where those bytes are. The 8 bytes per object overhead, and
the padding to bring the object size up to a multiple of 8 bytes are
likely to be interleaved with payload data. They will occupy cache
space and use memory bandwidth, much more expensive than the same
overhead in a separate structure.


This isn't to say that the optimization *should* be done,
of course. But the size of the potential savings is large
enough to influence the design from the outset: [...]

I completely agree...unless the usage of the array is a one time
occurrence and the real bottle neck in the system is a simple loop
somewhere that gets executed continually, which really should be a hash
table lookup.

Measure to find the problem area - dont guess.

Do both: Guess *and* measure. Guess beforehand, to inform
your design. Measure afterwards, to confirm (or refute) the
guesswork and to refine the implementation.

Recommended reading: "Programming Pearls" by Jon Bentley.
 
C

Chris Uppal

Eric said:
Do both: Guess *and* measure. Guess beforehand, to inform
your design. Measure afterwards, to confirm (or refute) the
guesswork and to refine the implementation.

.... and to refine your intuition and understanding of performance issues.

That intuition is a valuable asset, don't let it go stale, or your initial
designs will more frequently require modification after you have measured. At
that time you have necessarily invested a fair bit of time in implementing
something which you may discover has to be changed in ways you didn't
anticipate. A well-trained intuition will help you avoid such situations.

-- chris
 
E

Ed

Chris Uppal skrev:
Eric Sosman wrote:
... and to refine your intuition and understanding of performance issues.

That intuition is a valuable asset, don't let it go stale ...

Completely OT here. Really. Completely.

I recently had a conversation about computer intuition, and concluded
that it's an oxymoron.

Intuition is about forming thoughts on first experiences; in humans,
these are exclusively genetic in nature, for example, someone wrote
somewhere that humans are genetically predisposed to fear only three
things: spiders, loud noises and something else that I can't remember
just now (probably deadlines).

So if you show a spider to a three-year-old, it will probably become
upset (the three-year-old, that is).

If you show a three-year-old the source code for a poorly-performing
java application, it's unlikely that that three-year-old will start
crying (unless, of course, you're using generics, whose angle-brackets
strikes ancient fear into all rational beings).

In order to have any intuition about computers, we must evolve
responses to them, which means that humans and machines must cohabit
for millions of years.

Which we haven't. Yet.

So, being extraordinarily anal, I propose that no one, yet, has any
intuition about java performance; many have extrapolatable experience,
but not intuition.

However, now I've taken a peak at a dictionary and seen the definition:
in·tu·i·tion Audio pronunciation of "intuition" ( P )
Pronunciation Key (nt-shn, -ty-)
n.

1.
1. The act or faculty of knowing or sensing without the use of
rational processes; immediate cognition. See Synonyms at reason.
2. Knowledge gained by the use of this faculty; a perceptive
insight.
2. A sense of something not evident or deducible; an impression.

1.2 seems to suggest that I'm completely wrong.

Oh, well.

I would also like to point out that I've just painted my kitchen a
colour formally known as, "Apple cider 3," but there's a haunting
suspicion among my friends that it's really just plain-ol' cream.

..ed
 
P

Patricia Shanahan

Ed wrote:
....
In order to have any intuition about computers, we must evolve
responses to them, which means that humans and machines must cohabit
for millions of years.

I would agree with this if you had said "instinct" not "intuition".
So, being extraordinarily anal, I propose that no one, yet, has any
intuition about java performance; many have extrapolatable experience,
but not intuition.

However, now I've taken a peak at a dictionary and seen the definition:
in·tu·i·tion Audio pronunciation of "intuition" ( P )
Pronunciation Key (nt-shn, -ty-)
n.

1.
1. The act or faculty of knowing or sensing without the use of
rational processes; immediate cognition. See Synonyms at reason.
2. Knowledge gained by the use of this faculty; a perceptive
insight.
2. A sense of something not evident or deducible; an impression.

1.2 seems to suggest that I'm completely wrong.

That is what I thought intuition meant. Instinct must be inherited, but
intuition can come from anywhere other than fully thought out chains of
logic, including experience. I would agree that, at least in the
technical sense, we don't have instincts about Java performance. We can
have intuition.

Patricia
 
A

ali

thank you very much all of you i got lots of information of your
replays thanks really a lot
 
C

Chris Uppal

Ed said:
In order to have any intuition about computers, we must evolve
responses to them, which means that humans and machines must cohabit
for millions of years.

Like Patricia, I believe you are thinking of instict here. Intuition is
something different.

BTW, I think we have instinctive aversion to/distrust of more than just 3
things -- heights, snakes, and sudden movement come to mind in adition to
splders, deadlines, and hard rock.

I would also like to point out that I've just painted my kitchen a
colour formally known as, "Apple cider 3," but there's a haunting
suspicion among my friends that it's really just plain-ol' cream.

An ex-collegue of mine would have described it as "white, with a hint of
marketing" ;-)

-- chris
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top