• mnesia overload


    mnesia overload是个很典型的问题,下面我找到一些老外处理"mnesia overload"消息的方案

     

    If you're using mnesia disc_copies tables and doing a lot of writes all at once, you've probably run into the following message

    =ERROR REPORT==== 10-Dec-2008::18:07:19 ===

    Mnesia(node@host): ** WARNING ** Mnesia is overloaded: {dump_log, write_threshold}

     

    This warning event can get really annoying, especially when they start happening every second. But you can eliminate them, or at least drastically reduce their occurance.

    Synchronous Writes

    The first thing to do is make sure to use sync_transaction or sync_dirty. Doing synchronous writes will slow down your writes in a good way, since the functions won't return until your record(s) have been written to the transaction log. The alternative, which is the default, is to do asynchronous writes, which can fill transaction log far faster than it gets dumped, causing the above error report.

    Mnesia Application Configuration

    If synchronous writes aren't enough, the next trick is to modify 2 obscure configuration parameters. The mnesia_overload event generally occurs when the transaction log needs to be dumped, but the previous transaction log dump hasn't finished yet. Tweaking these parameters will make the transaction log dump less often, and the disc_copies tables dump to disk more often. NOTE: these parameters must be set before mnesia is started; changing them at runtime has no effect. You can set them thru the command line or in a config file.

    dc_dump_limit

    This variable controls how often disc_copies tables are dumped from memory. The default value is 4, which means if the size of the log is greater than the size of table / 4, then a dump occurs. To make table dumps happen more often, increase the value. I've found setting this to 40 works well for my purposes.

    dump_log_write_threshold

    This variable defines the maximum number of writes to the transaction log before a new dump is performed. The default value is 100, so a new transaction log dump is performed after every 100 writes. If you're doing hundreds or thousands of writes in a short period of time, then there's no way mnesia can keep up. I set this value to 50000, which is a huge increase, but I have enough RAM to handle it. If you're worried that this high value means the transaction log will rarely get dumped when there's very few writes occuring, there's also a dump_log_time_threshold configuration variable, which by default dumps the log every 3 minutes.

    How it Works

    I might be wrong on the theory since I didn't actually write or design mnesia, but here's my understanding of what's happening. Each mnesia activity is recorded to a single transaction log. This transaction log then gets dumped to table logs, which in turn are dumped to the table file on disk. By increasing the dump_log_write_threshold, transaction log dumps happen much less often, giving each dump more time to complete before the next dump is triggered. And increasing dc_dump_limit helps ensure that the table log is also dumped to disk before the next transaction dump occurs.

  • 相关阅读:
    LightOJ 1239
    LightOJ 1166 Old Sorting 置换群 或 贪心 水题
    vijos 1243 生产产品 DP + 单调队列优化
    POJ 3348 Cows 凸包 求面积
    POJ 1389 Area of Simple Polygons 扫描线+线段树面积并
    POJ 1151 Atlantis 扫描线+线段树
    POJ 1228 Grandpa's Estate 凸包 唯一性
    bzoj 3622 DP + 容斥
    Uva5211/POJ1873 The Fortified Forest 凸包
    POJ 2007 Scrambled Polygon 极角序 水
  • 原文地址:https://www.cnblogs.com/bozhang/p/3115263.html
Copyright © 2020-2023  润新知