473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Strange performance effects

Hi!

I am working on a project in which i implement a mathematical
optimization algorithm. One of the requirements on the code is very
good performance. So i started to optimize a bit. Now i do have a very
strange effect which i do not understand. Maybe somebody knows about:

I have the following class

template<class T> class SimplexL2Penalty : public Function<T,T>
{
public:

ASIString GetTypeInfo() const;
SimplexL2Penalty(const Simplex<T>& simplex);
SimplexL2Penalty(const Simplex<T>& simplex,const T& weight);
SimplexL2Penalty(const Simplex<T>& simplex,const Vector<T>&
w);
SimplexL2Penalty(const SimplexL2Penalty& toBeCopied);
virtual ~SimplexL2Penalty();
T Evaluate(const Vector<T>& point) const;
void operator*= (const T& factor);
ASIString ToXML() const;
Function<T,T>* ConstructCopy() const;
ASI_FLOGIC LargerOrEqual(const T& value) const;
const VectorSet<T>* GetZeroSet();

protected:

Vector<T> ComputePerturbation(const Vector<T>& point) const;
Simplex<T> m_Simplex;
T* m_WeightVector;
T m_Factor;

//Vector<T> *m_PerturbationVector1;
};

This class is used in an iterative algorithm. Performance is about 500
iterations per second.
When i add the pointer m_PerturbationVector1 to the class (without
using it at all) performance drops to 250 iterations per second.

What is going on? What can i do to overcome this effect.

Thanks a lot,
Roland

PS: I am using Microsoft Visual C++ 6.0.
Jul 22 '05 #1
3 1416
"Roland" <ro************@chello.at> wrote...
I am working on a project in which i implement a mathematical
optimization algorithm. One of the requirements on the code is very
good performance. So i started to optimize a bit. Now i do have a very
strange effect which i do not understand. Maybe somebody knows about:

I have the following class
Actually, it's a template.

template<class T> class SimplexL2Penalty : public Function<T,T>
{
public:

ASIString GetTypeInfo() const;
SimplexL2Penalty(const Simplex<T>& simplex);
SimplexL2Penalty(const Simplex<T>& simplex,const T& weight);
SimplexL2Penalty(const Simplex<T>& simplex,const Vector<T>&
w);
SimplexL2Penalty(const SimplexL2Penalty& toBeCopied);
virtual ~SimplexL2Penalty();
T Evaluate(const Vector<T>& point) const;
void operator*= (const T& factor);
ASIString ToXML() const;
Function<T,T>* ConstructCopy() const;
ASI_FLOGIC LargerOrEqual(const T& value) const;
const VectorSet<T>* GetZeroSet();

protected:

Vector<T> ComputePerturbation(const Vector<T>& point) const;
Simplex<T> m_Simplex;
T* m_WeightVector;
T m_Factor;

//Vector<T> *m_PerturbationVector1;
};

This class is used in an iterative algorithm.
How? Don't you think it might matter?
Performance is about 500
iterations per second.
When i add the pointer m_PerturbationVector1 to the class (without
using it at all) performance drops to 250 iterations per second.

What is going on?
Who the hell can tell? Without seeing how the template is used, your
guess is just as good as ours. It could be that the size causes some
kind of processor cache to be blown away more often, it could be that
allocating a bunch of them now requires more OS involvement... There
is no way to tell for certain.
What can i do to overcome this effect.


Don't declare that member, since you're not using it.

Why don't you take a profiler and run your process through it with and
without the member. See if you can spot the difference. Then analyse.
Then come back and ask for assistance if you still need it.

Victor
Jul 22 '05 #2
"Victor Bazarov" <v.********@comAcast.net> wrote in message news:<Lx1Pb.88602$5V2.150409@attbi_s53>...
"Roland" <ro************@chello.at> wrote...
I am working on a project in which i implement a mathematical
optimization algorithm. One of the requirements on the code is very
good performance. So i started to optimize a bit. Now i do have a very
strange effect which i do not understand. Maybe somebody knows about:

I have the following class


Actually, it's a template.

template<class T> class SimplexL2Penalty : public Function<T,T>
{
public:

ASIString GetTypeInfo() const;
SimplexL2Penalty(const Simplex<T>& simplex);
SimplexL2Penalty(const Simplex<T>& simplex,const T& weight);
SimplexL2Penalty(const Simplex<T>& simplex,const Vector<T>&
w);
SimplexL2Penalty(const SimplexL2Penalty& toBeCopied);
virtual ~SimplexL2Penalty();
T Evaluate(const Vector<T>& point) const;
void operator*= (const T& factor);
ASIString ToXML() const;
Function<T,T>* ConstructCopy() const;
ASI_FLOGIC LargerOrEqual(const T& value) const;
const VectorSet<T>* GetZeroSet();

protected:

Vector<T> ComputePerturbation(const Vector<T>& point) const;
Simplex<T> m_Simplex;
T* m_WeightVector;
T m_Factor;

//Vector<T> *m_PerturbationVector1;
};

This class is used in an iterative algorithm.


How? Don't you think it might matter?
Performance is about 500
iterations per second.
When i add the pointer m_PerturbationVector1 to the class (without
using it at all) performance drops to 250 iterations per second.

What is going on?


Who the hell can tell? Without seeing how the template is used, your
guess is just as good as ours. It could be that the size causes some
kind of processor cache to be blown away more often, it could be that
allocating a bunch of them now requires more OS involvement... There
is no way to tell for certain.
What can i do to overcome this effect.


Don't declare that member, since you're not using it.

Why don't you take a profiler and run your process through it with and
without the member. See if you can spot the difference. Then analyse.
Then come back and ask for assistance if you still need it.

Victor


Thank you. Clearly i will not declare a member when not using it. On
the long run i will use it.

Since i am a mathematican i do not know much about technical aspects.
Obviously nobody can answer the question in detail using the
information provided. But some may guess what it could be. Just as you
did. And then i migth be able to look for a book or something to learn
about. That is what i hoped for.

Roland
Jul 22 '05 #3

"Roland" <ro************@chello.at> wrote in message
news:9c**************************@posting.google.c om...
[SNIP]
Thank you. Clearly i will not declare a member when not using it. On
the long run i will use it.

Since i am a mathematican i do not know much about technical aspects.
Obviously nobody can answer the question in detail using the
information provided. But some may guess what it could be. Just as you
did. And then i migth be able to look for a book or something to learn
about. That is what i hoped for.


Sorry to disappoint you but guessing and optimization are two terms that
don't match very well. The whole problem starts with the term "optimizing a
bit". I'd recommend to profile your program first to determine where the
real bottleneck is before starting to fiddle around with the code. Keep in
mind that premature optimization is something that might even fire back!

Regards
Chris
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jason Heyes | last post by:
What harmful effects can using std::vector have on the performance of my program? How do I protect my program from these effects? Thanks.
4
by: hall | last post by:
Hi. I've come across someting strange. I was trying to make a for-loop execute repetadly until the function called inside it does not return true during the entire loop (see program below). ...
3
by: Alex Vinokur | last post by:
For instance, we need to measure performance of assignment 'ch1 = ch2' where ch1 and ch2 are of char type. We need to do that for different optimization levels of the same compiler. Here is...
13
by: Neil Zanella | last post by:
Hello, I wonder whether anyone has ever come across the following g++ compiler error message. I don't recall ever seeing it before. I solved my problem but I am still not sure about what this...
6
by: Jack Li | last post by:
Hi All, I have DB2 EEE 7.2 12 db partitions running on AIX 5.1ML5 P690( one server). The AIX workload manager is on. I started the same peoplesoft job on all 12 nodes at the same time. But some...
10
by: Daniel Billingsley | last post by:
In another online group in which I participate, we were discussing a particular piece of code that had a pretty high risk for breaking in the future (because it depended on something not changing...
2
by: Jeff S | last post by:
I'm looking for guidance (tutorials, backgrounders, tips, or otherwise) on measuring the performance of ASP.NET applications. I'm specifically interested in acquiring the capability of generating...
9
by: Nick Vaughan | last post by:
While running some long term tests on our Broadcast SDK one of our thread dropped out because an exception had been thrown: Exception: System.ArgumentOutOfRangeException Message: Load factor...
1
by: Nicholas Palmer | last post by:
Hi all, Got a question about the AspCompat=true page property. First a little background. We have an ASP.NET app that uses two COM components. The first is the Microsoft OWC 11 components and...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.