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

📄 throughput.so

📁 berkeley db 4.6.21的源码。berkeley db是一个简单的数据库管理系统
💻 SO
字号:
m4_comment([$Id: throughput.so,v 10.31 2002/04/02 17:07:05 bostic Exp $])m4_ref_title(m4_tam Applications,    Transaction throughput,    @transaction throughput, transapp/tune, transapp/faq)m4_p([dnlGenerally, the speed of a database system is measured by them4_italic(transaction throughput), expressed as a number oftransactions per second.  The two gating factors for m4_db performancein a transactional system are usually the underlying database files andthe log file.  Both are factors because they require disk I/O, which isslow relative to other system resources such as CPU.])m4_p([dnlIn the worst-case scenario:])m4_bulletbeginm4_bullet([dnlDatabase access is truly random and the database is too large for anysignificant percentage of it to fit into the cache, resulting in asingle I/O per requested key/data pair.])m4_bullet([Both the database and the log are on a single disk.])m4_bulletendm4_p([dnlThis means that for each transaction, m4_db is potentially performingseveral filesystem operations:])m4_bulletbeginm4_bullet([Disk seek to database file])m4_bullet([Database file read])m4_bullet([Disk seek to log file])m4_bullet([Log file write])m4_bullet([Flush log file information to disk])m4_bullet([dnlDisk seek to update log file metadata (for example, inode information)])m4_bullet([Log metadata write])m4_bullet([Flush log file metadata to disk])m4_bulletendm4_p([dnlThere are a number of ways to increase transactional throughput, all ofwhich attempt to decrease the number of filesystem operations pertransaction.  First, the m4_db software includes support form4_italic(group commit).  Group commit simply means that when theinformation about one transaction is flushed to disk, the informationfor any other waiting transactions will be flushed to disk at the sametime, potentially amortizing a single log write over a large number oftransactions.  There are additional tuning parameters which may beuseful to application writers:])m4_bulletbeginm4_bullet([dnlTune the size of the database cache.  If the m4_db key/data pairs usedduring the transaction are found in the database cache, the seek and readfrom the database are no longer necessary, resulting in two fewerfilesystem operations per transaction.  To determine whether your cachesize is too small, see m4_link(M4RELDIR/ref/am_conf/cachesize, Selectinga cache size).])m4_bullet([dnlPut the database and the log files on different disks.  This allows readsand writes to the log files and the database files to be performedconcurrently.])m4_bullet([dnlSet the filesystem configuration so that file access and modification timesare not updated.  Note that although the file access and modification timesare not used by m4_db, this may affect other programs -- so be careful.])m4_bullet([dnlUpgrade your hardware.  When considering the hardware on which to run yourapplication, however, it is important to consider the entire system.  Thecontroller and bus can have as much to do with the disk performance asthe disk itself.  It is also important to remember that throughput israrely the limiting factor, and that disk seek times are normally the trueperformance issue for m4_db.])m4_bullet([dnlTurn on the m4_ref(DB_TXN_WRITE_NOSYNC) or m4_ref(DB_TXN_NOSYNC) flags.This changes the m4_db behavior so that the log files are not writtenand/or flushed when transactions are committed.  Although this changewill greatly increase your transaction throughput, it means thattransactions will exhibit the ACI (atomicity, consistency, andisolation) properties, but not D (durability).  Database integrity willbe maintained, but it is possible that some number of the most recentlycommitted transactions may be undone during recovery instead of beingredone.])m4_bulletendm4_p([dnlIf you are bottlenecked on logging, the following test will help youconfirm that the number of transactions per second that your applicationdoes is reasonable for the hardware on which you're running.  Your testprogram should repeatedly perform the following operations:])m4_bulletbeginm4_bullet([Seek to the beginning of a file])m4_bullet([Write to the file])m4_bullet([Flush the file write to disk])m4_bulletendm4_p([dnlThe number of times that you can perform these three operations persecond is a rough measure of the minimum number of transactions persecond of which the hardware is capable.  This test simulates theoperations applied to the log file. (As a simplifying assumption in thisexperiment, we assume that the database files are either on a separatedisk; or that they fit, with some few exceptions, into the databasecache.)  We do not have to directly simulate updating the log filedirectory information because it will normally be updated and flushedto disk as a result of flushing the log file write to disk.])m4_p([dnlRunning this test program, in which we write 256 bytes for 1000 operationson reasonably standard commodity hardware (Pentium II CPU, SCSI disk),returned the following results:])m4_indent([dnl% testfile -b256 -o1000running: 1000 opsElapsed time: 16.641934 seconds1000 ops:   60.09 ops per second])m4_p([dnlNote that the number of bytes being written to the log as part of eachtransaction can dramatically affect the transaction throughput.  Thetest run used 256, which is a reasonable size log write.  Your logwrites may be different.  To determine your average log write size, usethe m4_ref(db_stat) utility to display your log statistics.])m4_p([dnlAs a quick sanity check, the average seek time is 9.4 msec for thisparticular disk, and the average latency is 4.17 msec.  That results ina minimum requirement for a data transfer to the disk of 13.57 msec, ora maximum of 74 transfers per second.  This is close enough to theprevious 60 operations per second (which wasn't done on a quiescentdisk) that the number is believable.])m4_p([dnlAn implementation of the previous m4_linkweb(writetest.cs, [example testprogram]) for m4_posix1_name standard systems is included in the m4_dbdistribution.])m4_page_footer

⌨️ 快捷键说明

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