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

CAD-1131: add a UTxO size trace to TraceStartLeadershipCheck messages & lots of cleanups #1329

Merged
merged 4 commits into from
Jun 25, 2020

Conversation

deepfire
Copy link
Contributor

@deepfire deepfire commented Jun 23, 2020

  1. Factors the Cardano.Tracing.Kernel module for NodeKernel access.
  2. Cardano.Config.LedgerQuery for a ledger queries typeclass.
  3. Enhance the TraceStartLeadershipCheck message with a UTxO size value.
  4. Switch over to the newly available Shelley.Spec.Ledger.BaseTypes.StrictMaybe.
  5. Clean up the overall tracer setup somewhat.

Sample messages:

{"at":"2020-06-23T22:30:54.43Z","env":"1.14.0:00000","ns":["cardano.node.Forge"],"data":{"kind":"TraceStartLeadershipCheck","slot":0},"app":[],"msg":"","pid":"12379","loc":null,"host":"andromed","sev":"Info","thread":"37"}
{"at":"2020-06-23T22:30:54.63Z","env":"1.14.0:00000","ns":["cardano.node.Forge"],"data":{"kind":"TraceStartLeadershipCheck","slot":1,"utxoSize":3},"app":[],"msg":"","pid":"12379","loc":null,"host":"andromed","sev":"Info","thread":"37"}

Note the absence of utxoSize for slot 0, when there's no NodeKernel available yet.

@deepfire deepfire force-pushed the cad-1131-utxo-size-trace branch 6 times, most recently from 5cc1b15 to e1fdcfa Compare June 23, 2020 22:23
@deepfire deepfire self-assigned this Jun 23, 2020
@deepfire deepfire marked this pull request as ready for review June 23, 2020 22:34
cardano-config/src/Cardano/Config/LedgerQueries.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Kernel.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Kernel.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Kernel.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Kernel.hs Outdated Show resolved Hide resolved
@@ -465,7 +478,7 @@ mkConsensusTracers' elidingFetchDecision measureBlockForging
tracingVerbosity :: TracingVerbosity
tracingVerbosity = traceVerbosity traceConf

mkConsensusTracers' _ _ _ _ TracingOff _ = Consensus.Tracers
mkConsensusTracers' _ _ _ _ _ TracingOff _ = Consensus.Tracers
Copy link
Contributor

Choose a reason for hiding this comment

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

Surely there is a less horrible way to do that?

Copy link
Contributor Author

@deepfire deepfire Jun 23, 2020

Choose a reason for hiding this comment

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

That would take a refactor, and people complain about large changes -- making them hard to review.

I already took some risks with this one..

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: fix it in a separate commit (before the other changes)?

Copy link
Contributor Author

@deepfire deepfire Jun 24, 2020

Choose a reason for hiding this comment

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

@mrBliss, done!

I didn't clean up all things I could, but that's already a large change.
We have quite a huge mess there..

cardano-node/src/Cardano/Tracing/Kernel.hs Outdated Show resolved Hide resolved
cardano-config/src/Cardano/Config/LedgerQueries.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Node/Run.hs Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Kernel.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Tracers.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Tracers.hs Show resolved Hide resolved
cardano-config/src/Cardano/Config/LedgerQueries.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Kernel.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Node/Run.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Tracers.hs Outdated Show resolved Hide resolved
import Data.IORef (IORef, atomicModifyIORef', readIORef)
import qualified Data.Text as Text
import qualified Data.HashMap.Strict as Map
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not an ordered Map like everywhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're creating an Aeson object manually, which uses this HashMap type under the hood.

cardano-node/src/Cardano/Tracing/Tracers.hs Outdated Show resolved Hide resolved
cardano-node/src/Cardano/Tracing/Tracers.hs Outdated Show resolved Hide resolved


class LedgerQueries blk where
ledgerUtxoSize :: LedgerState blk -> Int
Copy link
Contributor

Choose a reason for hiding this comment

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

I have seen UTxO (vs. Utxo) in a few places, although Utxo follows Haskell's capitalisation rules better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was one the unstated questions I had, actually, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, Thomas, if you think we should change it, I'd need a slightly less subtle suggestion. : -)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the record, ledger code uses:

  • UTXO
  • UTxO
  • Utxo
  • utxo


newtype NodeKernelData blk =
NodeKernelData
{ unNodeKernelData :: IORef (SMaybe (NodeKernel IO RemoteConnectionId LocalConnectionId blk))
Copy link
Contributor

Choose a reason for hiding this comment

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

This IORef will only be filled in once, when the NodeKernel has started (I know that was already the case before this PR), so that IORef + SMaybe is only used to break the circular dependency right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the tracers have to be created to make NodeKernel available.

@@ -465,7 +478,7 @@ mkConsensusTracers' elidingFetchDecision measureBlockForging
tracingVerbosity :: TracingVerbosity
tracingVerbosity = traceVerbosity traceConf

mkConsensusTracers' _ _ _ _ TracingOff _ = Consensus.Tracers
mkConsensusTracers' _ _ _ _ _ TracingOff _ = Consensus.Tracers
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: fix it in a separate commit (before the other changes)?

@deepfire deepfire force-pushed the cad-1131-utxo-size-trace branch 3 times, most recently from 7ae573b to 1113e36 Compare June 24, 2020 10:20
@Jimbo4350 Jimbo4350 self-requested a review June 24, 2020 10:25
@deepfire deepfire force-pushed the cad-1131-utxo-size-trace branch 2 times, most recently from 073a981 to a1436ec Compare June 24, 2020 11:18
@deepfire deepfire force-pushed the cad-1131-utxo-size-trace branch 3 times, most recently from aaca4a1 to 0b0271a Compare June 24, 2020 15:18
@deepfire deepfire changed the title CAD-1131: add a UTxO size trace to TraceStartLeadershipCheck messages CAD-1131: add a UTxO size trace to TraceStartLeadershipCheck messages & lots of cleanups Jun 24, 2020
@erikd erikd dismissed Jimbo4350’s stale review June 25, 2020 07:56

Looks like its been done.

@deepfire
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 25, 2020
1329: CAD-1131:  add a UTxO size trace to TraceStartLeadershipCheck messages & lots of cleanups r=deepfire a=deepfire

1. Factors the `Cardano.Tracing.Kernel` module for `NodeKernel` access.
2. `Cardano.Config.LedgerQuery` for a ledger queries typeclass.
3. Enhance the `TraceStartLeadershipCheck` message with a UTxO size value.
4. Switch over to the newly available `Shelley.Spec.Ledger.BaseTypes.StrictMaybe`.
5. Clean up the overall tracer setup somewhat.

Sample messages:
```
{"at":"2020-06-23T22:30:54.43Z","env":"1.14.0:00000","ns":["cardano.node.Forge"],"data":{"kind":"TraceStartLeadershipCheck","slot":0},"app":[],"msg":"","pid":"12379","loc":null,"host":"andromed","sev":"Info","thread":"37"}
{"at":"2020-06-23T22:30:54.63Z","env":"1.14.0:00000","ns":["cardano.node.Forge"],"data":{"kind":"TraceStartLeadershipCheck","slot":1,"utxoSize":3},"app":[],"msg":"","pid":"12379","loc":null,"host":"andromed","sev":"Info","thread":"37"}
```

Note the absence of `utxoSize` for slot 0, when there's no `NodeKernel` available yet.

Co-authored-by: Kosyrev Serge <kosyrev.serge@protonmail.com>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 25, 2020

Build failed

@deepfire
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 25, 2020

@iohk-bors iohk-bors bot merged commit f8a2da1 into master Jun 25, 2020
@iohk-bors iohk-bors bot deleted the cad-1131-utxo-size-trace branch June 25, 2020 09:43
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.

4 participants