-
Notifications
You must be signed in to change notification settings - Fork 16
Resolve issues #5 and #1: reduce number of collisions in the ptrack map #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
dd6fdc0
829f96c
3026be9
cf8e309
fbfba8c
ab17447
9c132a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
.deps | ||
*.so | ||
*.o | ||
ptrack--2.0.sql | ||
Dockerfile | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* ptrack/ptrack--2.1--2.2.sql */ | ||
|
||
-- Complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION ptrack UPDATE;" to load this file.\ quit | ||
|
||
CREATE FUNCTION ptrack_get_change_stat(start_lsn pg_lsn) | ||
RETURNS TABLE ( | ||
files bigint, | ||
pages bigint, | ||
"size, MB" numeric | ||
) AS | ||
$func$ | ||
DECLARE | ||
block_size bigint; | ||
BEGIN | ||
block_size := (SELECT setting FROM pg_settings WHERE name = 'block_size'); | ||
|
||
RETURN QUERY | ||
SELECT changed_files, | ||
changed_pages, | ||
block_size*changed_pages/(1024.0*1024) | ||
FROM | ||
(SELECT count(path) AS changed_files, | ||
sum( | ||
length(replace(right((pagemap)::text, -1)::varbit::text, '0', '')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Если таблицы 8TB, то вот эта строчка потребует выделение 1GB памяти для преобразования There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это очень грустно, что varbit не имеет функции countbits. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В любом случае, для ptrack_get_change_stat и ptrack_get_change_file_stat кажется нужно создать ptrack_get_pagecount (ну или другое название). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Таблицы же разбиты на сегменты по 1 ГБ дефолтно, а ptrack_get_pagemapset() выдаёт изначально битмапы per file/segment, то есть потребуется максимум в 1000 раз меньше памяти на каждое преобразование. Разве нет? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А ок. Я ещё не посмотрел ptrack_get_pagemapset() . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Слушай, но я бы всё равно поменял бы ptrack_get_pagemapset, добавив поле count в вывод. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Сделал |
||
) AS changed_pages | ||
FROM ptrack_get_pagemapset(start_lsn)) s; | ||
END | ||
$func$ LANGUAGE plpgsql; | ||
|
||
CREATE FUNCTION ptrack_get_change_file_stat(start_lsn pg_lsn) | ||
RETURNS TABLE ( | ||
file_path text, | ||
pages int, | ||
"size, MB" numeric | ||
) AS | ||
$func$ | ||
DECLARE | ||
block_size bigint; | ||
BEGIN | ||
block_size := (SELECT setting FROM pg_settings WHERE name = 'block_size'); | ||
|
||
RETURN QUERY | ||
SELECT s.path, | ||
changed_pages, | ||
block_size*changed_pages/(1024.0*1024) | ||
FROM | ||
(SELECT path, | ||
length(replace(right((pagemap)::text, -1)::varbit::text, '0', '')) | ||
AS changed_pages | ||
FROM ptrack_get_pagemapset(start_lsn)) s | ||
ORDER BY (changed_pages, s.path) DESC; | ||
END | ||
$func$ LANGUAGE plpgsql; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# ptrack extension | ||
comment = 'block-level incremental backup engine' | ||
default_version = '2.1' | ||
default_version = '2.2' | ||
module_pathname = '$libdir/ptrack' | ||
relocatable = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не могу найти, где делается unmap в этом случае?
При этом сразу после метки
ptrack_map_reinit
делаетсяdurable_unlink(ptrack_mmap_path)
.В итоге, этот файл повисает невидимкой в файловой системе, и в адрессном пространстве процесса повисает его mmap.
Наверное есть смысл позвать здесь
ptrackCleanFilesAndMap
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, похоже на то. Я сомневался в этом месте, но потом забыл и не разобрался до конца