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

Cost evaluation feedback #3

Open
pdarragh opened this issue Oct 4, 2022 · 4 comments
Open

Cost evaluation feedback #3

pdarragh opened this issue Oct 4, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@pdarragh
Copy link
Collaborator

pdarragh commented Oct 4, 2022

Via @__gparmer on Twitter:

Another potential use, that is likely already on your radar: If you can interpret the code, you can apply a cost function to it (while interpreting), which can provide feedback on how effective different optimizations are.

Different cost functions (loads are expensive vs. forward branches are expensive vs. instructions in general are expensive) can make the point to students that optimizations are architecture-specific.

I haven't thought about this one much, but adding such functionality could be neat and may not be terribly difficult? I figure it would essentially amount to just keeping a running total of costs incurred during step operations. The most primitive such cost function could just be counting the number of steps taken!

@pdarragh pdarragh added the enhancement New feature or request label Oct 4, 2022
@pdarragh pdarragh self-assigned this Oct 4, 2022
@laelath
Copy link

laelath commented Oct 6, 2022

On modern machines trying to predict the cost statically can be very hard. Not all loads are equal, and same for not all (forwards or backwards) branches. Because of out-of-order instruction execution in modern CPU pipelines, even arithmetic optimizations are often not nearly as effective as you would expect.

@pdarragh
Copy link
Collaborator Author

pdarragh commented Oct 6, 2022

Yeah, that's a good point, though I can imagine employing some simplifying assumptions in a class setting to make a point. But maybe that's not worth the potential payoff... hm.

@laelath
Copy link

laelath commented Oct 6, 2022

William Bowman actually uses an example of an "obvious" optimization that when you try and measure the performance impact of it ends up being indistinguishable from noise as a demonstration of this kind of thing. i.e. the wrong assumptions could potentially end up making the wrong point.

@pdarragh
Copy link
Collaborator Author

pdarragh commented Oct 6, 2022

Hmmm so probably not worth implementing then, I suppose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants