-
Notifications
You must be signed in to change notification settings - Fork 279
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
ENH: perf improvements by skipping unnecessary symbolic unit computations #4071
Conversation
This is to speed up calculations of the grid coordinates x, y, z which also benefits radius calculations and other geometric operations in derived fields.
…triggering calls to unyt.
Hi @yipihey, Also, I have a good idea what's going on because we discussed it on Slack, but it'd be good to add some context here so it's clearer to others. In particular, having your benchmark script and show what observable you measured (and how) would be very useful. Thanks a lot for working on this with us ! |
Ah yes. Indeed. This adds one more place with to add a .d to avoid triggering unit calculations when the outcome is known. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to me like it could be an enormous improvement in performance -- with big impacts on generating ghost zones, as well! Thanks, @yipihey . I think if we can guarantee that these will be in the same units (which I think we can) it should be good to go.
Super @matthewturk!
Yes I imagine as a rule we should always be able to do all computation in code_units. It should be safe to assume the users chose those units as the ones best suited for any calculation on their data fields. Then things like .in_base and methods like it should just show up when plotting labels or coloring etc. to done with the preferred “output” units.
T
… On Aug 12, 2022, at 10:28 AM, Matthew Turk ***@***.***> wrote:
@matthewturk approved this pull request.
This looks to me like it could be an enormous improvement in performance -- with big impacts on generating ghost zones, as well! Thanks, @yipihey <https://github.com/yipihey> . I think if we can guarantee that these will be in the same units (which I think we can) it should be good to go.
—
Reply to this email directly, view it on GitHub <#4071 (review)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAQSDIOHWJGC7L6JW5YR2UDVY2CT3ANCNFSM56GMEFWA>.
You are receiving this because you were mentioned.
|
Are you done or do you intend to push again here ? |
Hi @yipihey,
I would be a bit wary of assuming this in all cases--in this particular I think it's justified, however. |
Yes. Definitely want to be careful. Perhaps it makes sense to think of it as a style guide? I.e. recommend that code units are used when doing internal calculations. Then over time we can see whether we find a case in which this would not be the best or at least equivalent choice. |
@yipihey I completed the original message, reran your test script, and uploaded some basic screenshots from snakeviz. |
Oh fantastic. Thanks for checking. I think in the script below we should notice fewer calls to array.py in the snakeviz outputs. # Aprof.py: Use yt to make 1-D profiles and save them to a file.
import yt
for i in range(5):
ds = yt.load_sample("HiresIsolatedGalaxy")
ds._periodicity = (False, False, False) # Checking periodicity is slow in yt
readit = ds.all_data() # already defines xyz
x = readit.fcoords[:,0]
y = readit.fcoords[:,1]
z = readit.fcoords[:,2]
x2 = readit["index", "x"]
y2 = readit["index", "y"]
z2 = readit["index", "z"]
vol = readit["index", "volume"] |
yes with that script I see about 4% gain. It's more than 1%/changed line ! If it meets your goal here, I guess we can just merge as is. |
Perfect. Yes. That is all for now.
Thanks,
Tom
Typed on an IPhone. Please excuse typos and surprising autocorrects.
… On Aug 13, 2022, at 14:47, Clément Robert ***@***.***> wrote:
yes with that script I see about 4% gain. It's more than 1%/changed line ! If it meets your goal here, I guess we can just merge as is.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
I found two more spots that are in exactly the same spirit as the previous changes. I think we should keep that in this PR. |
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Hooray! Congratulations on your first merged pull request! We hope we keep seeing you around! 🎆 |
Yes let’s call it done for now.
I think there are more similar tweaks that will be possible but it may touch more files and will take more time.
Thanks!
Tom
… On Aug 12, 2022, at 11:13 AM, Clément Robert ***@***.***> wrote:
Are you done or do you intend to push again here ?
In any case I will try it out this weekend with the benchmark you posted on slack !
—
Reply to this email directly, view it on GitHub <#4071 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAQSDIL3PFUYTDH252IWWZDVY2H5LANCNFSM56GMEFWA>.
You are receiving this because you were mentioned.
|
PR Summary
Profiled script
Profiling and viz
on main:
This branch:
PR Checklist
edited by @neutrinoceros with details