https://github.com/jakobjpeters/speculator.jl
Reduce latency in a single line of code
https://github.com/jakobjpeters/speculator.jl
compilation julia latency precompilation
Last synced: 6 months ago
JSON representation
Reduce latency in a single line of code
- Host: GitHub
- URL: https://github.com/jakobjpeters/speculator.jl
- Owner: jakobjpeters
- License: mit
- Created: 2024-11-27T19:57:26.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-21T10:24:09.000Z (6 months ago)
- Last Synced: 2025-07-21T11:20:57.374Z (6 months ago)
- Topics: compilation, julia, latency, precompilation
- Language: Julia
- Homepage: https://jakobjpeters.github.io/Speculator.jl/
- Size: 496 KB
- Stars: 31
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE.md
Awesome Lists containing this project
README

# Speculator.jl
[](https://jakobjpeters.github.io/Speculator.jl/)
[](https://jakobjpeters.github.io/Speculator.jl/development/)
[](https://github.com/jakobjpeters/Speculator.jl/actions/workflows/continuous_integration.yml)
[](https://github.com/jakobjpeters/Speculator.jl/actions/workflows/documentation.yml)
[](https://codecov.io/gh/jakobjpeters/Speculator.jl)
[](https://juliapkgstats.com/pkg/Speculator)
[](https://juliahub.com/ui/Packages/General/Speculator?t=2)
## Introduction
Speculator.jl reduces latency by automatically searching for compilable methods.
## Usage
### Installation
```julia-repl
julia> using Pkg: add
julia> add("Speculator")
julia> using Speculator
```
### Showcase
```julia-repl
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
- [CompileTraces.jl](https://github.com/serenity4/CompileTraces.jl)
- [JuliaScript.jl](https://github.com/jolin-io/JuliaScript.jl)
- [PackageCompiler.jl](https://github.com/JuliaLang/PackageCompiler.jl)
- [PrecompileSignatures.jl](https://github.com/rikhuijzer/PrecompileSignatures.jl)
- [PrecompileTools.jl](https://github.com/JuliaLang/PrecompileTools.jl)
### Reflection
- [Cthulhu.jl](https://github.com/JuliaDebug/Cthulhu.jl)
- [JET.jl](https://github.com/aviatesk/JET.jl)
- [LookingGlass.jl](https://github.com/NHDaly/LookingGlass.jl)
- [MethodAnalysis.jl](https://github.com/timholy/MethodAnalysis.jl)
- [MethodInspector.jl](https://github.com/bluesmoon/MethodInspector.jl)
- [PkgCacheInspector.jl](https://github.com/timholy/PkgCacheInspector.jl)
- [SnoopCompile.jl](https://github.com/timholy/SnoopCompile.jl)
- [SnoopCompileCore.jl](https://github.com/timholy/SnoopCompile.jl/tree/master/SnoopCompileCore)
## Acknowledgements
Credit to [Cameron Pfiffer](https://github.com/cpfiffer) 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](https://github.com/JuliaLang/PrecompileTools.jl/issues/28).