Skip to content

jakobjpeters/Speculator.jl

Repository files navigation

Speculator.jl

Documentation Stable Documentation Development

Continuous Integration Workflow Documentation Workflow

Codecov Downloads Dependents

Introduction

Speculator.jl reduces latency by automatically searching for compilable methods.

Usage

Installation

julia> using Pkg: add

julia> add("Speculator")

julia> using Speculator

Showcase

julia> module Showcase
           export g, h

           f() = nothing
           g(::Int) = nothing
           h(::Union{String, Symbol}) = nothing
       end;

julia> speculate(Showcase; verbosity = compile)
compile: Main.Showcase.g(::Int64)
compile: Main.Showcase.f()

julia> speculate(Base.isexported, Showcase; verbosity = pass)
pass: Main.Showcase.g(::Int64)

julia> speculate(Showcase.h; verbosity = compile) do m, n
           !(m == Core && n == :String)
       end
compile: Main.Showcase.h(::Symbol)

julia> speculate(Showcase.h; limit = 2, verbosity = compile  pass)
pass: Main.Showcase.h(::Symbol)
compile: Main.Showcase.h(::String)

julia> install_speculator(; limit = 4, verbosity = compile)

julia> i(::Union{String, Symbol}, ::AbstractChar) = nothing;

compile: Main.i(::Symbol, ::LinearAlgebra.WrapperChar)
compile: Main.i(::String, ::LinearAlgebra.WrapperChar)
compile: Main.i(::Symbol, ::Char)
compile: Main.i(::String, ::Char)

Features

  • Precompile packages
  • Compile interactively
  • Filter values
  • Run in the background
  • Handle abstractly typed methods
  • Save compilation directives to a file
  • Show logging statements

Planned

  • Disable during development using Preferences.jl?
  • Support for UnionAll types?

Similar Packages

Precompilation

Reflection

Acknowledgements

Credit to Cameron Pfiffer for the initial idea.

The preexisting package PrecompileSignatures.jl implements similar functionality, notably that PrecompileSignatures.@precompile_signatures ::Module is roughly equivalent to Speculator.speculate(::Module).

The idea to compile concrete method signatures has also been brought up in PrecompileTools.jl #28.

About

Reduce latency in a single line of code

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages