/images/avatar.jpg
杂七杂八的,随手记录。

A Close Look at a Spinlock – Embedded in Academia

本文为摘录(或转载),侵删,原文为: https://blog.regehr.org/archives/2173

自旋锁 (spinlock) 是多处理器操作系统提供的最基本的互斥原语。自旋锁需要保护当前 CPU 免受抢占(通常通过禁用中断,但我们会在本文中忽略这个方面),并且还需要防止其他核心同时访问临界区(通过使用原子内存操作)。正如其名称所示,尝试获取已锁定的自旋锁会简单地自旋:它们会消耗 CPU 时间:

Note about PO file in PostgreSQL

Table of Contents

本文为摘录(或转载),侵删,原文为: https://github.com/postgres/postgres/blob/master/doc/src/sgml/nls.sgml#L52

1 Concepts

The pairs of original (English) messages and their (possibly) translated equivalents are kept in message catalogs , one for each program (although related programs can share a message catalog) and for each target language. There are two file formats for message catalogs: The first is the PO file (for Portable Object), which is a plain text file with special syntax that translators edit. The second is the MO file (for Machine Object), which is a binary file generated from the respective PO file and is used while the internationalized program is run. Translators do not deal with MO files; in fact hardly anyone does.

how to avoid memory being swapped (locking memory pages)

本文为摘录(或转载),侵删,原文为: https://stackoverflow.com/questions/12520499/linux-how-to-lock-the-pages-of-a-process-in-memory

1 mlockall()

from manpage:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

mlockall() and munlockall()
    mlockall() locks all pages mapped into the address space of the  calling  process.   This  in‐
    cludes the pages of the code, data, and stack segment, as well as shared libraries, user space
    kernel data, shared memory, and memory-mapped files.  All mapped pages are  guaranteed  to  be
    resident  in  RAM  when the call returns successfully; the pages are guaranteed to stay in RAM
    until later unlocked.

    The flags argument is constructed as the bitwise OR of one or more of the following constants:

    MCL_CURRENT
           Lock all pages which are currently mapped into the address space of the process.

    MCL_FUTURE
           Lock all pages which will become mapped into the address space of the  process  in  the
           future.   These  could be, for instance, new pages required by a growing heap and stack
           as well as new memory-mapped files or shared memory regions.

    MCL_ONFAULT (since Linux 4.4)
           Used together with MCL_CURRENT, MCL_FUTURE, or both.  Mark all current  (with  MCL_CUR‐
           RENT)  or  future  (with  MCL_FUTURE)  mappings to lock pages when they are faulted in.
           When used with MCL_CURRENT, all present pages are locked, but mlockall() will not fault
           in non-present pages.  When used with MCL_FUTURE, all future mappings will be marked to
           lock pages when they are faulted in, but they will not be populated by  the  lock  when
           the mapping is created.  MCL_ONFAULT must be used with either MCL_CURRENT or MCL_FUTURE
           or both.

    If MCL_FUTURE has been specified, then a later  system  call  (e.g.,  mmap(2),  sbrk(2),  mal‐
    loc(3)), may fail if it would cause the number of locked bytes to exceed the permitted maximum
    (see below).  In the same circumstances, stack growth may likewise fail: the kernel will  deny
    stack expansion and deliver a SIGSEGV signal to the process.

munlockall() unlocks all pages mapped into the address space of the calling process.

2 how to do this after program started and program does not call mlockall() ?

Make a GDB command file that contains something like this:

LogIndex | PolarDB for PostgreSQL

本文为摘录(或转载),侵删,原文为: https://apsaradb.github.io/PolarDB-for-PostgreSQL/zh/theory/logindex.html

1 背景介绍

PolarDB 采用了共享存储一写多读架构,读写节点 RW 和多个只读节点 RO 共享同一份存储,读写节点可以读写共享存储中的数据;只读节点仅能各自通过回放日志,从共享存储中读取数据,而不能写入,只读节点 RO 通过内存同步来维护数据的一致性。此外,只读节点可同时对外提供服务用于实现读写分离与负载均衡,在读写节点异常 crash 时,可将只读节点提升为读写节点,保证集群的高可用。基本架构图如下所示:

PolarDB for PostgreSQL架构介绍

本文为摘录(或转载),侵删,原文为: https://help.aliyun.com/zh/polardb/polardb-for-postgresql/polardb-for-postgresql-architecture/?spm=a2c4g.11186623.0.0.2e3b5fb1p0L9je

PolarDB PostgreSQL 版是一款阿里云自主研发的企业级数据库产品,采用计算存储分离架构,兼容 PostgreSQL 与 Oracle。PolarDB PostgreSQL 版的存储与计算能力均可横向扩展,具有高可靠、高可用、弹性扩展等企业级数据库特性。同时,PolarDB PostgreSQL 版具有大规模并行计算能力,可以应对 OLTP 与 OLAP 混合负载。还具有时空、向量、搜索、图谱等多模创新特性,可以满足企业对数据处理日新月异的新需求。