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

Added test to partially ensure HashableValue does not regress #1431

Merged
merged 4 commits into from
Mar 24, 2022

Conversation

robert-e-davidson3
Copy link
Contributor

@robert-e-davidson3 robert-e-davidson3 commented Feb 17, 2022

Closes nothing (just ran into this)

Description

While looking into another issue, I came across the warning in hashablevalue.go and figured it could use a quick test to catch a possible regression.

I also added some language to the warning because it had a loophole.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov-commenter
Copy link

codecov-commenter commented Feb 17, 2022

Codecov Report

Merging #1431 (e9c8f65) into master (3ecb20d) will not change coverage.
The diff coverage is n/a.

❗ Current head e9c8f65 differs from pull request most recent head fd10f23. Consider uploading reports for the commit fd10f23 to get more accurate results

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1431   +/-   ##
=======================================
  Coverage   73.01%   73.01%           
=======================================
  Files         288      288           
  Lines       39786    39786           
=======================================
  Hits        29048    29048           
  Misses       9263     9263           
  Partials     1475     1475           
Flag Coverage Δ
unittests 73.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
runtime/interpreter/encode.go 65.72% <ø> (ø)
runtime/interpreter/hashablevalue.go 100.00% <ø> (ø)
runtime/interpreter/primitivestatictype.go 72.42% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ecb20d...fd10f23. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Feb 17, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 3ecb20d
The command for i in {1..N}; do go test ./... -run=XXX -bench=. -shuffle=on; done was used.
Bench tests were run a total of 7 times on each branch.

Results

old.txtnew.txt
time/opdelta
RuntimeResourceDictionaryValues-222.1ms ±16%22.4ms ±17%~(p=0.620 n=7+7)
RuntimeFungibleTokenTransfer-22.22ms ±22%2.01ms ±29%~(p=0.318 n=7+7)
ParseDeploy/byte_array-231.8ms ±15%35.8ms ±18%~(p=0.073 n=7+7)
ParseDeploy/decode_hex-21.77ms ± 8%1.82ms ±14%~(p=0.902 n=7+7)
ParseFungibleToken-2333µs ±19%344µs ±24%~(p=0.805 n=7+7)
ParseArray-221.2ms ±18%23.0ms ±41%~(p=0.710 n=7+7)
ParseInfix-213.7µs ±27%14.6µs ±23%~(p=0.535 n=7+7)
QualifiedIdentifierCreation/One_level-23.95ns ± 5%3.98ns ± 9%~(p=0.945 n=6+7)
QualifiedIdentifierCreation/Three_levels-2225ns ±13%226ns ±11%~(p=0.902 n=7+7)
ContractInterfaceFungibleToken-268.7µs ±15%72.0µs ±23%~(p=0.456 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2250µs ±25%247µs ±27%~(p=1.000 n=7+7)
NewInterpreter/new_interpreter-21.93µs ±17%1.89µs ±18%~(p=0.805 n=7+7)
NewInterpreter/new_sub-interpreter-23.63µs ±16%3.49µs ±16%~(p=0.535 n=7+7)
InterpretRecursionFib-24.33ms ±14%4.22ms ±11%~(p=0.805 n=7+7)
 
alloc/opdelta
ContractInterfaceFungibleToken-226.6kB ± 0%26.6kB ± 0%+0.00%(p=0.033 n=7+6)
RuntimeResourceDictionaryValues-24.05MB ± 0%4.05MB ± 0%~(p=0.805 n=7+7)
RuntimeFungibleTokenTransfer-2273kB ± 0%273kB ± 0%~(p=0.902 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.2kB ± 0%66.2kB ± 0%~(p=1.000 n=7+7)
NewInterpreter/new_interpreter-2848B ± 0%848B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.32kB ± 0%1.32kB ± 0%~(all equal)
InterpretRecursionFib-21.26MB ± 0%1.26MB ± 0%~(p=0.767 n=7+6)
 
allocs/opdelta
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.849 n=7+7)
RuntimeFungibleTokenTransfer-24.52k ± 0%4.52k ± 0%~(p=0.738 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
ContractInterfaceFungibleToken-2458 ± 0%458 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-239.0 ± 0%39.0 ± 0%~(all equal)
InterpretRecursionFib-226.2k ± 0%26.2k ± 0%~(all equal)
 

@robert-e-davidson3
Copy link
Contributor Author

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Great idea to avoid regressions there! 👍

Given that HashInputTypeUFix64 is currently the last "case in the enum", but might not be in the future, when types are added, maybe add an additional case which just indicates the "count" / number of cases, and a comment indicating it always must be last, e.g.

	// !!! *WARNING* !!!
	// ADD NEW TYPES *BEFORE* THIS WARNING.
	// DO *NOT* ADD NEW TYPES AFTER THIS LINE!
	HashInputType_Count
)

And then use HashInputType_Count in the new test case.

There are actually two more enumerations which have similar requirements. Could you please add the same "count case" there and a test case for each?

  • interpreter.CBORTag*
  • interpreter.PrimitiveStaticType

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Great idea and work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants