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

added support for explicit compaction #111

Merged
merged 25 commits into from
Feb 7, 2024
Merged

Conversation

jmalicevic
Copy link
Contributor

Adds an API for explicit compaction for different DB backends.

badger and bolt do not support this, hence the function returns nil.

Addresses partially cometbft/cometbft#49

@jmalicevic jmalicevic added enhancement New feature or request wip Work in progress labels Jan 5, 2024
@jmalicevic jmalicevic self-assigned this Jan 5, 2024
@jmalicevic jmalicevic changed the title Added compaction to bolt and badger added support for explicit compaction Jan 5, 2024
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

looking good so far 👍

Copy link

codecov bot commented Jan 29, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (fb4f703) 76.80% compared to head (0876df8) 77.19%.
Report is 2 commits behind head on main.

❗ Current head 0876df8 differs from pull request most recent head 6c8b95e. Consider uploading reports for the commit 6c8b95e to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
+ Coverage   76.80%   77.19%   +0.38%     
==========================================
  Files          23       23              
  Lines        2048     2109      +61     
==========================================
+ Hits         1573     1628      +55     
- Misses        403      407       +4     
- Partials       72       74       +2     
Files Coverage Δ
badger_db.go 88.10% <100.00%> (+0.33%) ⬆️
boltdb.go 58.59% <100.00%> (+1.33%) ⬆️
boltdb_batch.go 83.33% <100.00%> (+0.64%) ⬆️
cleveldb.go 71.85% <100.00%> (+0.85%) ⬆️
cleveldb_batch.go 83.01% <100.00%> (+0.66%) ⬆️
goleveldb_batch.go 93.61% <100.00%> (+0.28%) ⬆️
memdb.go 70.43% <100.00%> (+0.79%) ⬆️
memdb_batch.go 95.91% <100.00%> (+0.17%) ⬆️
prefixdb.go 70.74% <100.00%> (+0.40%) ⬆️
prefixdb_batch.go 100.00% <100.00%> (ø)
... and 4 more
Files Coverage Δ
badger_db.go 88.10% <100.00%> (+0.33%) ⬆️
boltdb.go 58.59% <100.00%> (+1.33%) ⬆️
boltdb_batch.go 83.33% <100.00%> (+0.64%) ⬆️
cleveldb.go 71.85% <100.00%> (+0.85%) ⬆️
cleveldb_batch.go 83.01% <100.00%> (+0.66%) ⬆️
goleveldb_batch.go 93.61% <100.00%> (+0.28%) ⬆️
memdb.go 70.43% <100.00%> (+0.79%) ⬆️
memdb_batch.go 95.91% <100.00%> (+0.17%) ⬆️
prefixdb.go 70.74% <100.00%> (+0.40%) ⬆️
prefixdb_batch.go 100.00% <100.00%> (ø)
... and 4 more

@jmalicevic jmalicevic marked this pull request as ready for review January 30, 2024 13:41
@jmalicevic jmalicevic requested a review from a team as a code owner January 30, 2024 13:41
@adizere adizere added this to the 2024-Q1 milestone Jan 30, 2024
Copy link
Member

@adizere adizere left a comment

Choose a reason for hiding this comment

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

left a couple of nit & suggestions

backend_test.go Outdated Show resolved Hide resolved
cleveldb.go Outdated Show resolved Hide resolved
memdb.go Show resolved Hide resolved
pebble.go Outdated Show resolved Hide resolved
prefixdb_batch.go Outdated Show resolved Hide resolved
Co-authored-by: Adi Seredinschi <a@seredinschi.net>
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

👍

backend_test.go Show resolved Hide resolved
backend_test.go Outdated Show resolved Hide resolved
goleveldb_batch.go Outdated Show resolved Hide resolved
pebble.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@jmalicevic jmalicevic added this pull request to the merge queue Feb 7, 2024
Merged via the queue into main with commit a89094b Feb 7, 2024
6 checks passed
@jmalicevic jmalicevic deleted the jasmina/add-compaction-to-db branch February 7, 2024 12:57
github-merge-queue bot pushed a commit to cometbft/cometbft that referenced this pull request Feb 16, 2024
Blocked on cometbft/cometbft-db#111 and
benchmarking


Addresses #49 

Upon pruning we explicitly call the compaction function of the DB
backend. This has shown to immediately shrink the storage footprint.

We need to evaluate the duration of this compaction depending on the
storage size to be able to reason about the impact on Comet's regular
operations.

ToDo: 
-Extend the `storage` config section with following parameters:
- [ ] `in-process-compaction = false #Enable or disable in-process
compaction. False by default`
- [ ] `in-process-compaction-interval = 10 #Interval in number of blocks
to trigger explicit compaction; 10 by default`



<!--

Please add a reference to the issue that this PR addresses and indicate
which
files are most critical to review. If it fully addresses a particular
issue,
please include "Closes #XXX" (where "XXX" is the issue number).

If this PR is non-trivial/large/complex, please ensure that you have
either
created an issue that the team's had a chance to respond to, or had some
discussion with the team prior to submitting substantial pull requests.
The team
can be reached via GitHub Discussions or the Cosmos Network Discord
server in
the #cometbft channel. GitHub Discussions is preferred over Discord as
it
allows us to keep track of conversations topically.
https://github.com/cometbft/cometbft/discussions

If the work in this PR is not aligned with the team's current
priorities, please
be advised that it may take some time before it is merged - especially
if it has
not yet been discussed with the team.

See the project board for the team's current priorities:
https://github.com/orgs/cometbft/projects/1

-->

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
mergify bot pushed a commit to cometbft/cometbft that referenced this pull request Feb 16, 2024
Blocked on cometbft/cometbft-db#111 and
benchmarking

Addresses #49

Upon pruning we explicitly call the compaction function of the DB
backend. This has shown to immediately shrink the storage footprint.

We need to evaluate the duration of this compaction depending on the
storage size to be able to reason about the impact on Comet's regular
operations.

ToDo:
-Extend the `storage` config section with following parameters:
- [ ] `in-process-compaction = false #Enable or disable in-process
compaction. False by default`
- [ ] `in-process-compaction-interval = 10 #Interval in number of blocks
to trigger explicit compaction; 10 by default`

<!--

Please add a reference to the issue that this PR addresses and indicate
which
files are most critical to review. If it fully addresses a particular
issue,
please include "Closes #XXX" (where "XXX" is the issue number).

If this PR is non-trivial/large/complex, please ensure that you have
either
created an issue that the team's had a chance to respond to, or had some
discussion with the team prior to submitting substantial pull requests.
The team
can be reached via GitHub Discussions or the Cosmos Network Discord
server in
the #cometbft channel. GitHub Discussions is preferred over Discord as
it
allows us to keep track of conversations topically.
https://github.com/cometbft/cometbft/discussions

If the work in this PR is not aligned with the team's current
priorities, please
be advised that it may take some time before it is merged - especially
if it has
not yet been discussed with the team.

See the project board for the team's current priorities:
https://github.com/orgs/cometbft/projects/1

-->

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
(cherry picked from commit cfe8b88)

# Conflicts:
#	internal/state/store.go
#	internal/store/store.go
#	node/node.go
greg-szabo pushed a commit to cometbft/cometbft that referenced this pull request Feb 22, 2024
Blocked on cometbft/cometbft-db#111 and
benchmarking


Addresses #49 

Upon pruning we explicitly call the compaction function of the DB
backend. This has shown to immediately shrink the storage footprint.

We need to evaluate the duration of this compaction depending on the
storage size to be able to reason about the impact on Comet's regular
operations.

ToDo: 
-Extend the `storage` config section with following parameters:
- [ ] `in-process-compaction = false #Enable or disable in-process
compaction. False by default`
- [ ] `in-process-compaction-interval = 10 #Interval in number of blocks
to trigger explicit compaction; 10 by default`



<!--

Please add a reference to the issue that this PR addresses and indicate
which
files are most critical to review. If it fully addresses a particular
issue,
please include "Closes #XXX" (where "XXX" is the issue number).

If this PR is non-trivial/large/complex, please ensure that you have
either
created an issue that the team's had a chance to respond to, or had some
discussion with the team prior to submitting substantial pull requests.
The team
can be reached via GitHub Discussions or the Cosmos Network Discord
server in
the #cometbft channel. GitHub Discussions is preferred over Discord as
it
allows us to keep track of conversations topically.
https://github.com/cometbft/cometbft/discussions

If the work in this PR is not aligned with the team's current
priorities, please
be advised that it may take some time before it is merged - especially
if it has
not yet been discussed with the team.

See the project board for the team's current priorities:
https://github.com/orgs/cometbft/projects/1

-->

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
@jmalicevic jmalicevic removed this from the 2024-Q1 milestone Mar 4, 2024
@adizere adizere added this to the 2024-Q1 milestone Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wip Work in progress
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants