Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 29th, 2006, 2:59 AM   #11
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
So what do you do if you want to push in some pointers to objects?
Say the object is 1 KB, you don't want to copy that 30 million times right?
What if you make a pointer to each of your objects and put that in your vector?

I think that's what the OP means.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Mar 30th, 2006, 2:24 AM   #12
slyadams
Newbie
 
Join Date: Mar 2006
Posts: 12
Rep Power: 0 slyadams is on a distinguished road
This is what I do at the moment, I 'new' the object, then push the pointer.

Thing is, I am storing lots and lots of 'data points' consisting of 3 ints and a long. Thus, my object size is only 160bits and so a 32bit overhead to that is not insignificant.

I couldn't test the copy constructor yesterday because something came up, but will do today.

Thanks again everyone.
slyadams is offline   Reply With Quote
Old Mar 30th, 2006, 2:33 AM   #13
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Quote:
Originally Posted by slyadams
I thought about ways to reduce the number of objects, but the problem is the data is storing rows from a database. This data is basically a 4 element data point (long,int,int,int) and the process needs to store loads of them to make them available for front end applications to query. Basically the process is a data cache and provides significantly quicker access than querying the database directly.
That is normally the purpose of a cache. That doesn't mean the cache has to hold EVERYTHING though. For example, are there particular objects that are accessed frequently? Is there some other pattern to access (eg based on object X being accessed, is there a higher likelihood of some other object Y being accessed shortly afterwards)?
Quote:
Originally Posted by slyadams
The process does work and has been in production for about a year now and I'm pretty sure doesn't have any leaks because the process is usually up for months on end, constantly reading new rows from the database and dropping old ones. We've just started an implementation for a new client who wants a 64bit platform. During this implementation I realised that the memory overhead of all these pointers will double.
If the client has a 64 bit platform, odds are they won't be skimping on RAM anyway. One of the purposes of going 64 bit is that more RAM can be addressed. It might help if you asked the client how much RAM on the target machine can be assumed as a minimim. Then you can decide if you need to worry about memory usage or not.
Quote:
Originally Posted by slyadams
I will write a copy constructor today and trace through the allocation and see what happens.
All you really need to check is that the number of constructor calls matches the number of destructor calls. Keep in mind you need to track ALL constructors though.
Quote:
Originally Posted by slyadams
I will try and get around the vector resizing issue by looking at the impact of moving to a list. Although, the maximum length of a vector at the bottom of my tree is going to be 1440. With a object size of 160bits, this comes out at just under 30kB. Not that much at all, so maybe I don't need to worry about vector resizes.
A typical implementation of a list is as a linked list. If that's true, it means each node of the list contains your object, plus a pointer to another node in the list.
grumpy is offline   Reply With Quote
Old Mar 30th, 2006, 3:52 AM   #14
slyadams
Newbie
 
Join Date: Mar 2006
Posts: 12
Rep Power: 0 slyadams is on a distinguished road
Yep mate, know about caches and linked lists and the like.

The cache doesn't hold everything, trust me! It stores the last 50 days worth of data (there is over 2 years in the database). If a front end process requests data older than the 50 days then the cache will go and get this from the database, with an obvious performance hit. Pretty much all the data in the cache will be accessed regularly, due to the nature of the system.

While it may be true that the client won't be skimping on memory, it is still true that on a 64 bit platform, the pointer to the object will be 64 bits, while the object itself is only 160bits. To me that overhead is too high (30% of the space requirement for the data points would be in storing the pointers!).

We built the target machine and it is dedicated, pretty much, to running this process. The machien has, I think, 4GB of memory in it. Now, the reason we decided to use a 64bit machine for this installation is that the system deals with a LOT of unix timestamps (both in the database and the cache) and so we thought we'd see how much of a performance benefit we might get from getting a 64 bit CPU to handle this, rather than a 32bit CPU.
slyadams is offline   Reply With Quote
Old Mar 30th, 2006, 4:18 AM   #15
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Quote:
Originally Posted by slyadams
While it may be true that the client won't be skimping on memory, it is still true that on a 64 bit platform, the pointer to the object will be 64 bits, while the object itself is only 160bits. To me that overhead is too high (30% of the space requirement for the data points would be in storing the pointers!).
My point is: WHY do you consider that overhead too high? If you are busily saving memory resources you don't need to you are just wasting effort.
Quote:
Originally Posted by slyadams
We built the target machine and it is dedicated, pretty much, to running this process. The machien has, I think, 4GB of memory in it.
Given you are controlling both the hardware and the software, it would be easier to make sure the hardware has enough memory. With 160 bit structs, 4G is more than enough. A Gig of RAM costs no more than (and probably less than) the time you've spent worrying about the memory usage of different techniques.
Quote:
Originally Posted by slyadams
Now, the reason we decided to use a 64bit machine for this installation is that the system deals with a LOT of unix timestamps (both in the database and the cache) and so we thought we'd see how much of a performance benefit we might get from getting a 64 bit CPU to handle this, rather than a 32bit CPU.
With that sort of rationale, I suggest doing the minimum needed to get the program running correctly on the 64 bit system, and then test your little heart out. I'd only worry about memory usage if testing showed it was a significant issue.
grumpy is offline   Reply With Quote
Old Mar 30th, 2006, 6:14 AM   #16
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I feel compelled to suggest that you study economics as well as C++. You can find bosses that don't know (or care) that you're tanking the bottom-line, but it's a chancy thing.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 30th, 2006, 7:08 AM   #17
slyadams
Newbie
 
Join Date: Mar 2006
Posts: 12
Rep Power: 0 slyadams is on a distinguished road
The implementation is on a fixed price contract and currently we are undergoing a process to review the system components, and we have budget to do this. The issue here is the fact that this process is part of a commercial piece of software that we install for a number of clients.

Maximising the amount of history that can fit in an instance of the cache is very important because queries that request data from before the start are commonplace. Thus, if we can increase the history of the cache by 30% (e.g. 50 days -> 65 days) then this is a tangible benefit to at least one of our clients, who are prepared to spend money on our time, but are very resistent to spend a few hundred bucks on some more RAM. Telling you that its a 'government' client will tell you why.

I spent a couple of hours today modifying the code and checking out the constuctors, destructors and copy constructors and it all seems to work.

Also, the figure of 30m points was for a different client than the 64bit machine. The amount of points for this new client is, at the moment, not completely defined by the client. This is why it is important to us to maximise the amount of history that can be loaded.
slyadams is offline   Reply With Quote
Old Mar 30th, 2006, 8:38 AM   #18
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
prepared to spend money on our time, but are very resistent to spend a few hundred bucks on some more RAM
Well, nothing you can do about that, but pay more taxes. I sympathize, did tons of work for the USPS and some for the Air Force and State Department.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 30th, 2006, 11:17 AM   #19
slyadams
Newbie
 
Join Date: Mar 2006
Posts: 12
Rep Power: 0 slyadams is on a distinguished road
Cheers mate. I'm pretty sure I'm there now. I've removed the pointers, created the correct copy constructor and done a bunch of burn tests and its stable and the internal 'memory counter' is consistent. All I need to do now is check that the code that creates and deletes subtrees still works, although I don't see how it won't.

Many thanks again
slyadams is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:35 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC