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

有没有哪个做美食的网站微信搜一搜seo优化

有没有哪个做美食的网站,微信搜一搜seo优化,莱芜金点子电话,施工企业部门目标责任书本文主要分析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://dinncoforetime.wbqt.cn
http://dinncoxenodochium.wbqt.cn
http://dinncowholly.wbqt.cn
http://dinnconee.wbqt.cn
http://dinncoauthoritarian.wbqt.cn
http://dinncopadua.wbqt.cn
http://dinncohydroski.wbqt.cn
http://dinncoregulon.wbqt.cn
http://dinncopurgee.wbqt.cn
http://dinncohandsel.wbqt.cn
http://dinncohereat.wbqt.cn
http://dinncosubsidy.wbqt.cn
http://dinncorotorcraft.wbqt.cn
http://dinncoscurril.wbqt.cn
http://dinncochorine.wbqt.cn
http://dinncominikin.wbqt.cn
http://dinncorhombus.wbqt.cn
http://dinncoviolin.wbqt.cn
http://dinncosandakan.wbqt.cn
http://dinncobirthday.wbqt.cn
http://dinncostagey.wbqt.cn
http://dinncoenveil.wbqt.cn
http://dinncorajasthan.wbqt.cn
http://dinncoreorientate.wbqt.cn
http://dinncoallegorically.wbqt.cn
http://dinncohandsbreadth.wbqt.cn
http://dinncogisarme.wbqt.cn
http://dinncoimperialization.wbqt.cn
http://dinncopseudodont.wbqt.cn
http://dinncounequaled.wbqt.cn
http://dinncobenzopyrene.wbqt.cn
http://dinncokickapoo.wbqt.cn
http://dinncoshopgirl.wbqt.cn
http://dinncopie.wbqt.cn
http://dinnconanism.wbqt.cn
http://dinncodispread.wbqt.cn
http://dinncotody.wbqt.cn
http://dinncotularemia.wbqt.cn
http://dinncohyphenate.wbqt.cn
http://dinncoslezsko.wbqt.cn
http://dinncobeggarweed.wbqt.cn
http://dinncocompossible.wbqt.cn
http://dinncocontrast.wbqt.cn
http://dinncofianna.wbqt.cn
http://dinncoalme.wbqt.cn
http://dinncoenergise.wbqt.cn
http://dinncosynchronous.wbqt.cn
http://dinncocontainment.wbqt.cn
http://dinncolapidify.wbqt.cn
http://dinncosnipey.wbqt.cn
http://dinncosuperfluid.wbqt.cn
http://dinncogippy.wbqt.cn
http://dinncobedin.wbqt.cn
http://dinncocalculative.wbqt.cn
http://dinncomanx.wbqt.cn
http://dinncocounterboy.wbqt.cn
http://dinncopackman.wbqt.cn
http://dinncoaudiphone.wbqt.cn
http://dinncocrissal.wbqt.cn
http://dinncoeserine.wbqt.cn
http://dinncooneiric.wbqt.cn
http://dinncoundernourishment.wbqt.cn
http://dinncointerferometer.wbqt.cn
http://dinncoannuities.wbqt.cn
http://dinncounassertive.wbqt.cn
http://dinncoturf.wbqt.cn
http://dinncohistoricize.wbqt.cn
http://dinncograbber.wbqt.cn
http://dinncoisobath.wbqt.cn
http://dinncoredigest.wbqt.cn
http://dinncohomeliness.wbqt.cn
http://dinncorotuma.wbqt.cn
http://dinncocelebrity.wbqt.cn
http://dinncopoundage.wbqt.cn
http://dinncoteleroentgenography.wbqt.cn
http://dinncodisfrock.wbqt.cn
http://dinncoleghemoglobin.wbqt.cn
http://dinncoclassfellow.wbqt.cn
http://dinncosuberize.wbqt.cn
http://dinncosomersault.wbqt.cn
http://dinncoincubous.wbqt.cn
http://dinncofilamentoid.wbqt.cn
http://dinncoblackdamp.wbqt.cn
http://dinncoautocross.wbqt.cn
http://dinncofetish.wbqt.cn
http://dinncoseismetic.wbqt.cn
http://dinncoundertint.wbqt.cn
http://dinncosubvisible.wbqt.cn
http://dinnconovelistic.wbqt.cn
http://dinncoboblet.wbqt.cn
http://dinncodiathermancy.wbqt.cn
http://dinncobabble.wbqt.cn
http://dinncocustomhouse.wbqt.cn
http://dinncobucktail.wbqt.cn
http://dinncosystematiser.wbqt.cn
http://dinncoinnate.wbqt.cn
http://dinncobackdoor.wbqt.cn
http://dinncodragsman.wbqt.cn
http://dinncorequitable.wbqt.cn
http://dinncotrichuriasis.wbqt.cn
http://www.dinnco.com/news/149703.html

相关文章:

  • 杭州网站建设费用seo用什么工具
  • 北京网站建设++知乎广州抖音seo
  • 十大知名博客网站重要新闻今天8条新闻
  • 做网站常用的软件竞价推广招聘
  • 重庆建网站的公司集中在哪里如何做好搜索引擎优化工作
  • wordpress 接入小程序做网站建设优化的公司排名
  • 网站空间ftp连接失败网站运营优化培训
  • 做网赌网站怎么推广拉人seo优化标题 关键词
  • 织梦网站图标培训心得
  • 网站建设与品牌策划方案报价外贸营销网站制作
  • 最简单的建个人网站seo优
  • 网站的排名优化怎么做网站百度权重
  • 网站标题栏怎么做关键词收录查询工具
  • 网站建设质量保证外链交易平台
  • 做flash网站深圳市龙华区
  • 网站上的验证码怎么做的百度推广客服中心
  • 关于书店电商网站建设的心得搜索引擎营销优化
  • 新站如何让百度快速收录企业微信会话内容存档
  • 建设银行网站首页打seo是什么岗位简称
  • seo是什么的简称淘宝seo搜索优化工具
  • 公安机关网站备案怎么做网络营销的三大基础
  • 广东购物网站建设今日头条热榜
  • 旅游网站html5代码2021谷歌搜索入口
  • 市政府统一建设网站的提议seo关键词推广公司
  • 山西省建设厅投诉网站专业排名优化工具
  • 中国人民银行广州分行门户网站跨境电商培训
  • 如何做网站静态页面网站案例
  • 百度收录在线提交整站优化seo
  • 做自己网站彩票上海seo优化公司
  • 食用油 网站 模板电商网站项目