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

Cleaned up BucketApplicator::Counters #3566

Merged
merged 2 commits into from
Jan 11, 2024

Conversation

SirTyson
Copy link
Contributor

@SirTyson SirTyson commented Oct 5, 2022

Description

Resolves #3114. Cleans up BucketApplicator::Counters.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

@@ -32,34 +32,26 @@ class BucketApplicator
public:
class Counters
{
// indexed by LedgerEntryType, i.e. offer counter == CounterArray[OFFER]
// array size == num enums in LedgerEntryType
typedef std::array<uint64_t, 8> CounterArray;
Copy link
Contributor

Choose a reason for hiding this comment

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

as this is not performance critical, you should just make this a map LedgerEntryType -> uint64_t, that way you don't need to hardcode anything

case CONFIG_SETTING:
++mConfigSettingUpsert;
break;
#ifndef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
Copy link
Contributor

Choose a reason for hiding this comment

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

you should not need those ifdefs anymore (see my comment on using maps)

CounterArray const& upserted,
CounterArray const& deleted)
{
return fmt::format("for {}-entry bucket {}.{} au:{} ad:{} tu:{} td:{} "
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need to preserve the exact output, so you should just use iterators.
This will also fix the bug that we're not logging properly if ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION is set

src/bucket/BucketApplicator.cpp Show resolved Hide resolved
@marta-lokhova
Copy link
Contributor

@SirTyson any reason not to rebase and merge this? Looks like a useful change.

@SirTyson
Copy link
Contributor Author

SirTyson commented Jan 8, 2024

@SirTyson any reason not to rebase and merge this? Looks like a useful change.

Done

@SirTyson SirTyson self-assigned this Jan 10, 2024
Copy link
Contributor

@marta-lokhova marta-lokhova left a comment

Choose a reason for hiding this comment

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

One question, otherwise looks good. Please squash the commits and we can merge this.

++mTTLDelete;
break;
}
auto let = e.deadEntry().type();
Copy link
Contributor

Choose a reason for hiding this comment

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

We should preserve the invariant regarding deletion of CONFIG_SETTING (it's illegal, so we should crash)

@@ -32,39 +32,24 @@ class BucketApplicator
public:
class Counters
{
// LedgerEntryType -> num_upserted, num_deleted
typedef std::map<LedgerEntryType, std::pair<uint64_t, uint64_t>>
Copy link
Contributor

Choose a reason for hiding this comment

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

Turning std::pair into a struct would help with readability.

@marta-lokhova
Copy link
Contributor

r+ b4777b3

@latobarita latobarita merged commit 99b85bd into stellar:master Jan 11, 2024
15 checks passed
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.

Clean-up implementation of BucketApplicator::Counters
4 participants