Skip to content
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

feat(pageserver): separate sparse and dense keyspace #7503

Merged
merged 10 commits into from
Apr 30, 2024
Merged

Conversation

skyzh
Copy link
Member

@skyzh skyzh commented Apr 24, 2024

Problem

extracted (and tested) from #7468, part of #7462.

The current codebase assumes the keyspace is dense -- which means that if we have a keyspace of 0x00-0x100, we assume every key (e.g., 0x00, 0x01, 0x02, ...) exists in the storage engine. However, the assumption does not hold any more in metadata keyspace. The metadata keyspace is sparse. It is impossible to do per-key check.

Ideally, we should not have the assumption of dense keyspace at all, but this would incur a lot of refactors. Therefore, we split the keyspaces we have to dense/sparse and handle them differently in the code for now. At some point in the future, we should assume all keyspaces are sparse.

Summary of changes

  • Split collect_keyspace to return dense+sparse keyspace.
  • Do not allow generating image layers for sparse keyspace (for now -- will fix this next week, we need image layers anyways).
  • Generate delta layers for sparse keyspace.
  • This pull request includes part of chore(pageserver): shrink aux keyspace to 0x60-0x7F #7502.

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.
  • Do we need to implement analytics? if so did you add the relevant metrics to the dashboard?
  • If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section.

Checklist before merging

  • Do not forget to reformat commit message to not include the above checklist

@skyzh skyzh requested a review from a team as a code owner April 24, 2024 16:45
@skyzh skyzh requested a review from problame April 24, 2024 16:45
@skyzh skyzh force-pushed the skyzh/sparse-keyspace branch 3 times, most recently from 0345242 to affc2c1 Compare April 24, 2024 16:49
Copy link

github-actions bot commented Apr 24, 2024

2850 tests run: 2729 passed, 0 failed, 121 skipped (full report)


Flaky tests (2)

Postgres 15

  • test_partial_evict_tenant[relative_spare]: release
  • test_vm_bit_clear_on_heap_lock: debug

Code coverage* (full report)

  • functions: 28.2% (6583 of 23352 functions)
  • lines: 47.0% (46825 of 99721 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
32b41bd at 2024-04-29T19:01:40.383Z :recycle:

@skyzh skyzh force-pushed the skyzh/sparse-keyspace branch from 2b29272 to db31d65 Compare April 24, 2024 18:18
libs/pageserver_api/src/key.rs Outdated Show resolved Hide resolved
libs/pageserver_api/src/key.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/storage_layer/inmemory_layer.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline/compaction.rs Outdated Show resolved Hide resolved
@skyzh skyzh force-pushed the skyzh/sparse-keyspace branch from 804ea39 to bbae27b Compare April 24, 2024 19:36
@skyzh skyzh changed the base branch from main to skyzh/shrink-encoding April 24, 2024 19:37
@skyzh skyzh requested review from arpad-m and VladLazar April 24, 2024 19:37
Base automatically changed from skyzh/shrink-encoding to main April 26, 2024 17:35
@skyzh skyzh force-pushed the skyzh/sparse-keyspace branch 2 times, most recently from 64f857a to 52f1ba7 Compare April 26, 2024 17:41
@skyzh skyzh changed the base branch from main to skyzh/btreemap-inmem-layer April 26, 2024 17:42
@skyzh skyzh force-pushed the skyzh/sparse-keyspace branch from bf13008 to 848c35f Compare April 26, 2024 17:43
pageserver/src/http/routes.rs Outdated Show resolved Hide resolved
@jcsp
Copy link
Collaborator

jcsp commented Apr 26, 2024

Generally LGTM, I like the concept of using distinct KeySpaces for now.

In an earlier iteration of #6778 , I attempted to replace the inner Range<> type of KeySpace with something smarter that could represent the sparseness of sharding, but it was a rather painful diff, so makes sense that this PR also leaves that existing "dense KeySpace" type as-is.

Ideally, we should not have the assumption of dense keyspace at all

Agree.

@skyzh skyzh mentioned this pull request Apr 29, 2024
24 tasks
@skyzh skyzh force-pushed the skyzh/btreemap-inmem-layer branch from 41e043d to e401025 Compare April 29, 2024 16:34
@skyzh skyzh force-pushed the skyzh/sparse-keyspace branch 2 times, most recently from 60075ff to 6d97a87 Compare April 29, 2024 17:03
Base automatically changed from skyzh/btreemap-inmem-layer to main April 29, 2024 17:16
skyzh added 5 commits April 29, 2024 13:22
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
skyzh added 4 commits April 29, 2024 13:22
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
@skyzh skyzh force-pushed the skyzh/sparse-keyspace branch from 6d97a87 to 01b24f3 Compare April 29, 2024 17:23
@skyzh skyzh requested a review from jcsp April 29, 2024 18:22
@skyzh
Copy link
Member Author

skyzh commented Apr 29, 2024

resolved merge conflicts with main, ready for review

@skyzh skyzh merged commit 45c625f into main Apr 30, 2024
52 of 53 checks passed
@skyzh skyzh deleted the skyzh/sparse-keyspace branch April 30, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants