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

Fix inlining for CompactAddr in the FromCBOR instance #2761

Merged
merged 1 commit into from May 4, 2022

Conversation

lehins
Copy link
Contributor

@lehins lehins commented Apr 29, 2022

There was not enough inlining prior to this PR which resulted in a slight but noticeable regression, when comparing to the implementation prior to the fix to address deserialization. TLDR, nothing crazy, just some inlining.

@lehins lehins requested a review from nc6 April 29, 2022 22:42
Copy link
Contributor

@nc6 nc6 left a comment

Choose a reason for hiding this comment

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

No major objections, just some questions.

@@ -30,8 +36,9 @@ import Test.QuickCheck.Gen (chooseWord64)

propValidateNewDecompact :: forall crypto. CC.Crypto crypto => Addr crypto -> Property
propValidateNewDecompact addr =
let compact = SBS.toShort $ serialiseAddr addr
decompactedOld = CA.deserializeShortAddr @crypto compact
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain the change here? This seems like we're comparing to a different method than before. I am generally worried that we have so many different deserialisers now, it's very difficult to know which to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good question and a very good observation: there are indeed too many deserializers now. In fact all this recent work paves the way for us remove all the old deserializers, but only after we are past the hardfork.

With regards to what has changed here is deserialiseAddr and deserializeShortAddr are almost identical, except latter works on ShortByteStrings, while the former works on ByteStrings. So, considering that deserializeShortAddr was used only for this test, we can just get rid of that function now and replace it with semantically equivalent one

-- Nothing -> cborError $ DecoderErrorCustom "Addr" "invalid address"
fromCBOR = do
(_addr, cAddr) <- fromCborBackwardsBothAddr
pure cAddr
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the change here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was mainly an experiment to check if for some reason fmap snd is too lazy for the Decoder and forcing the tuple would make an improvement. Honestly I don't know if it did, because I was also adding INLINE pragmas as well. As soon as I saw a regression gone, I didn't bother going back and changing it back to snd <$> fromCborBackwardsBothAddr, since that would mean at least another hour being wasted. However, if you are really curious I can make an effort and do a db-analyser run with this change reverted.

@lehins
Copy link
Contributor Author

lehins commented May 3, 2022

@nc6 Hopefully I've answered your questions. I've restarted the hydra build, since there was one of those recurring false positive test failures, however I have no idea why hydra is reporting CI as failing. Maybe you know you know how to fix it, if not, I'll force push a commit tomorrow.

Copy link
Contributor

@JaredCorduan JaredCorduan left a comment

Choose a reason for hiding this comment

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

LGTM!

@lehins lehins merged commit 418233b into master May 4, 2022
@iohk-bors iohk-bors bot deleted the lehins/fix-uninlined-compactaddr-from-cbor branch May 4, 2022 00:07
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