⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tune.so

📁 berkeley db 4.6.21的源码。berkeley db是一个简单的数据库管理系统
💻 SO
字号:
m4_comment([$Id: tune.so,v 11.24 2006/08/08 05:24:09 mjc Exp $])m4_ref_title(m4_tam Applications,    Transaction tuning,    [@transaction tuning, transaction @tuning],    transapp/reclimit, transapp/throughput)m4_p([dnlThere are a few different issues to consider when tuning the performanceof m4_db transactional applications.  First, you should reviewm4_link(M4RELDIR/ref/am_misc/tune, [Access method tuning]), as thetuning issues for access method applications are applicable totransactional applications as well.  The following are additional tuningissues for m4_db transactional applications:])m4_tagbeginm4_tag(access method, [dnlHighly concurrent applications should use the Queue access method, wherepossible, as it provides finer-granularity of locking than the otheraccess methods.  Otherwise, applications usually see better concurrencywhen using the Btree access method than when using either the Hash orRecno access methods.])m4_tag(record numbers, [dnlUsing record numbers outside of the Queue access method will often slowdown concurrent applications as they limit the degree of concurrencyavailable in the database.  Using the Recno access method, or the Btreeaccess method with retrieval by record number configured can slowapplications down.])m4_tag(Btree database size, [dnlWhen using the Btree access method, applications supporting concurrentaccess may see excessive numbers of deadlocks in small databases.  Thereare two different approaches to resolving this problem.  First, as theBtree access method uses page-level locking, decreasing the databasepage size can result in fewer lock conflicts.  Second, in the case ofdatabases that are cyclically growing and shrinking, turning off reversesplits (with m4_ref(DB_REVSPLITOFF)) can leave the database with enoughpages that there will be fewer lock conflicts.])m4_tag(read locks, [dnlPerforming all read operations outside of transactions or atm4_link(M4RELDIR/ref/transapp/read, snapshot isolation) can oftensignificantly increase application throughput.  In addition, limitingthe lifetime of non-transactional cursors will reduce the length oftimes locks are held, thereby improving concurrency.])m4_tag([m4_ref(DB_DIRECT_DB), m4_ref(DB_DIRECT_LOG)], [dnlConsider using the m4_ref(DB_DIRECT_DB) and m4_ref(DB_DIRECT_LOG) flags.On some systems, avoiding caching in the operating system can improvewrite throughput and allow the creation of larger m4_db caches.])m4_tag([m4_ref(DB_READ_UNCOMMITTED), m4_ref(DB_READ_COMMITTED)], [dnlConsider decreasing the level of isolation of transaction using them4_ref(DB_READ_UNCOMMITTED) or m4_ref(DB_READ_COMMITTED) flags fortransactions or cursors or the m4_ref(DB_READ_UNCOMMITTED) flag onindividual read operations.  The m4_ref(DB_READ_COMMITTED) flag willrelease read locks on cursors as soon as the data page is nolongerreferenced.  This is also called m4_italic(degree 2 isolation).  Thiswill tend to block write operations for shorter periods for applicationsthat do not need to have repeatable reads for cursor operations.m4_p([dnlThe m4_ref(DB_READ_UNCOMMITTED) flag will allow read operations topotentially return data which has been modified but not yet committed,and can significantly increase application throughput in applicationsthat do not require data be guaranteed to be permanent in the database.This is also called m4_italic(degree 1 isolation), or m4_italic(dirtyreads).])])m4_tag([m4_ref(DB_RMW)], [dnlIf there are many deadlocks, consider using the m4_ref(DB_RMW) flag toimmediate acquire write locks when reading data items that willsubsequently be modified.  Although this flag may increase contention(because write locks are held longer than they would otherwise be), itmay decrease the number of deadlocks that occur.])m4_tag([m4_ref(DB_TXN_WRITE_NOSYNC), m4_ref(DB_TXN_NOSYNC)], [dnlBy default, transactional commit in m4_db implies durability, that is,all committed operations will be present in the database after recoveryfrom any application or system failure.  For applications not requiringthat level of certainty, specifying the m4_ref(DB_TXN_NOSYNC) flag willoften provide a significant performance improvement. In this case, thedatabase will still be fully recoverable, but some number of committedtransactions might be lost after application or system failure.])m4_tag(access databases in order, [dnlWhen modifying multiple databases in a single transaction, always accessphysical files and databases within physical files, in the same orderwhere possible.  In addition, avoid returning to a physical file ordatabase, that is, avoid accessing a database, moving on to anotherdatabase and then returning to the first database.  This cansignificantly reduce the chance of deadlock between threads ofcontrol.])m4_tag(large key/data items, [dnlTransactional protections in m4_db are guaranteed by before and afterphysical image logging.  This means applications modifying largekey/data items also write large log records, and, in the case of thedefault transaction commit, threads of control must wait until thoselog records have been flushed to disk.  Applications supportingconcurrent access should try and keep key/data items small whereverpossible.])m4_tag(mutex selection, [dnlDuring configuration, m4_db selects a mutex implementation for thearchitecture. m4_db normally prefers blocking-mutex implementations overnon-blocking ones.  For example, m4_db will select POSIX pthread mutexinterfaces rather than assembly-code test-and-set spin mutexes becausepthread mutexes are usually more efficient and less likely to waste CPUcycles spinning without getting any work accomplished.m4_p([dnlFor some applications and systems (generally highly concurrentapplications on large multiprocessor systems), m4_db makes the wrongchoice.  In some cases, better performance can be achieved byconfiguring with them4_linkpage(M4RELDIR/ref/build_unix/conf, --with-mutex, --with-mutex)argument and selecting a different mutex implementation than the oneselected by m4_db.  When a test-and-set spin mutex implementation isselected, it may be useful to tune the number of spins made beforeyielding the processor and sleeping.  For more information, see them4_refT(mutex_set_tas_spins).])m4_p([dnlFinally, m4_db may put multiple mutexes on individual cache lines.  Whentuning m4_db for large multiprocessor systems, it may be useful to tunemutex alignment using them4_ref(mutex_set_align) method.])])m4_tag([m4_linkpage(M4RELDIR/ref/build_unix/conf,--enable-posixmutexes, --enable-posixmutexes)], [dnlBy default, the m4_db library will only select the POSIX pthread muteximplementation if it supports mutexes shared between multiple processes.If your application does not share its database environment betweenprocesses and your system's POSIX mutex support was not selected becauseit did not support inter-process mutexes, you may be able to increaseperformance and transactional throughput by configuring with them4_linkpage(M4RELDIR/ref/build_unix/conf, --enable-posixmutexes,--enable-posixmutexes) argument.])m4_tag(log buffer size, [dnlm4_db internally maintains a buffer of log writes.   The buffer iswritten to disk at transaction commit, by default, or, whenever itis filled.  If it is consistently being filled before transactioncommit, it will be written multiple times per transaction, costingapplication performance.  In these cases, increasing the size of thelog buffer can increase application throughput.])m4_tag(log file location, [dnlIf the database environment's log files are on the same disk as thedatabases, the disk arms will have to seek back-and-forth between thetwo.  Placing the log files and the databases on different disk armscan often increase application throughput.])m4_tag(trickle write, [dnlIn some applications, the cache is sufficiently active and dirty thatreaders frequently need to write a dirty page in order to have space inwhich to read a new page from the backing database file.  You can usethe m4_ref(db_stat) utility (or the statistics returned by them4_refT(memp_stat)) to see how often this is happening in yourapplication's cache.  In this case, using a separate thread of controland the m4_refT(memp_trickle) to trickle-write pages can often increasethe overall throughput of the application.])m4_tagendm4_page_footer

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -