Change derived Generic sum type instances to generate a balanced binary tree of Eithers #670
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #334.
This makes the derived instances for
Generic
for datatypes with multiple constructors use a balanced binary tree ofEither
types, rather than a linear chain ofEither
s. This has the side-effect of making it much nicer to write genericBits
-like type classes, see the changes toCustomBits.bs
in the testsuite.To measure the effect on performance, I ran
time make checkparallel -j16 -C testsuite
before and after making this change.Pre-change (commit e4361d9) testsuite runtime: 10383.02s user 1748.27s system 666% cpu 30:20.54 total
Post-change (commit d32b927) testsuite runtime: 7877.59s user 1738.98s system 1325% cpu 12:05.69 total
Note that when running the testsuite prior to this change, there were some tests that failed due to OOMing on my system, so the exact speedup isn't accurate - but at least this is clearly a significant performance win. Is there a more specific test/set of tests that exhibit this problem, that would be a better benchmark?
Note that the bsc-contrib tests are currently failing, but should be fixed by merging B-Lang-org/bsc-contrib#25.