Skip to content

Conversation

@kungasc
Copy link
Contributor

@kungasc kungasc commented Oct 3, 2024

Changelog entry

...

Changelog category

  • Not for changelog (changelog entry is not required)

Additional information

Implementation is based on https://github.com/cockroachdb/pebble/blob/master/internal/cache/clockpro.go code

@github-actions
Copy link

github-actions bot commented Oct 3, 2024

2024-10-03 15:43:03 UTC Pre-commit check linux-x86_64-release-asan for cef4c25 has started.
2024-10-03 15:43:42 UTC Artifacts will be uploaded here
2024-10-03 15:46:43 UTC ya make is running...
🟡 2024-10-03 15:50:16 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
485 481 0 4 0 0

🟢 2024-10-03 15:50:24 UTC Build successful.

@kungasc kungasc changed the title init files Shared Cache Clock-PRO implementation Oct 3, 2024
@kungasc kungasc changed the title Shared Cache Clock-PRO implementation Shared Cache Clock-Pro implementation Oct 3, 2024
@kungasc kungasc mentioned this pull request Oct 3, 2024
33 tasks
@kungasc kungasc self-assigned this Oct 3, 2024
@github-actions
Copy link

github-actions bot commented Oct 3, 2024

2024-10-03 15:45:50 UTC Pre-commit check linux-x86_64-relwithdebinfo for cef4c25 has started.
2024-10-03 15:46:01 UTC Artifacts will be uploaded here
2024-10-03 15:48:22 UTC ya make is running...
🟡 2024-10-03 15:50:58 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
485 481 0 4 0 0

2024-10-03 15:51:07 UTC ya make is running... (failed tests rerun, try 2)
🟡 2024-10-03 15:51:42 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
4 (only retried tests) 0 0 4 0 0

2024-10-03 15:51:50 UTC ya make is running... (failed tests rerun, try 3)
🔴 2024-10-03 15:52:21 UTC Some tests failed, follow the links below.

Test history | Ya make output | Test bloat | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
4 (only retried tests) 0 0 4 0 0

🟢 2024-10-03 15:52:27 UTC Build successful.

@github-actions
Copy link

github-actions bot commented Oct 4, 2024

2024-10-04 16:00:33 UTC Pre-commit check linux-x86_64-relwithdebinfo for 883fc23 has started.
2024-10-04 16:00:43 UTC Artifacts will be uploaded here
2024-10-04 16:03:07 UTC ya make is running...
🟡 2024-10-04 16:07:33 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
484 482 0 2 0 0

2024-10-04 16:07:43 UTC ya make is running... (failed tests rerun, try 2)
🟡 2024-10-04 16:08:17 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
2 (only retried tests) 0 0 2 0 0

2024-10-04 16:08:30 UTC ya make is running... (failed tests rerun, try 3)
🔴 2024-10-04 16:09:12 UTC Some tests failed, follow the links below.

Test history | Ya make output | Test bloat | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
2 (only retried tests) 0 0 2 0 0

🟢 2024-10-04 16:09:18 UTC Build successful.

@github-actions
Copy link

github-actions bot commented Oct 4, 2024

2024-10-04 16:00:33 UTC Pre-commit check linux-x86_64-release-asan for 883fc23 has started.
2024-10-04 16:00:44 UTC Artifacts will be uploaded here
2024-10-04 16:03:05 UTC ya make is running...
🟡 2024-10-04 16:08:05 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
484 482 0 2 0 0

🟢 2024-10-04 16:08:13 UTC Build successful.

@github-actions
Copy link

github-actions bot commented Oct 7, 2024

2024-10-07 14:54:04 UTC Pre-commit check linux-x86_64-release-asan for 79c508a has started.
2024-10-07 14:54:40 UTC Artifacts will be uploaded here
2024-10-07 14:57:51 UTC ya make is running...
🟡 2024-10-07 15:01:30 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
486 483 0 3 0 0

🟢 2024-10-07 15:01:39 UTC Build successful.

@github-actions
Copy link

github-actions bot commented Oct 7, 2024

2024-10-07 14:56:39 UTC Pre-commit check linux-x86_64-relwithdebinfo for 79c508a has started.
2024-10-07 14:56:51 UTC Artifacts will be uploaded here
2024-10-07 14:59:13 UTC ya make is running...
🟡 2024-10-07 15:01:48 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
486 483 0 3 0 0

2024-10-07 15:01:57 UTC ya make is running... (failed tests rerun, try 2)
🟡 2024-10-07 15:02:31 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
3 (only retried tests) 0 0 3 0 0

2024-10-07 15:02:44 UTC ya make is running... (failed tests rerun, try 3)
🔴 2024-10-07 15:03:21 UTC Some tests failed, follow the links below.

Test history | Ya make output | Test bloat | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
3 (only retried tests) 0 0 3 0 0

🟢 2024-10-07 15:03:27 UTC Build successful.

@github-actions
Copy link

github-actions bot commented Oct 8, 2024

2024-10-08 16:44:02 UTC Pre-commit check linux-x86_64-release-asan for 7ea8730 has started.
2024-10-08 16:44:32 UTC Artifacts will be uploaded here
2024-10-08 16:47:25 UTC ya make is running...
🟢 2024-10-08 16:50:48 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
487 487 0 0 0 0

🟢 2024-10-08 16:50:56 UTC Build successful.

@github-actions
Copy link

github-actions bot commented Oct 8, 2024

2024-10-08 16:47:00 UTC Pre-commit check linux-x86_64-relwithdebinfo for 7ea8730 has started.
2024-10-08 16:47:10 UTC Artifacts will be uploaded here
2024-10-08 16:49:35 UTC ya make is running...
🟢 2024-10-08 16:51:58 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
487 487 0 0 0 0

🟢 2024-10-08 16:52:06 UTC Build successful.

@github-actions
Copy link

github-actions bot commented Oct 9, 2024

2024-10-09 20:05:40 UTC Pre-commit check linux-x86_64-relwithdebinfo for 58a68bb has started.
2024-10-09 20:05:51 UTC Artifacts will be uploaded here
2024-10-09 20:09:09 UTC ya make is running...
🔴 2024-10-09 20:29:32 UTC Build failed, see the logs.

@github-actions
Copy link

github-actions bot commented Oct 9, 2024

2024-10-09 20:05:43 UTC Pre-commit check linux-x86_64-release-asan for 58a68bb has started.
2024-10-09 20:05:53 UTC Artifacts will be uploaded here
2024-10-09 20:09:02 UTC ya make is running...
🔴 2024-10-09 20:33:19 UTC Build failed, see the logs.

@kungasc kungasc force-pushed the cache-cache-clock-pro branch from a878a3b to 3924cdf Compare October 10, 2024 08:29
@github-actions
Copy link

github-actions bot commented Oct 10, 2024

2024-10-10 08:32:40 UTC Pre-commit check linux-x86_64-release-asan for 9395ade has started.
2024-10-10 08:32:51 UTC Artifacts will be uploaded here
2024-10-10 08:36:01 UTC ya make is running...
🟡 2024-10-10 10:19:29 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
11782 11521 0 86 65 110

🟢 2024-10-10 10:20:30 UTC Build successful.
🟡 2024-10-10 10:21:02 UTC ydbd size 5.7 GiB changed* by +127.2 KiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 1738d8c merge: 9395ade diff diff %
ydbd size 6 103 922 760 Bytes 6 104 053 024 Bytes +127.2 KiB +0.002%
ydbd stripped size 1 520 991 984 Bytes 1 521 027 824 Bytes +35.0 KiB +0.002%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

@github-actions
Copy link

github-actions bot commented Oct 10, 2024

2024-10-10 08:32:40 UTC Pre-commit check linux-x86_64-relwithdebinfo for 9395ade has started.
2024-10-10 08:32:51 UTC Artifacts will be uploaded here
2024-10-10 08:36:07 UTC ya make is running...
🟡 2024-10-10 09:54:12 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
41493 35916 0 3 5469 105

2024-10-10 09:57:42 UTC ya make is running... (failed tests rerun, try 2)
🟢 2024-10-10 10:19:15 UTC Tests successful.

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
107 (only retried tests) 5 0 0 1 101

🟢 2024-10-10 10:19:22 UTC Build successful.
🟢 2024-10-10 10:19:42 UTC ydbd size 2.8 GiB changed* by +84.9 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 1738d8c merge: 9395ade diff diff %
ydbd size 3 012 071 792 Bytes 3 012 158 688 Bytes +84.9 KiB +0.003%
ydbd stripped size 477 602 296 Bytes 477 618 680 Bytes +16.0 KiB +0.003%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

, ColdTarget(limit)
{}

TIntrusiveList<TPage> EvictNext() override {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переделал чтобы тут возвращался список, ибо кажется что рекурсия RunHandCold-> RunHandTest -> RunHandCold может иногда и по 2 страницы эвиктить

@kungasc kungasc marked this pull request as ready for review October 10, 2024 12:36
@kungasc kungasc requested a review from snaury October 10, 2024 12:36

SizeTest += entry->Size;

while (SizeTest > Limit) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А разве не нужно перед этим циклом сделать Advance(HandCold)? Ведь к этому моменту страница уже в Test, а не в Cold.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я тут честно не знаю, списывал отсюда

https://github.com/cockroachdb/pebble/blob/0501caf7b65a9202b901555e42e77f2d47f47f43/internal/cache/clockpro.go#L554

До конца не понял всех рекурсивных вызывов с додвиганиями стрелок, старался просто переписать 1 в 1, чтобы случайно не ухудшить эффективность алгоритма делая что-то иначе

Оставлю тудушку на подумать пока

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По-хорошему тут и рекурсию бы убрать, и сделать просто цикл

}
}

Advance(HandCold);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что-то я не понимаю алгоритм. Страница может попасть либо в Hot либо в Test, но при этом я не понимаю каким образом на неё станет указывать правильный HandHot или HandTest. Не говоря уже о том, что если страница не IsCold, то при продвижении HandCold всё странным образом смешивается. Видимо нужно подробнее читать алгоритм, но есть ощущение чего-то очень бажного.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Опишу как я это понял.

Есть три типа страниц:

  • 'Cold resident' — страница с данными, холодная
  • 'Hot' — страница с данными, горячая
  • 'Cold non-resident' (='Test') — страница без данных, которую выгрузили

Дальше все страницы выписываются в кольцо, в котором мы лимитируем число страниц каждого вида.

Страниц 'Cold non-resident' столько, чтобы они вмещались в лимит кэша (но они пустые).

Страницы 'Cold resident' и 'Hot' в сумме вмещаются в лимит кэша.

Дальше по этому кольцу мы возим 3 стрелки:

  • HandTest — следующая страница которую будем удалять из 'Cold non-resident'
  • HandCold — следующая страница которую будем пытаться удалить из 'Cold resident'
  • HandHot — следующая страница которую будем пытаться удалить из 'Hot'

Иногда страница в кольце перемещается (например, при трансформации 'Cold non-resident' --> 'Hot' мы её перемещаем перед HandHot, видимо чтобы она подольше пожила), а иногда остаются где были (например, при трансформации 'Cold resident' --> 'Cold non-resident' страница остаётся где и была).

И видимо, (но явно этого нигде не написано ни в статье, ни в коде), эти три стрелки ездят друг за другом, то есть никогда не пересекаются, и от HandCold до HandHot страниц 'Cold non-resident' нет.

@kungasc kungasc requested a review from snaury October 14, 2024 10:20
@github-actions
Copy link

github-actions bot commented Oct 14, 2024

2024-10-14 10:22:21 UTC Pre-commit check linux-x86_64-release-asan for 6653e91 has started.
2024-10-14 10:22:32 UTC Artifacts will be uploaded here
2024-10-14 10:25:40 UTC ya make is running...
🟡 2024-10-14 12:12:08 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
11794 11427 0 54 273 40

🟢 2024-10-14 12:13:08 UTC Build successful.
🟡 2024-10-14 12:13:39 UTC ydbd size 5.7 GiB changed* by +118.2 KiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 2414fb7 merge: 6653e91 diff diff %
ydbd size 6 095 972 288 Bytes 6 096 093 296 Bytes +118.2 KiB +0.002%
ydbd stripped size 1 520 294 768 Bytes 1 520 330 224 Bytes +34.6 KiB +0.002%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

@github-actions
Copy link

github-actions bot commented Oct 14, 2024

2024-10-14 10:22:48 UTC Pre-commit check linux-x86_64-relwithdebinfo for 6653e91 has started.
2024-10-14 10:22:59 UTC Artifacts will be uploaded here
2024-10-14 10:26:11 UTC ya make is running...
🟡 2024-10-14 11:49:50 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
41548 35962 0 2 5471 113

2024-10-14 11:53:35 UTC ya make is running... (failed tests rerun, try 2)
🟢 2024-10-14 12:05:10 UTC Tests successful.

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
107 (only retried tests) 7 0 0 0 100

🟢 2024-10-14 12:05:18 UTC Build successful.
🟢 2024-10-14 12:05:38 UTC ydbd size 2.8 GiB changed* by +75.0 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 2414fb7 merge: 6653e91 diff diff %
ydbd size 3 009 100 320 Bytes 3 009 177 168 Bytes +75.0 KiB +0.003%
ydbd stripped size 477 343 736 Bytes 477 355 960 Bytes +11.9 KiB +0.003%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

@kungasc kungasc merged commit fe41b68 into ydb-platform:main Oct 15, 2024
10 checks passed
nikvas0 pushed a commit to nikvas0/ydb that referenced this pull request Oct 15, 2024
kungasc added a commit to kungasc/ydb that referenced this pull request Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants