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

Back to union storage #49

Merged
merged 4 commits into from
Jun 27, 2023
Merged

Back to union storage #49

merged 4 commits into from
Jun 27, 2023

Conversation

MasonProtter
Copy link
Owner

@MasonProtter MasonProtter commented Jun 26, 2023

This undoes the major overhaul of version 0.4 where we were doing computed storage. With this change, a bunch of things get a lot simpler, and we don't need to carry around extra parameters in the sum type.

While the computed storage did benefit some situations, julia's Union is also quite good. For all isbits data it should have the same performance profile as before, but for non-isbits data, there are some tradeoffs as to what ends up heap allocated and what doesn't, and I think that Union actually does a better job when you're modifying and interacting with the data since there's usually fewer pointers involved.

Fixes #30

@codecov
Copy link

codecov bot commented Jun 26, 2023

Codecov Report

Merging #49 (a1e9a18) into master (f786349) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            master       #49    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            4         3     -1     
  Lines          360       249   -111     
==========================================
- Hits           360       249   -111     
Impacted Files Coverage Δ
src/SumTypes.jl 100.00% <100.00%> (ø)
src/cases.jl 100.00% <100.00%> (ø)
src/sum_type.jl 100.00% <100.00%> (ø)

@MasonProtter
Copy link
Owner Author

@Krastanov, I know you have some code relying on SumTypes.jl for performance referenced in #28. Could I ask you to test out this PR and see if it causes any performance regressions (or improvements!) for you?

@Krastanov
Copy link

Yes, I should be able to do so today or tomorrow.

@Krastanov
Copy link

The only interesting benchmarks I have are with isbits objects, so maybe this is not too informative, but here are the results:

Tested on:

julia> versioninfo()
Julia Version 1.9.1
Commit 147bdf428cd (2023-06-07 08:27 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × AMD Ryzen 9 7950X 16-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
  Threads: 32 on 32 virtual cores

If you want to double check things for yourself, these are the benchmarks that depend on sumtypes:

https://github.com/QuantumSavory/QuantumClifford.jl/blob/544ba079c55dea93946cadba2a3aa6cd5d72adca/benchmark/benchmarks.jl#L131-L138

@MasonProtter
Copy link
Owner Author

Well that’s quite encouraging news! I guess julia’s handling of enclosed unions here is a bit smarter than what I was doing and enabled some speedups.

@MasonProtter MasonProtter merged commit c7628c4 into master Jun 27, 2023
@MasonProtter MasonProtter deleted the back-to-union branch June 27, 2023 05:55
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.

Dealing with extra parameters in recursive sumtypes
3 participants