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

Best-offer debugging #2944

Merged
merged 5 commits into from
Mar 12, 2021
Merged

Best-offer debugging #2944

merged 5 commits into from
Mar 12, 2021

Conversation

rokopt
Copy link
Contributor

@rokopt rokopt commented Mar 4, 2021

Best-offer debugging

Updates and integrates some formerly-private debugging for getBestOffer() which cross-checks its return values against a much slower, simpler algorithm.

Because the debug algorithm is so slow, it is compiled in by default only when tests are compiled in (or when explicitly requested with a configure option), and if is compiled in, it runs by default only under the test and fuzz commands (or when explicitly requested with a command-line option; it can also be disabled for test and fuzz with a command-line option).

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

src/test/FuzzerImpl.cpp Outdated Show resolved Hide resolved
src/test/test.cpp Outdated Show resolved Hide resolved
src/ledger/LedgerTxn.cpp Outdated Show resolved Hide resolved
src/main/CommandLine.cpp Outdated Show resolved Hide resolved
@rokopt rokopt force-pushed the best-offer-debugging branch 2 times, most recently from da17ff3 to dae0070 Compare March 4, 2021 18:15
@rokopt
Copy link
Contributor Author

rokopt commented Mar 4, 2021

To try to get some idea of the impact of this on test speed, I ran ./src/stellar-core test --all-versions --ll info -w NoTests -a -r simple "[tx]" (I'm guessing the transaction tests would include the most impacted) with and without best-offer debugging compiled in:

--enable-extrachecks --enable-asan --disable-best-offer-debugging: 7m55s
--enable-extrachecks --enable-asan --enable-best-offer-debugging: 7m57s

I'm guessing that's well within the variation (and even if it weren't, it's probably an irrelevant difference for a unit test), so I think we can indeed comfortably afford not to provide a --disable-best-offer-debugging for stellar-core test.

Copy link
Contributor

@sisuresh sisuresh left a comment

Choose a reason for hiding this comment

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

I reviewed the last commit and the logic looks good to me. Just included a few minor comments.

src/ledger/LedgerTxn.cpp Outdated Show resolved Hide resolved
src/ledger/LedgerTxnImpl.h Show resolved Hide resolved
src/ledger/LedgerTxn.cpp Show resolved Hide resolved
@rokopt
Copy link
Contributor Author

rokopt commented Mar 5, 2021

To try to get some idea of the impact of this on test speed, I ran ./src/stellar-core test --all-versions --ll info -w NoTests -a -r simple "[tx]" (I'm guessing the transaction tests would include the most impacted) with and without best-offer debugging compiled in:

--enable-extrachecks --enable-asan --disable-best-offer-debugging: 7m55s
--enable-extrachecks --enable-asan --enable-best-offer-debugging: 7m57s

I'm guessing that's well within the variation (and even if it weren't, it's probably an irrelevant difference for a unit test), so I think we can indeed comfortably afford not to provide a --disable-best-offer-debugging for stellar-core test.

I also tried it on a catchup. The range I chose took ~5.5 minutes without best-offer debugging, and ~45 minutes with it.

@MonsieurNicolas
Copy link
Contributor

Is the configure option needed now that you have the config? Why not just enable it if people enable extra-checks?

@MonsieurNicolas MonsieurNicolas added this to In progress in v15.4.0 via automation Mar 5, 2021
@rokopt
Copy link
Contributor Author

rokopt commented Mar 5, 2021

Is the configure option needed now that you have the config? Why not just enable it if people enable extra-checks?

Extrachecks are off unless --enable-extrachecks is explicitly specified, even if tests are being built. I think we were intending that tests would build and run with best-offer debugging unless someone explicitly requested otherwise. (Just keying best-offer debugging off BUILD_TESTS is an option.)

@rokopt
Copy link
Contributor Author

rokopt commented Mar 6, 2021

Nicolas requested the removal of the separate configure option, --enable-best-offer-debugging, in favor of using --enable-extrachecks to determine whether to set -DBEST_OFFER_DEBUGGING.

He also requested removing the --enable-best-offer-debugging option from run and catchup, as if anyone needs such detailed debugging for those commands, they'll probably be modifying code and rebuilding anyway.

I've pushed commits to do each of those two things.

Copy link
Contributor

@MonsieurNicolas MonsieurNicolas left a comment

Choose a reason for hiding this comment

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

cool. you should squash those last 2 commits into the previous commits as they're (mostly) cancelling things that this PR added

@@ -10,8 +10,15 @@
namespace stellar
{

InMemoryLedgerTxnRoot::InMemoryLedgerTxnRoot()
InMemoryLedgerTxnRoot::InMemoryLedgerTxnRoot(
#if BEST_OFFER_DEBUGGING
Copy link
Contributor

Choose a reason for hiding this comment

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

do not mix #if BEST_OFFER_DEBUGGING and #ifdef BEST_OFFER_DEBUGGING
What you want everywhere is #ifdef BEST_OFFER_DEBUGGING given how you set it in the configure script

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yikes, thanks for catching that. Fixed.

@@ -983,7 +983,11 @@ void
TransactionFuzzer::initialize()
{
resetRandomSeed(1);
mApp = createTestApplication(mClock, getFuzzConfig(0));
auto cfg = getFuzzConfig(0);
#ifdef BEST_OFFER_DEBUGGING
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need this: as you're using a test configuration, it's already set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Removed.

@rokopt
Copy link
Contributor Author

rokopt commented Mar 7, 2021

cool. you should squash those last 2 commits into the previous commits as they're (mostly) cancelling things that this PR added

Squashed. (The previous two were also squashable.)

src/ledger/LedgerTxn.cpp Outdated Show resolved Hide resolved
src/ledger/LedgerTxn.cpp Outdated Show resolved Hide resolved
@rokopt
Copy link
Contributor Author

rokopt commented Mar 11, 2021

Fuzz metrics from current master without this PR:

master-without-order-book-not-crossed-invariant-for-20-min

And with this PR:

best-offer-debugging-after-20-minutes

So the impact of this on exec speed is very substantial, although the benefits in terms of noticing bugs that fuzzing might find could also be large. (That all applies to #2959 as well.)

Compile in best-offer debugging if extrachecks are enabled.
The Config option is initialized to false, so that
best-offer debugging will be used only if something
explicitly turns it on.  (For example, a test might
set it in a Config option before calling
createTestApplication(), or the "test" command might
enable it by default if not explicitly disabled on the
command line, or the "run" command might enable it if
explicitly enabled on the command line.)
Always use best-offer debugging in `stellar-core test`.
Add parameters to the constructors of LedgerTxnRoot and
InMemoryLedgerTxnRoot to pass in the state of the
best-offer debug Config option (or "false" if best-offer
debugging is not compiled in).  If best-offer debugging
is compiled in, also give those classes new boolean
members to store the value of the option.
If best-offer debugging is compiled in and the run-time
Config option is set, check the results of getBestOffer()
against a new getBestOfferSlow().
@MonsieurNicolas
Copy link
Contributor

r+ ae3dfa0

@latobarita latobarita merged commit d825052 into stellar:master Mar 12, 2021
v15.4.0 automation moved this from In progress to Done Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants