An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# Speculator.jl

[![Documentation Stable](https://img.shields.io/badge/Documentation-stable-blue.svg)](https://jakobjpeters.github.io/Speculator.jl/)
[![Documentation Development](https://img.shields.io/badge/Documentation-development-blue.svg)](https://jakobjpeters.github.io/Speculator.jl/development/)

[![Continuous Integration Workflow](https://github.com/jakobjpeters/Speculator.jl/workflows/Continuous%20Integration/badge.svg)](https://github.com/jakobjpeters/Speculator.jl/actions/workflows/continuous_integration.yml)
[![Documentation Workflow](https://github.com/jakobjpeters/Speculator.jl/workflows/Documentation/badge.svg)](https://github.com/jakobjpeters/Speculator.jl/actions/workflows/documentation.yml)

[![Codecov](https://codecov.io/gh/jakobjpeters/Speculator.jl/graph/badge.svg?token=KNLZXD2MV0)](https://codecov.io/gh/jakobjpeters/Speculator.jl)
[![Downloads](https://img.shields.io/badge/dynamic/json?url=http%3A%2F%2Fjuliapkgstats.com%2Fapi%2Fv1%2Fmonthly_downloads%2FSpeculator&query=total_requests&suffix=%2Fmonth&label=Downloads)](https://juliapkgstats.com/pkg/Speculator)
[![Dependents](https://juliahub.com/docs/General/Speculator/stable/deps.svg)](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).