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

refactor!(shwap/store): decouple Q1Q4 and ODS files #3643

Merged
merged 8 commits into from
Aug 14, 2024

Conversation

Wondertan
Copy link
Member

@Wondertan Wondertan commented Aug 11, 2024

The main goal of this PR is to decouple Q1Q4 and ODS files physically, so now there are two files .ods and .q4. This is needed to fix and unblock trimming in #3620. Besides, this PR ends up shaving off another ~27% of times it take for Put.

This PR is split into several commits that are independently reviewable and should be merged as so.

TODO:

  • Doc new funcs
  • Lazy open

@Wondertan
Copy link
Member Author

Wondertan commented Aug 11, 2024

One more optimization to do here is to open files lazily. However, that's not trivial, as we detect whether file is empty or not only while opening it and we can't open empty file lazily with ease.

Options:

  • Store the empty file, instead of detecting it and returning the in-mem version.
  • Return ErrEmptyFile when Accessor methods ask to open it lazily.
  • Detect ErrEmptyFile and route all the request to the empty accessor.
  • Always open ODS while keep Q4 only lazy.

I am going with the last option. It's simple and optimizes for the more common case: ODS usage without Q4. The less common but still possible case where Q4 is used without ODS is not covered, but its less common(only for sampling) and might not worth additional complexity to handle it.

@Wondertan Wondertan force-pushed the shwap-decouple-files branch 10 times, most recently from f08245d to eb86046 Compare August 14, 2024 09:31
This PR simplifies and cleans row/col read logic in preparation for ODS and Q1Q4 files decoupling.
Mainly, it removes quadrant offset from calculations
@Wondertan Wondertan force-pushed the shwap-decouple-files branch from 4746808 to c59d96a Compare August 14, 2024 10:52
store/file/ods.go Outdated Show resolved Hide resolved
store/file/q1q4_file.go Outdated Show resolved Hide resolved
store/file/q1q4_file.go Outdated Show resolved Hide resolved
store/file/q1q4_file.go Outdated Show resolved Hide resolved
store/store.go Outdated Show resolved Hide resolved
store/file/ods_q4_test.go Outdated Show resolved Hide resolved
store/file/q4.go Outdated Show resolved Hide resolved
store/file/q4.go Show resolved Hide resolved
store/store.go Show resolved Hide resolved
store/store.go Outdated Show resolved Hide resolved
Makes ODS and Q4 distinct physical files with different extentions. Both files are hardlinked separately
@Wondertan Wondertan force-pushed the shwap-decouple-files branch from c59d96a to a8c83e7 Compare August 14, 2024 16:42
Treating empty file as an empty block can create issues for node operators and is a foot gun.
To avoid this, we make empty file a proper file.

Besides, we refresh empty file on start to ensure its consistent with canonical empty file kept in mem.
This yields additional 27% improvement on the Put operation for the store.
The discrepancy seems to grow with the block size.
@Wondertan Wondertan force-pushed the shwap-decouple-files branch from a8c83e7 to 4ee148f Compare August 14, 2024 17:02
@Wondertan Wondertan merged commit 9449437 into shwap Aug 14, 2024
15 of 18 checks passed
@Wondertan Wondertan deleted the shwap-decouple-files branch August 14, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:refactor Attached to refactoring PRs shwap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants