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 SimplexL2Penalt y : public Function<T,T>
{
public:
ASIString GetTypeInfo() const;
SimplexL2Penalt y(const Simplex<T>& simplex);
SimplexL2Penalt y(const Simplex<T>& simplex,const T& weight);
SimplexL2Penalt y(const Simplex<T>& simplex,const Vector<T>&
w);
SimplexL2Penalt y(const SimplexL2Penalt y& toBeCopied);
virtual ~SimplexL2Penal ty();
T Evaluate(const Vector<T>& point) const;
void operator*= (const T& factor);
ASIString ToXML() const;
Function<T,T>* ConstructCopy() const;
ASI_FLOGIC LargerOrEqual(c onst T& value) const;
const VectorSet<T>* GetZeroSet();
protected:
Vector<T> ComputePerturba tion(const Vector<T>& point) const;
Simplex<T> m_Simplex;
T* m_WeightVector;
T m_Factor;
//Vector<T> *m_Perturbation Vector1;
};
This class is used in an iterative algorithm. Performance is about 500
iterations per second.
When i add the pointer m_PerturbationV ector1 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. 3 1442
"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 SimplexL2Penalt y : public Function<T,T> { public:
ASIString GetTypeInfo() const; SimplexL2Penalt y(const Simplex<T>& simplex); SimplexL2Penalt y(const Simplex<T>& simplex,const T& weight); SimplexL2Penalt y(const Simplex<T>& simplex,const Vector<T>& w); SimplexL2Penalt y(const SimplexL2Penalt y& toBeCopied); virtual ~SimplexL2Penal ty(); T Evaluate(const Vector<T>& point) const; void operator*= (const T& factor); ASIString ToXML() const; Function<T,T>* ConstructCopy() const; ASI_FLOGIC LargerOrEqual(c onst T& value) const; const VectorSet<T>* GetZeroSet();
protected:
Vector<T> ComputePerturba tion(const Vector<T>& point) const; Simplex<T> m_Simplex; T* m_WeightVector; T m_Factor;
//Vector<T> *m_Perturbation Vector1; };
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_PerturbationV ector1 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
"Victor Bazarov" <v.********@com Acast.net> wrote in message news:<Lx1Pb.886 02$5V2.150409@a ttbi_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 SimplexL2Penalt y : public Function<T,T> { public:
ASIString GetTypeInfo() const; SimplexL2Penalt y(const Simplex<T>& simplex); SimplexL2Penalt y(const Simplex<T>& simplex,const T& weight); SimplexL2Penalt y(const Simplex<T>& simplex,const Vector<T>& w); SimplexL2Penalt y(const SimplexL2Penalt y& toBeCopied); virtual ~SimplexL2Penal ty(); T Evaluate(const Vector<T>& point) const; void operator*= (const T& factor); ASIString ToXML() const; Function<T,T>* ConstructCopy() const; ASI_FLOGIC LargerOrEqual(c onst T& value) const; const VectorSet<T>* GetZeroSet();
protected:
Vector<T> ComputePerturba tion(const Vector<T>& point) const; Simplex<T> m_Simplex; T* m_WeightVector; T m_Factor;
//Vector<T> *m_Perturbation Vector1; };
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_PerturbationV ector1 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
"Roland" <ro************ @chello.at> wrote in message
news:9c******** *************** ***@posting.goo gle.com...
[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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.
|
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).
The two lines that confuse me are marked as (1) and (2).
count=0;
bool s(true);
|
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 some test program.
Environment
-----------
|
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 message is all about. Any
ideas?
error: invalid initialization of non-const reference of
|
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 node(partition)
processing speed are much faster than the others. The fastest node
took 15 hours. But the slowest node took 17 hours.
According to DBA, the data are evenly disributed on 12 partitions. The
configuration of the partitions are...
| |
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 that was outside the
developer's control) but was slightly more performant. One participant
posted:
"I tend to take the performance track also, adding readability if the impact
isn't too great. There is also an odd reality that takes place...
|
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 objective data that
quantifies the effects of performance tuning efforts (e.g., performance
measures before and after implementing caching). I want to be able to
demonstrate cases where performance tuning efforts resulted in measurably
faster...
|
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 needs to be between 0.1 and 1.
Parameter name: loadFactor
Source: mscorlib
at System.Collections.Hashtable..ctor(Int32 capacity, Single
loadFactor, IHashCodeProvider hcp, IComparer comparer)
at System.Collections.Hashtable..ctor()
|
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 the second is a custom VB6 COM
component. So I was reading about AspCompat=true and it seemed like it would
be a good fit for our app. From what I can tell both of the COM components
that we are using are STA and we are creating the components in...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |