Click here to Skip to main content
15,897,891 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: True or False Flags: best practices Pin
SSMERK00712-Jul-07 5:56
SSMERK00712-Jul-07 5:56 
QuestionData collection and mapping Pin
patelash0111-Jul-07 10:22
patelash0111-Jul-07 10:22 
AnswerRe: Data collection and mapping Pin
Pete O'Hanlon11-Jul-07 10:53
mvePete O'Hanlon11-Jul-07 10:53 
QuestionMalloc & Page File Pin
Mr Simple9-Jul-07 9:59
Mr Simple9-Jul-07 9:59 
AnswerRe: Malloc & Page File Pin
Mr Simple9-Jul-07 10:03
Mr Simple9-Jul-07 10:03 
GeneralRe: Malloc & Page File Pin
Luc Pattyn9-Jul-07 10:11
sitebuilderLuc Pattyn9-Jul-07 10:11 
GeneralRe: Malloc & Page File Pin
Mr Simple9-Jul-07 22:10
Mr Simple9-Jul-07 22:10 
GeneralRe: Malloc & Page File Pin
Luc Pattyn10-Jul-07 0:50
sitebuilderLuc Pattyn10-Jul-07 0:50 
Hi,

there seems no need to have just one (large) buffer.
this is how I would go about it:

- pre-allocate a number N of memory blocks of 52KB each (yes exactly 52*1024 bytes);
- have two queues, one with empty buffers, one with full buffers;
- initialize with all the available buffers in the "empty queue";
- let the producer take an empty buffer, and fill it up completely, before
putting it in the full queue;
- let the consumer take a full buffer, empty it, and return it to the empty queue;

take care of performance by:
- not using function calls in producer/consumer other than the ones absolutely
necessary, including one queue_get and one queue_put.
- using a single disk I/O function that transfers an entire buffer at the time
(that's why it best is a multiple of 4KB); and use the lowest-level I/O function
available, in C that might be fread/fwrite or even read/write. Not sure.
- trying to keep the buffers in cache (although they probably would have to
be copied to/from memory to perform the disk's DMA); that's why I do not
insist on having large buffers nor many buffers; I would try not to exceed 1 MB
in total.
- possibly: not using a locking queue; a queue that serves one producer and
one consumer can de devised to lock only on extreme conditions (that is
full and empty), but not while putting/getting an item (use a circular buffer,
a get and a put index; only one party is allowed to write to the get index,
the other to the put index)
- possibly and somewhat tricky: play around with producer/consumer priorities:
if there are more empty buffers, raise the producer; if there are more full
buffers, lower the producer. Or something similar.
- experimenting with N: this is your one degree of freedom, you can add memory
to keep it alive longer (maybe with less cache efficiency), that is to overcome
longer disturbances due to external causes.

If you do this right, I would not be surprised you could make it run "forever",
since 53MB/s is well below today's disk bandwidth. The thing that probably
matters most is what else the PC is doing (networks, optical disks, etc; turn
them of as much as possible!).

I would not be concerned about the paging mechanism inside the PC; it knows
how to handle bigger jobs than this. You only would be using around 1 MB of
memory, and all your use is rather static and in multiples of 4KB, so
dont worry.

One final remark: I would first try a subset of the above, to get things
working, so I could observe how well it already is doing, then decide on further
improvements.

Good luck, and dont hesitate to post more questions, or results...

Smile | :)





GeneralRe: Malloc & Page File Pin
Mr Simple10-Jul-07 5:19
Mr Simple10-Jul-07 5:19 
GeneralRe: Malloc & Page File Pin
Dan Neely10-Jul-07 5:37
Dan Neely10-Jul-07 5:37 
GeneralRe: Malloc & Page File Pin
Mr Simple10-Jul-07 5:44
Mr Simple10-Jul-07 5:44 
GeneralRe: Malloc & Page File Pin
Dan Neely10-Jul-07 7:09
Dan Neely10-Jul-07 7:09 
AnswerRe: Malloc & Page File Pin
Stephen Hewitt9-Jul-07 14:07
Stephen Hewitt9-Jul-07 14:07 
AnswerRe: Malloc & Page File Pin
Emmanouil12-Jul-07 3:22
Emmanouil12-Jul-07 3:22 
GeneralRe: Malloc & Page File Pin
Luc Pattyn12-Jul-07 7:27
sitebuilderLuc Pattyn12-Jul-07 7:27 
GeneralRe: Malloc & Page File Pin
Emmanouil12-Jul-07 7:58
Emmanouil12-Jul-07 7:58 
QuestionYour help is greatly appreciated Pin
columbiasmiles9-Jul-07 7:30
columbiasmiles9-Jul-07 7:30 
Questionadding elements in alphabetical order to a hashtable that deals with collisions using java Pin
claudinawales8-Jul-07 23:28
claudinawales8-Jul-07 23:28 
AnswerRe: adding elements in alphabetical order to a hashtable that deals with collisions using java Pin
Luc Pattyn9-Jul-07 10:56
sitebuilderLuc Pattyn9-Jul-07 10:56 
QuestionEncrypting data in a database Pin
jlebensold5-Jul-07 20:37
jlebensold5-Jul-07 20:37 
AnswerRe: Encrypting data in a database Pin
Paul Conrad4-Nov-07 7:08
professionalPaul Conrad4-Nov-07 7:08 
GeneralRe: Encrypting data in a database Pin
jlebensold5-Nov-07 20:02
jlebensold5-Nov-07 20:02 
QuestionObscenely amount of data Pin
minimice5-Jul-07 20:24
minimice5-Jul-07 20:24 
AnswerRe: Obscenely amount of data Pin
originSH5-Jul-07 22:23
originSH5-Jul-07 22:23 
AnswerRe: Obscenely amount of data Pin
Brady Kelly5-Jul-07 22:26
Brady Kelly5-Jul-07 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.