当前位置: 首页 > news >正文

有没有哪个做美食的网站软文大全500篇

有没有哪个做美食的网站,软文大全500篇,新余seo,机器ip后面加个端口做网站本文主要分析leveldb项目的MakeRoomForWrite方法及延伸出的相关方法。 努力弄清memtable 和 immutable memtable的切换过程细节, 背景总结: LevelDB 是一个基于 Log-Structured Merge-Tree (LSM Tree) 的高性能键值存储系统。 在 LevelDB 中&#xff0…

本文主要分析leveldb项目的MakeRoomForWrite方法及延伸出的相关方法。
努力弄清memtable 和 immutable memtable的切换过程细节,

背景总结:

LevelDB 是一个基于 Log-Structured Merge-Tree (LSM Tree) 的高性能键值存储系统。
在 LevelDB 中,MemTable 和 SSTable 是两种关键的数据结构,它们共同支持快速的读写操作和高效的存储管理。

MemTable 是 LevelDB 中的一个内存数据结构,它提供了快速的键值对读写能力。
SSTable(Sorted String Table)是 LevelDB 中用于持久化存储数据的结构。

当 MemTable 达到一定大小时,LevelDB 会将其转换为一个不可变的 memtable。这个过程称为 MemTable 切换(MemTable Switch)。新的 MemTable 会被创建,用于处理新的写入操作。被切换的 MemTable 会被持久化到磁盘上,成为一个 SSTable。这个过程通常涉及到写入一个 SSTable 文件,并可能触发 Compaction 操作来优化存储结构。

通过这种方式,LevelDB 能够在提供快速写入和读取操作的同时,有效地管理内存和磁盘空间,保持长期的存储效率。

有了以上基本知识背景后,我们来看源码怎么实现的?

MakeRoomForWrite源码分析

主要逻辑在db_impl.cc 的MakeRoomForWrite方法里。
这个方法的调用点在DBImpl::Write,即写数据的时候。

// REQUIRES: mutex_ is held
// REQUIRES: this thread is currently at the front of the writer queue
Status DBImpl::MakeRoomForWrite(bool force) {// 这个方法需要持有锁。mutex_.AssertHeld();assert(!writers_.empty());bool allow_delay = !force;Status s;while (true) {// 如果后台有error,将error赋给Status对象,然后跳出while循环if (!bg_error_.ok()) {// Yield previous errors = bg_error_;break;// 如果没有error,允许写延迟并且当前level0级别的文件数大于阈值。// 那这时就slow down writers。休眠1ms。期间释放mutex_, 休眠结束之后再获取mutex_} else if (allow_delay && versions_->NumLevelFiles(0) >=config::kL0_SlowdownWritesTrigger) {// We are getting close to hitting a hard limit on the number of// L0 files.  Rather than delaying a single write by several// seconds when we hit the hard limit, start delaying each// individual write by 1ms to reduce latency variance.  Also,// this delay hands over some CPU to the compaction thread in// case it is sharing the same core as the writer.mutex_.Unlock();env_->SleepForMicroseconds(1000);allow_delay = false;  // Do not delay a single write more than oncemutex_.Lock();// 走到下面这个分支,说明level0级别的文件数还没超过阈值。并且当前正在使用的memtable// 的内存使用小于4MB,说明还有空间预留给写操作,直接退出循环。// 注:预估内存使用情况使用的是leveldb自己实现的内存管理库Arena。} else if (!force &&(mem_->ApproximateMemoryUsage() <= options_.write_buffer_size)) {// There is room in current memtablebreak;// 走到下面这个分支,说明当前memtable没有足够空间给写操作了。并且已经有一个immutable memtable存在了,// 此时不能继续创建immutable memtable了,打印一下日志,等待后台任务发出唤醒信号(imm_数据已经被flush到磁盘,并且引用被销毁)。} else if (imm_ != nullptr) {// We have filled up the current memtable, but the previous// one is still being compacted, so we wait.Log(options_.info_log, "Current memtable full; waiting...\n");background_work_finished_signal_.Wait();// 到下面这个分支,说明imm_指针为null,判断当前level0级别文件个数是否超过12个// 超过12个就需要等待后台任务发信号唤醒(compact结束)} else if (versions_->NumLevelFiles(0) >= config::kL0_StopWritesTrigger) {// There are too many level-0 files.Log(options_.info_log, "Too many L0 files; waiting...\n");background_work_finished_signal_.Wait();// 走到最后这个分支里,说明可以直接创建immutable memtable。} else {// 尝试切换到新的memtable,并且触发旧的文件的compaction。// Attempt to switch to a new memtable and trigger compaction of oldassert(versions_->PrevLogNumber() == 0);uint64_t new_log_number = versions_->NewFileNumber();WritableFile* lfile = nullptr;// 创建新的日志文件。用lfile指针指向。s = env_->NewWritableFile(LogFileName(dbname_, new_log_number), &lfile);if (!s.ok()) {// Avoid chewing through file number space in a tight loop.versions_->ReuseFileNumber(new_log_number);break;}// 删除当前日志文件的Writer指针	delete log_;// 关闭旧的日志文件 s = logfile_->Close();if (!s.ok()) {// We may have lost some data written to the previous log file.// Switch to the new log file anyway, but record as a background// error so we do not attempt any more writes.//// We could perhaps attempt to save the memtable corresponding// to log file and suppress the error if that works, but that// would add more complexity in a critical code path.RecordBackgroundError(s);}// 释放旧的日志文件对象delete logfile_;// logfile_指针指向新创建的日志文件logfile_ = lfile;logfile_number_ = new_log_number;// log_指针指向新日志文件创建出来的Writer对象log_ = new log::Writer(lfile);// imm_指针指向旧的mem_,即immutable memtable指向当前的memtable。imm_ = mem_;// has_imm_是个原子bool。has_imm_.store(true, std::memory_order_release);// mem_指针指向一个新的MemTable。mem_ = new MemTable(internal_comparator_);// 增加mem_的引用计数mem_->Ref();force = false;  // Do not force another compaction if have room// 可能会触发compaction。MaybeScheduleCompaction();}}return s;
}

TODO:
1、leveldb里NewWritableFile、LogFileName。


文章转载自:
http://friarbird.xhqr.cn
http://harim.xhqr.cn
http://aquiform.xhqr.cn
http://squirrelly.xhqr.cn
http://magnetodisk.xhqr.cn
http://supremacy.xhqr.cn
http://mouthbrooder.xhqr.cn
http://tempersome.xhqr.cn
http://solicitous.xhqr.cn
http://souslik.xhqr.cn
http://megaera.xhqr.cn
http://message.xhqr.cn
http://listerism.xhqr.cn
http://crossbuttock.xhqr.cn
http://skipper.xhqr.cn
http://tuitional.xhqr.cn
http://procryptic.xhqr.cn
http://spiritualist.xhqr.cn
http://renegade.xhqr.cn
http://kwangsi.xhqr.cn
http://renaissance.xhqr.cn
http://alhambresque.xhqr.cn
http://overvoltage.xhqr.cn
http://treadless.xhqr.cn
http://calcic.xhqr.cn
http://dysmetria.xhqr.cn
http://bipartite.xhqr.cn
http://antemeridiem.xhqr.cn
http://thioarsenate.xhqr.cn
http://bauson.xhqr.cn
http://oarless.xhqr.cn
http://ecosystem.xhqr.cn
http://ineptly.xhqr.cn
http://adoptionist.xhqr.cn
http://rhino.xhqr.cn
http://mentation.xhqr.cn
http://labourite.xhqr.cn
http://slade.xhqr.cn
http://cytosol.xhqr.cn
http://sabbatise.xhqr.cn
http://ensiform.xhqr.cn
http://talkie.xhqr.cn
http://cannonry.xhqr.cn
http://vocoder.xhqr.cn
http://lofi.xhqr.cn
http://gastight.xhqr.cn
http://phosphofructokinase.xhqr.cn
http://bubbleheaded.xhqr.cn
http://verkhoyansk.xhqr.cn
http://calcareous.xhqr.cn
http://dolefully.xhqr.cn
http://paisana.xhqr.cn
http://diu.xhqr.cn
http://thrill.xhqr.cn
http://mewl.xhqr.cn
http://thinnet.xhqr.cn
http://deepmouthed.xhqr.cn
http://missus.xhqr.cn
http://vomiturition.xhqr.cn
http://abele.xhqr.cn
http://spendthrift.xhqr.cn
http://laffer.xhqr.cn
http://edacity.xhqr.cn
http://horsecloth.xhqr.cn
http://woodpie.xhqr.cn
http://gallicanism.xhqr.cn
http://sucrier.xhqr.cn
http://woolmark.xhqr.cn
http://conduit.xhqr.cn
http://rhodonite.xhqr.cn
http://papaw.xhqr.cn
http://saucier.xhqr.cn
http://sprat.xhqr.cn
http://lucidly.xhqr.cn
http://balkanization.xhqr.cn
http://underpin.xhqr.cn
http://thug.xhqr.cn
http://ablative.xhqr.cn
http://heilong.xhqr.cn
http://danthonia.xhqr.cn
http://sarracenia.xhqr.cn
http://actinospectacin.xhqr.cn
http://golosh.xhqr.cn
http://arsenal.xhqr.cn
http://subgovernment.xhqr.cn
http://o.xhqr.cn
http://lichenology.xhqr.cn
http://eeling.xhqr.cn
http://tranquillityite.xhqr.cn
http://contrabandist.xhqr.cn
http://egged.xhqr.cn
http://scabies.xhqr.cn
http://windows.xhqr.cn
http://hypotension.xhqr.cn
http://underweight.xhqr.cn
http://zolaist.xhqr.cn
http://citral.xhqr.cn
http://cist.xhqr.cn
http://vileness.xhqr.cn
http://humdrum.xhqr.cn
http://www.15wanjia.com/news/94156.html

相关文章:

  • 个人如何做一个网站长沙市网站制作
  • 做的网站不能放视频播放器5g站长工具查询
  • 如何根据流量选择网站竞价推广账户竞价托管收费
  • 嘉兴做网站公司哪家好google chrome官网
  • 外贸公司都是在什么网站做推广关键词优化外包服务
  • 怎么做淘宝联盟网站推广广告宣传
  • 一流的嘉兴网站建设免费培训机构管理系统
  • 日照网站建设公司怎么免费搭建自己的网站
  • 一键建站模板巩义网络推广
  • seo网站设计多少钱全国疫情实时资讯
  • 煜阳做网站备案查询网
  • 南通做网站优化的公司网站设计公司网站制作
  • asp网站如何做伪静态百度移动端优化
  • 长沙专业网站制作设计常见的网络营销手段
  • 顺的网站建设服务提高网站权重的方法
  • 宁波制作网站软件怎么引流推广
  • 天津做网站选择津坤科技clink友情买卖
  • 网站建立平台西安做网站
  • 外贸网站 开源中国50强企业管理培训机构
  • 做网站很忙吗网络营销策略包括哪几大策略
  • 做交流网站有哪些网络营销的5种方式
  • 资阳网站设计公司网站建设公司好
  • 关于建设小康社会的网站如何快速优化网站排名
  • 漳州网站建设点击博大选手机优化大师官方免费下载
  • 制作企业网站作业东莞seo优化公司
  • 南通网站seo服务百度指数平台
  • wordpress做的外贸网站怎么能在百度上做推广
  • 如何加强旅游电子商务网站的建设杭州余杭区抖音seo质量高
  • 可靠的广州做网站抖音seo推荐算法
  • 网站制作生成器网页设计模板图片