PostgreSQL数据库动态共享内存管理器——Dynamic shared memory areas

这篇具有很好参考价值的文章主要介绍了PostgreSQL数据库动态共享内存管理器——Dynamic shared memory areas。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

dsm.c提供的功能允许创建后端进程间共享的共享内存段。DSA利用多个DSM段提供共享内存heap;DSA可以利用已经存在的共享内存(DSM段)也可以创建额外的DSM段。和系统heap使用指针不同的是,DSA提供伪指针,可以转换为backend-local指针,但是该伪指针可以在后端进程之间共享,可以用于构建共享数据结构。
每个DSA管理多个DSM段,可以向其中添加新段,不需要时detach它们。每个段包含多个4KB页,一个free page manager(用于跟踪空闲页的连续运行)以及一个页面映射page map(用于跟踪分配给每个页面的对象的来源)。分配超过8KB的空间请求通过通过选择一个段并在其空闲页管理器中查找连续的空闲页来处理。较小的分配请求使用选定大小的对象池来处理。每个池由多个16页(64KB)超级块组成,以与大型对象相同的方式分配。大型对象和新超级块的分配由单个LWLock进行串行化,但从预先存在的超级块分配小型对象时,每个池使用一个LWLock。目前,每个大小类有一个池,因此有一个锁。提高并发性的每核心池和减少由此产生的碎片的策略是未来研究的领域。每个超级块都用一个“span”来管理,它跟踪超级块的空闲列表。自由请求是通过查看页面映射来处理的,以查找分配地址的跨度,这样小对象就可以返回到适当的自由列表中,大对象页面可以直接返回到自由页面映射中。在分配时,用于选择段和超级块的简单启发式方法试图鼓励集中占用的内存,从而增加了整个超级块变为空并返回到空闲页管理器的可能性,而整个段变为空并且返回到操作系统的可能性。Each DSA area manages a set of DSM segments, adding new segments as required and detaching them when they are no longer needed. Each segment contains a number of 4KB pages, a free page manager for tracking consecutive runs of free pages, and a page map for tracking the source of objects allocated on each page. Allocation requests above 8KB are handled by choosing a segment and finding consecutive free pages in its free page manager. Allocation requests for smaller sizes are handled using pools of objects of a selection of sizes. Each pool consists of a number of 16 page (64KB) superblocks allocated in the same way as large objects. Allocation of large objects and new superblocks is serialized by a single LWLock, but allocation of small objects from pre-existing superblocks uses one LWLock per pool. Currently there is one pool, and therefore one lock, per size class. Per-core pools to increase concurrency and strategies for reducing the resulting fragmentation are areas for future research. Each superblock is managed with a ‘span’, which tracks the superblock’s freelist. Free requests are handled by looking in the page map to find which span an address was allocated from, so that small objects can be returned to the appropriate free list, and large object pages can be returned directly to the free page map. When allocating, simple heuristics for selecting segments and superblocks try to encourage occupied memory to be concentrated, increasing the likelihood that whole superblocks can become empty and be returned to the free page manager, and whole segments can become empty and be returned to the operating system.

dsa_create/dsa_create_in_place

dsa_create函数在新的一个DSM段中创建一个新的shared area。dsa_create_in_place函数在已经存在的共享内存空间上创建一个新的shared area。

dsa_area *dsa_create(int tranche_id){
	dsm_segment *segment = dsm_create(DSA_INITIAL_SEGMENT_SIZE, 0); /* Create the DSM segment that will hold the shared control object and the first segment of usable space. */	
	dsm_pin_segment(segment); /* All segments backing this area are pinned, so that DSA can explicitly control their lifetime (otherwise a newly created segment belonging to this area might be freed when the only backend that happens to have it mapped in ends, corrupting the area). */

	/* Create a new DSA area with the control object in this segment. */
	dsa_area   *area = create_internal(dsm_segment_address(segment), DSA_INITIAL_SEGMENT_SIZE, tranche_id, dsm_segment_handle(segment), segment);

	/* Clean up when the control segment detaches. */
	on_dsm_detach(segment, &dsa_on_dsm_detach_release_in_place, PointerGetDatum(dsm_segment_address(segment)));

	return area;
}
dsa_area *dsa_create_in_place(void *place, size_t size,int tranche_id, dsm_segment *segment){
	dsa_area   *area = create_internal(place, size, tranche_id, DSM_HANDLE_INVALID, NULL);

	/* Clean up when the control segment detaches, if a containing DSM segment was provided. */
	if (segment != NULL)
		on_dsm_detach(segment, &dsa_on_dsm_detach_release_in_place, PointerGetDatum(place));
	return area;
}

PostgreSQL数据库动态共享内存管理器——Dynamic shared memory areas,# Greenplum,数据库

dsa_attach/dsa_attach_in_place

dsa_allocate dsa_free文章来源地址https://www.toymoban.com/news/detail-607925.html

到了这里,关于PostgreSQL数据库动态共享内存管理器——Dynamic shared memory areas的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 新增PostgreSQL数据库管理功能,1Panel开源面板v1.9.3发布

    2024年1月15日,现代化、开源的Linux服务器运维管理面板1Panel正式发布v1.9.3版本。 在这一版本中,1Panel新增了PostgreSQL数据库管理功能,并且支持设置PHP运行环境扩展模版。此外,我们进行了30多项功能更新和问题修复。1Panel应用商店新增了3款应用,并且更新了22款应用。感谢社

    2024年01月18日
    浏览(40)
  • 图数据库 NebulaGraph 的内存管理实践之 Memory Tracker

    数据库的内存管理是数据库内核设计中的重要模块,内存的可度量、可管控是数据库稳定性的重要保障。同样的,内存管理对图数据库 NebulaGraph 也至关重要。 图数据库的多度关联查询特性,往往使图数据库执行层对内存的需求量巨大。本文主要介绍 NebulaGraph v3.4 版本中引入

    2024年02月05日
    浏览(24)
  • postgresql|数据库|角色(用户)管理工作---授权和去权以及usage和select两种权限的区别

    postgresql做为一个比较复杂的关系型的重型数据库,不管是安装部署,还是后期的运行维护,都还是有比较多的细节问题需要引起关注。 例如,用户权限的合理分配,那么,什么是权限的合理分配呢? 自然是权限的最小化原则,也就是说每个用户能够完成其权限范围内的工作

    2024年02月13日
    浏览(32)
  • postgresql|数据库|MySQL数据库向postgresql数据库迁移的工具pgloader的部署和初步使用

    MySQL数据库和postgresql数据库之间的差异并不多,这里的差异指的是对SQL语言的支持两者并不大,但底层的东西差异是非常多的,例如,MySQL的innodb引擎概念,数据库用户管理,这些和postgresql相比是完全不同的(MySQL用户就是用户,没有角色,postgresql有用户,有角色,但差异不

    2024年02月14日
    浏览(69)
  • 【数据库】什么是 PostgreSQL?开源数据库系统

    PostgreSQL 是一个开源的对象关系数据库系统,本文,我们将讨论 PostgreSQL、它的用途和好处。 PostgreSQL 是由 PostgreSQL Global Development Group 开发的高级 开源关系数据库管理系统(RDBMS) 。它作为 POSTGRES 项目的一部分于 1986 年在加州大学伯克利分校启动,它最初于 1996 年 7 月 8 日发布

    2023年04月08日
    浏览(35)
  • postgresql数据库定时备份到远程数据库

    1.老规矩,服务器目录结构: conf目录无内容 profile: 其中: 最后一行 export PGPASSWORD=‘root’ 是需要备份的数据库的密码,因为直接用 pg_dump 命令备份需要输入密码交互,而我们需要达到自动备份,所以借助这种方式不需要输入密码 docker-compose.yml: 启动容器: 然后再data目录下面

    2024年02月09日
    浏览(37)
  • PostgreSQL Linux操作PostgreSQL数据库

    PostgreSQL教程 菜鸟教程:https://www.runoob.com/postgresql/postgresql-tutorial.html 登录PG数据库:psql -U 用户名(U需要大写) 登录PG数据库(指定主机、端口,并进入指定数据库): psql -U 用户名 -h 127.0.0.1 -p 5432 -d 数据库名 -U 登录的用户名 -h 连接的主机(默认127.0.0.1,可替换成远程主机

    2024年02月11日
    浏览(48)
  • [运维|数据库] docker postgresql数据库环境变量配置

    要配置Docker中的PostgreSQL数据库的环境变量,可以使用以下方法: 使用Docker命令行: 将 用户名 , 密码 , 数据库名 替换为你想要设置的实际值。这将创建一个名为 mypostgres 的容器,并将 PostgreSQL 的用户名、密码和数据库名设置为指定的值。 -p 5432:5432 指定了容器内部和主机之间

    2024年02月09日
    浏览(51)
  • 数据库新闻速递 -- POSTGRESQL 正在蚕食数据库市场 (翻译)

    开头还是介绍一下群,如果感兴趣polardb ,mongodb ,mysql ,postgresql ,redis 等有问题,有需求都可以加群群内有各大数据库行业大咖,CTO,可以解决你的问题。加群请加 liuaustin3微信号 ,在新加的朋友会分到3群(共1140人左右 1 + 2 + 3) 尽管NoSQL数据库继续蓬勃发展,但关系型数据库仍

    2024年02月13日
    浏览(48)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包