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

Activate specialisation for functions with function input #82

Closed
SamuelBrand1 opened this issue Feb 28, 2024 · 3 comments · Fixed by #83
Closed

Activate specialisation for functions with function input #82

SamuelBrand1 opened this issue Feb 28, 2024 · 3 comments · Fixed by #83
Assignees
Labels

Comments

@SamuelBrand1
Copy link
Collaborator

Problem

I think it is safer performance wise to activate type specialisation for functions that ingest other functions, see this.

Solution

Fix this for scan and check other possible usages.

@seabbs
Copy link
Collaborator

seabbs commented Feb 28, 2024

Could you touch on https://docs.julialang.org/en/v1/devdocs/functions/#compiler-efficiency-issues - as this was noted as a potential downside in the resource you gave.

Did you also consider for scan specifically using a already existing implementation (i.e. Rocket.jl) and if yes why did you discount it? If no should we make a new issue for this?

@SamuelBrand1
Copy link
Collaborator Author

So specialisation is used typically in functions like map (as mentioned in the link) to boost performance.

Many functions simply "pass through" an argument to somewhere else, e.g. to another function or to a storage location. Such functions do not need to be specialized for every closure that might be passed in. Fortunately this case is easy to distinguish by simply considering whether a function calls one of its arguments (i.e. the argument appears in "head position" somewhere). Performance-critical higher-order functions like map certainly call their argument function and so will still be specialized as expected.

We are using specialisation in the map function sense; its not passing a function (or function-like object) to get lowered down, its going to operate on elements of a vector in sequence with stateful updates.

I am not using the Rocket.jl version of scan because its pretty heavily embedded in using Observables, which just seems like over-kill to import en-masse into this project.

@seabbs
Copy link
Collaborator

seabbs commented Feb 28, 2024

Awesome thanks. Both of those points make sense to me.

@seabbs seabbs added this to the EpiAware 0.1.0 milestone Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants