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

stagedSync: Optimize prune old chunks #10019

Merged
merged 7 commits into from
Apr 24, 2024
Merged

stagedSync: Optimize prune old chunks #10019

merged 7 commits into from
Apr 24, 2024

Conversation

somnathb1
Copy link
Collaborator

@somnathb1 somnathb1 commented Apr 22, 2024

Summary
Fixes prune point for log (+index)

  • Unnecessary to use ETL again for deleting kv.Log entries, delete in the initial loop
  • Put the last pruneTo block number in the PruneState - this will begin pruning from that point. Earlier the pruneFrom point being passed in was buggy as it used some other assumption for this value

@somnathb1 somnathb1 changed the title Fix prune old chunks Optimize prune old chunks Apr 22, 2024
@somnathb1 somnathb1 enabled auto-merge (squash) April 22, 2024 13:00
if err := pruneLogKeyCollector.Collect(k, nil); err != nil {
return err
}
c.DeleteCurrent()
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. err not checked
  2. plz use tx.Delete(table, k). Because seems some version of mdbx has bug when same cursor used for for iteration and DeleteCurrent - we did workaround it by using 2 cursors or tx.Delete, tnx. I'm not sure which versions are affected - because not easy to reproduce.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • tx.DeleteCurrent pattern is used at many places in the code base. Are you also saying all of them need fixing too, then? Because the way i see it, DeleteCurrent can only be used in a for loop like that.
  • What is the performance impact of using tx.Delete here, compared to DeleteCurrent?

Copy link
Collaborator

Choose a reason for hiding this comment

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

DeleteCurrent is not bad - use 1 cursor to iterate and in same time DeleteCurrent - bad in some mdbx versions.

No performance impact (of course it’s there - O(1) vs O(n log n), but mdbx’s methods itself are fast-enough, bottleneck is usually in “touching cold data”, but you touching it by loop anyway).

Don’t need modify other places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, for now, using tx.Delete in its place

@somnathb1 somnathb1 changed the title Optimize prune old chunks stagedSync: Optimize prune old chunks Apr 23, 2024
@somnathb1 somnathb1 merged commit d318f11 into devel Apr 24, 2024
7 checks passed
@somnathb1 somnathb1 deleted the som/fix_pruneOldChunks branch April 24, 2024 11:07
@ghost ghost mentioned this pull request Jun 3, 2024
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.

None yet

3 participants