niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Berkeley DB
BDB and 4GB+ RAM on 32bit system
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Howard Chu
*nix forums beginner


Joined: 14 Feb 2005
Posts: 15

PostPosted: Wed Apr 06, 2005 9:29 am    Post subject: Re: BDB and 4GB+ RAM on 32bit system Reply with quote

studdugie@gmail.com wrote:
Quote:
I'm trying to figure out what is the best way to give BerkeleyDB
4.3.27NC on Linux 2.6.xx, 4GB or more of RAM w/o the amount of RAM
given to BDB counting against the process that started BDB. I've read
the documentation at least 100x times and so far the only thing I'm
sure about is using DB_PRIVATE would cause any memory BDB allocated to
count against the process that started BDB. I don't fully understand
the interaction between BDB and the OS' memory management facilities so
I'm not quite sure how the shared memory and/or file system backed
memory options work insofar as counting against my process. It may be
useful to note that I'm running a single process/threaded application
that does not use transactions, locking, replication, etc.

The stock answer for Linux on 32 bit x86 is that any single process can
only address up to 4GB. If the machine has more memory than that, the
only way to make use of it is to access the memory from multiple
processes, and any process can only access up to 4GB each. Also in
practice the usable limit is smaller; by default 1GB of the address
space in each process is reserved for the kernel, so only 3GB is
available for application usage.

Quote:
If I had to express what I'm trying to do as a series of questions, it
would go like this:

Is it possible for a process to open and use BDB w/o the memory that
BDB uses counting as part of the memory of the process that opened BDB?

Some process somewhere has to own it. At best you could have a single
process using up to 3GB for BDB itself, and use pipes or a small shared
memory region to communicate with it from your main application process,
thus giving you around 6GB of working space if you ran only two
processes. If you did all the data exchange via pipes it would probably
kill the application's performance; if you used shared memory it might
be reasonable but any space you dedicate as a shared memory
communication port would be space you couldn't use for BDB caches.

While you can probably make this work with enough determination and
skill, it would be easier just to buy a 64 bit machine and not try to
shoehorn a larger-than-32-bit problem into a 32 bit machine. AMD64
systems are ridiculously cheap and the performance is fantastic.

--
-- Howard Chu
Chief Architect, Symas Corp. Director, Highland Sun
http://www.symas.com http://highlandsun.com/hyc
Symas: Premier OpenSource Development and Support
Back to top
studdugie@gmail.com
*nix forums beginner


Joined: 21 Jun 2005
Posts: 28

PostPosted: Tue Apr 05, 2005 5:36 pm    Post subject: BDB and 4GB+ RAM on 32bit system Reply with quote

I'm trying to figure out what is the best way to give BerkeleyDB
4.3.27NC on Linux 2.6.xx, 4GB or more of RAM w/o the amount of RAM
given to BDB counting against the process that started BDB. I've read
the documentation at least 100x times and so far the only thing I'm
sure about is using DB_PRIVATE would cause any memory BDB allocated to
count against the process that started BDB. I don't fully understand
the interaction between BDB and the OS' memory management facilities so
I'm not quite sure how the shared memory and/or file system backed
memory options work insofar as counting against my process. It may be
useful to note that I'm running a single process/threaded application
that does not use transactions, locking, replication, etc.

If I had to express what I'm trying to do as a series of questions, it
would go like this:

Is it possible for a process to open and use BDB w/o the memory that
BDB uses counting as part of the memory of the process that opened BDB?

What is maximum amount of memory BDB can use, where memory consists of
the BDB cache in an Environment and database cache(s) outside of an
Environment?


I'm pasting some sample code of how I've got it setup now.
Unfortunately, I'm not able to test it because the memory that I've
ordered for the box hasn't arrived yet. So while I wait for it to get
here I figured I would ask what limitations I'm going to run up
against.

<code>
/*Note to helpful group reader:
* The tails, indexDb, and rindexDb are the databases the need the 4GB
cache.
* They are going to be the only databases that will participate in an
Environment.
* All other databases will exist outside of any Environment so I set
the cache directly
* on the database object.*/

BDB_PAGE_SIZE = Bytes.KILOBYTE << 6;

EnvironmentConfig envc = new EnvironmentConfig();
envc.setAllowCreate( true );
envc.setInitializeRegions( true );
envc.setInitializeCache( true );
envc.setCacheSize( Bytes.GIGABYTE << 2 );
sysenv = new Environment( SYSTEM_DIR, envc );

DatabaseConfig bdbConfig = new DatabaseConfig();
bdbConfig.setAllowCreate( true );
bdbConfig.setType( DatabaseType.HASH );
tails = sysenv.openDatabase( null, "tails", null, bdbConfig );

bdbConfig.setPageSize( BDB_PAGE_SIZE );
indexDb = sysenv.openDatabase( null, "indexDb", null, bdbConfig );

bdbConfig.setType( DatabaseType.BTREE );
rindexDb = sysenv.openDatabase( null, "rindexDb", null, bdbConfig );

SequenceConfig seqc = new SequenceConfig();
seqc.setAllowCreate( true );
seqc.setWrap( false );
seqc.setAutoCommitNoSync( true );
seqc.setInitialValue( 1 );
seqc.setRange( 1, 1L << 32 );
sequence = rindexDb.openSequence( null, new BigEndianIntegerEntry( 0 ),
seqc );

bdbConfig.setUnsortedDuplicates( true );
bdbConfig.setCacheSize( BDB_PAGE_SIZE << 1 );
logLines = new Database( new File( STAGING, name.concat( dbSuffix )
).getAbsolutePath(), null, bdbConfig );
</code>

Thanxs,

Dane
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 2:44 am | All times are GMT
navigation Forum index » Databases » Berkeley DB
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Bug#379104: ITP: complearn-mpi -- parallel quartet tree s... Rudi Cilibrasi devel 0 Fri Jul 21, 2006 11:30 am
No new posts Bug#379103: ITP: complearn-gui -- 3D drag-and-drop interf... Rudi Cilibrasi devel 0 Fri Jul 21, 2006 11:00 am
No new posts crashes my system like clockwork walterbyrd@iname.com PHP 10 Thu Jul 20, 2006 6:49 pm
No new posts running a system function from c++ code Fred J. C++ 13 Thu Jul 20, 2006 2:54 am
No new posts Comparing Tru64 UNIX and HP-UX System Management Tools lmcgaughey@parsec.com Tru64 0 Wed Jul 19, 2006 6:52 pm

Online Advertising | Personal Loans | Loans | Web Advertising | Fish Tank Help
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1640s ][ Queries: 20 (0.0829s) ][ GZIP on - Debug on ]