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

Default mask to Trues from FillArray #70

Merged
merged 3 commits into from
Aug 9, 2020
Merged

Default mask to Trues from FillArray #70

merged 3 commits into from
Aug 9, 2020

Conversation

JeffFessler
Copy link
Owner

Saves memory for the usual default, and will save time for .* mask operations.

@codecov
Copy link

codecov bot commented Aug 1, 2020

Codecov Report

Merging #70 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #70   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files          49       49           
  Lines        2113     2113           
=======================================
  Hits         2108     2108           
  Misses          5        5           
Impacted Files Coverage Δ
src/fbp/image_geom.jl 100.00% <100.00%> (ø)

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 a3f71e0...bae42bf. Read the comment docs.

@johnnychen94
Copy link
Contributor

From the description, ConstantArrays looks like the same as FillArrays.jl https://github.com/JuliaArrays/FillArrays.jl ?

@johnnychen94
Copy link
Contributor

will save time for .* mask operations.

Any benchmark for this? I'm a little doubt about this improvement given that broadcasting is generally doing pretty good.

@JeffFessler
Copy link
Owner Author

@johnnychen94 thanks for telling me about FillArrays. I tried searching for something like this and could not find it. I should have asked you! Do you mind emailing me your email address so I can ask occasional questions like that before investing time repeating existing work? (My email is easy to find on my web page.)

There are timing tests in the repo::
https://github.com/JeffFessler/ConstantArrays.jl/blob/master/test/time.jl
Those tests show that .* is indeed faster with both ConstantArrays and FillArrays than using trues(dims) probably because of having to read all of the data values for trues from memory.
Currently my ConstantArrays is faster than FillArrays for a certain indexing operation that I overloaded.
Maybe I will submit a PR to FillArrays later to address that.
There is another indexing operation that is also relevant to image reconstruction that is still slower than I would like it to be; if you look at it and have any ideas about how to speed it up I would welcome your input!

@johnnychen94
Copy link
Contributor

johnnychen94 commented Aug 3, 2020

Sorry for the late response, I was exhausted last week because of the day-to-day seminars. It's johnnychen94@hotmail.com, or Johnny Chen in slack.

I tried to play with the benchmark scripts, but the results are a little obscure to me to understand. My best guess is that these differences are misleading; these fundamental operations might be affected by Julia's optimization on BitArray and CPU caches. Just a guess.

If the memory allocation of mask isn't a performance bottleneck, probably it would just be fine to not tweak it.

@JeffFessler
Copy link
Owner Author

Thanks for taking a look. I studied it further and was able to figure out how to speed everything up the way I wanted. The timing results are all in the updated time.jl file linked above.
I plan to submit a PR to FillArrays and if that goes through then I can try to delete ConstantArrays.

@JeffFessler
Copy link
Owner Author

@johnnychen94 , thanks for the pointer to FillArrays. I contributed a couple of features to it so that it would support what I needed here and now I'm using FillArrays instead. Any comments?

@JeffFessler JeffFessler changed the title Default mask to ConstantArray Default mask to Trues from FillArray Aug 9, 2020
Copy link
Contributor

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

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

LGTM

@JeffFessler JeffFessler merged commit 9352463 into master Aug 9, 2020
@JeffFessler JeffFessler deleted the mask branch August 9, 2020 15:00
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.

None yet

2 participants