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

Avoid recomputing the ShelleyLedgerConfig #2390

Merged
merged 1 commit into from
Jul 13, 2020

Conversation

mrBliss
Copy link
Contributor

@mrBliss mrBliss commented Jul 13, 2020

In #2375, we discovered that validating a Byron chain took 10x as long using
CardanoBlock than using ByronBlock.

Looking at the profiling report, we see it being dominated by:

exp' src/Shelley/Spec/NonIntegral.hs:(171,1)-(175,43) 52.1 56.7
ln'  src/Shelley/Spec/NonIntegral.hs:(159,1)-(162,27) 22.7 26.1

Which is strange, as we're validating a Byron-only chain! It turns out that
these two functions are called by mkActiveSlotCoeff, which is called as part
of mkShelleyLedgerConfig, which we are calling in completeLedgerConfig. This
happens for each block.

To fix this, we replace the partial ledger config of Shelley with a non-partial
one containing a dummy EpochInfo Identity. In completeLedgerConfig we
replace the dummy EpochInfo Identity with the correct one. This means we only
call mkShelleyLedgerConfig once and cache its result.

@mrBliss mrBliss added the consensus issues related to ouroboros-consensus label Jul 13, 2020
@mrBliss mrBliss requested a review from edsko July 13, 2020 14:32
@mrBliss mrBliss mentioned this pull request Jul 13, 2020
In #2375, we discovered that validating a Byron chain took 10x as long using
`CardanoBlock` than using `ByronBlock`.

Looking at the profiling report, we see it being dominated by:

```
exp' src/Shelley/Spec/NonIntegral.hs:(171,1)-(175,43) 52.1 56.7
ln'  src/Shelley/Spec/NonIntegral.hs:(159,1)-(162,27) 22.7 26.1
```

Which is strange, as we're validating a Byron-only chain! It turns out that
these two functions are called by `mkActiveSlotCoeff`, which is called as part
of `mkShelleyLedgerConfig`, which we are calling in `completeLedgerConfig`. This
happens for *each* block.

To fix this, we replace the partial ledger config of Shelley with a non-partial
one containing a dummy `EpochInfo Identity`. In `completeLedgerConfig` we
replace the dummy `EpochInfo Identity` with the correct one. This means we only
call `mkShelleyLedgerConfig` once and cache its result.
@mrBliss mrBliss force-pushed the mrBliss/cache-ledgerconfig branch from 372d4a1 to 28f451e Compare July 13, 2020 14:55
@mrBliss
Copy link
Contributor Author

mrBliss commented Jul 13, 2020

bors merge

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jul 13, 2020

@iohk-bors iohk-bors bot merged commit b0902f6 into master Jul 13, 2020
@iohk-bors iohk-bors bot deleted the mrBliss/cache-ledgerconfig branch July 13, 2020 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants