Skip to content

jakobjpeters/Speculator.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Speculator.jl

Documentation Stable Documentation Development

Continuous Integration Workflow Documentation Workflow

Codecov

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 = debug)
[ Info: Compiled `Main.Showcase.g(::Int)`
[ Info: Compiled `Main.Showcase.f()`

julia> speculate(Base.isexported, Showcase; verbosity = debug)
[ Info: Skipped `Main.Showcase.g(::Int)`

julia> speculate(Showcase.h; limit = 2, verbosity = debug)
[ Info: Compiled `Main.Showcase.h(::String)`
[ Info: Compiled `Main.Showcase.h(::Symbol)`

julia> install_speculator(; limit = 4, verbosity = debug)
[ Info: The input speculator has been installed into the REPL

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

[ Info: Compiled `Main.i(::Symbol, ::LinearAlgebra.WrapperChar)`
[ Info: Compiled `Main.i(::String, ::LinearAlgebra.WrapperChar)`
[ Info: Compiled `Main.i(::Symbol, ::Char)`
[ Info: Compiled `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

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.