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

Simplify cost graphs and speedup costing performance #523

Merged
merged 31 commits into from
Jun 13, 2019

Conversation

aslesarenko
Copy link
Collaborator

@aslesarenko aslesarenko commented Jun 10, 2019

  • memory leak fixed in (resetContext is doing additional cleanups)
  • removed dependency on scalan-meta.jar
  • removed dependancy on scala-compiler.jar
  • various performance optimisations (based on profiling)
  • costing speedup by using max constants instead of variables (which simplifies cost graph and hence reduce time)
  • decreased timeout in SpamSpeciafication
  • fixed limit check in ValueSerializer
  • MaxBoxSize set to 4 * 1024
  • check MaxBoxSize and MaxPropositionBytes limits in deserialization

@aslesarenko aslesarenko added the S-ready-for-merge Status: This PR is ready for merge label Jun 11, 2019
@aslesarenko aslesarenko added this to the v2.1.2 milestone Jun 11, 2019
* move reader.positionLimit check from ValueSerializer to SigmaByteReader methods;

* default SigmaByteReader.positionLimit to the whole remaining reader bytes;

* extract max proposition size as a paramater in ErgoTreeSerializer.deserializeErgoTree;

* honor maxTreeSize on constant deserialization in ErgoTreeSerializer.deserializeErgoTree;

* remove checkPositionLimit in reader's getType and getValue;

* add readers positionLimit setting in box deserialization;
add restoration of readers positionLimit where it is altered;

* restore serialization round trit check without prefixed random bytes;
# Conflicts:
#	src/test/scala/sigmastate/serialization/generators/ValueGenerators.scala
@aslesarenko aslesarenko changed the base branch from v2.1.2 to v2.2 June 12, 2019 12:36
@greenhat greenhat mentioned this pull request Jun 12, 2019
val value = r.getULong()
val tree = ErgoTreeSerializer.DefaultSerializer.deserializeErgoTree(r)
val creationHeight = r.getUInt().toInt
val addTokensCount = r.getByte()
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this breaks binary format?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@catena2w I don't think so. We're writing unsigned values, but we were reading signed values. I just fixed reading.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for small non-negative range they are the same @inline override def getUByte(): Int = getByte() & 0xFF

@@ -127,15 +128,18 @@ class ErgoTreeSerializer {
deserializeErgoTree(r)
}

def deserializeErgoTree(r: SigmaByteReader): ErgoTree = {
def deserializeErgoTree(r: SigmaByteReader,
maxTreeSizeBytes: Int = SigmaSerializer.MaxPropositionSize): ErgoTree = {
Copy link
Member

Choose a reason for hiding this comment

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

Is this really a function parameter? Let's either remove it from parameters list or remove the default value

Copy link
Collaborator

Choose a reason for hiding this comment

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

@catena2w Probably not. Easing of testing does not count. Apart from that, decoupling from SigmaSerializer constant does not worth it alone. Removing default value will just force this constant leaking out. Let me remove the parameter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed default value.

cost(s"{ $rootTree.updateDigest($rootTree.digest) == $rootTree }") shouldBe
(AccessRootHash + selectField + newAvlTreeCost + comparisonCost /* for isConstantSize AvlTree type */)
cost(s"{ $rootTree.updateOperations(1.toByte) == $rootTree }") shouldBe
(AccessRootHash + newAvlTreeCost + comparisonCost + constCost)
Copy link
Member

Choose a reason for hiding this comment

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

Let's add tests for changed costing rules, they should be quite easy now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

only this tests are affected and changed. Others are not affected.
More test will be added in #516

@greenhat greenhat mentioned this pull request Jun 12, 2019
@aslesarenko aslesarenko merged commit a8f5524 into v2.2 Jun 13, 2019
@catena2w catena2w deleted the simplify-costing branch June 18, 2019 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-ready-for-merge Status: This PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants