Skip to content

Conversation

redxaxder
Copy link
Contributor

No description provided.

@redxaxder redxaxder force-pushed the redxaxder/manual_unpack branch 2 times, most recently from b7bd41c to 2198430 Compare September 24, 2021 22:22
@redxaxder redxaxder marked this pull request as ready for review September 24, 2021 22:22
@redxaxder redxaxder force-pushed the redxaxder/manual_unpack branch 3 times, most recently from a14262f to f5101c6 Compare September 27, 2021 16:22
@redxaxder redxaxder force-pushed the redxaxder/manual_unpack branch from f5101c6 to d1bcb50 Compare September 27, 2021 19:20
Comment on lines +461 to +467
TxInCompact32 ::
HS.SizeHash (CC.HASH crypto) ~ 32 =>
{-# UNPACK #-} !Word64 -> -- Hash part 1/4
{-# UNPACK #-} !Word64 -> -- Hash part 2/4
{-# UNPACK #-} !Word64 -> -- Hash part 3/4
{-# UNPACK #-} !Word64 -> -- Hash part 4/4
{-# UNPACK #-} !Word64 -> -- Index
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is clearly 6 words, so it's a win.

@@ -431,7 +440,10 @@ deriving newtype instance CC.Crypto crypto => FromCBOR (TxId crypto)
deriving newtype instance CC.Crypto crypto => NFData (TxId crypto)

instance HeapWords (TxIn crypto) where
heapWords (TxInCompact txid ix) = 3 + HW.heapWordsUnpacked txid + HW.heapWordsUnpacked ix
heapWords (TxInCompact32 a _ _ _ ix) =
6 + (4 * HW.heapWordsUnpacked a) + HW.heapWordsUnpacked ix
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that heapWordsUnpacked (a :: Word64) is zero? The answer here must be 6, so it must amount to 6 + 4 * 0 + 0. Can someone verify that the answer here does indeed come out to be simply 6?

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 have

instance HeapWords Word64 where
  heapWords _ = 2

and

heapWordsUnpacked :: HeapWords a => a -> Int
heapWordsUnpacked x = heapWords x - 2

Comment on lines +480 to +482
case HS.viewHash32 (extractHash sh) of
HS.ViewHashNot32 -> TxInCompactOther txid (fromIntegral index)
HS.ViewHash32 a b c d -> TxInCompact32 a b c d (fromIntegral index)
Copy link
Contributor

Choose a reason for hiding this comment

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

Noice.

Co-authored-by: Jared Corduan <jared.corduan@iohk.io>
@redxaxder redxaxder merged commit c0a7b02 into master Sep 30, 2021
@iohk-bors iohk-bors bot deleted the redxaxder/manual_unpack branch September 30, 2021 13:05
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.

3 participants