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

feed quasiquote variables in as arguments #30

Merged
merged 2 commits into from
Dec 7, 2016

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Nov 23, 2016

interpolating these into the AST gives the optimizer too much flexibility
for a benchmark, that can mean the compiler will be able to just constant-fold away the work
this rewrites the quasiquote interpolation variables as setup variables, rather than capturing their values directly in the function, thereby ensuring the compiler can't optimize the function based upon their values

interpolating these into the AST gives the optimizer too much flexibility
for a benchmark, that can mean the compiler will be able to just constant-fold away the work
@jrevels
Copy link
Member

jrevels commented Nov 23, 2016

Thanks! This is a really valuable change, and will only get more useful as the compiler gets smarter.

@@ -203,8 +220,14 @@ macro benchmarkable(args...)
end
deleteat!(params, delinds)

quote_vars = Expr[]
core = quasiquote!(core, quote_vars)
Copy link
Member

Choose a reason for hiding this comment

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

The test failure comes from catching the possible (though extreme) case where core here is a Symbol.

@StefanKarpinski
Copy link

Wouldn't it be better to automatically do this for any bindings from the outer scope? I.e. instead of having to quasiquote globals to measure the right thing, just do it automatically.

@jrevels
Copy link
Member

jrevels commented Nov 23, 2016

Wouldn't it be better to automatically do this for any bindings from the outer scope? I.e. instead of having to quasiquote globals to measure the right thing, just do it automatically.

This was originally the case when this package was still in its initial development phase, but after spending some time with it, I ended up going with the current behavior. It's less magical, less bug-prone, and encourages users to be explicit with regards to (and thus think carefully about) variable scoping in the benchmark expression. I did think about "inverting" the current behavior (e.g. variables would be local by default and global if you "interpolated" them), but that ended up being confusing to use/implement via interpolation syntax.

not sure what it means to benchmark a constant value, but need to handle this case anyways
@vtjnash
Copy link
Member Author

vtjnash commented Nov 24, 2016

Thanks jrevels. I leave it up to you what you want to do with this. With the change you mentioned, it now passes CI (it looks like the mac buildbots had network issues). I just mostly wanted to see if it was possible / how it would work. This is probably not a complete unquote implementation (it doesn't handle nesting, although perhaps it doesn't need to), but I thought it might be interesting to play with.

@jrevels jrevels merged commit cf5215c into JuliaCI:master Dec 7, 2016
jrevels referenced this pull request in JuliaLang/julia Feb 8, 2017
Improve inferability of unique
@vtjnash vtjnash deleted the jn/quasiquote branch April 17, 2021 13:02
@vtjnash vtjnash restored the jn/quasiquote branch April 17, 2021 13:02
@vtjnash vtjnash deleted the jn/quasiquote branch April 17, 2021 13:02
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.

3 participants