JuliaInterop / JuliaInterop/JuliaCall

Proposal: _fast variants for lower-overhead Julia calls

Open
#286 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
287
Forks
43
PR merge metrics
No merged PRs in 30d

Description

The current overhead for me calling julia_call("sqrt", 2) is ~7μs. Providing a _fast equivalent stripping it of some QoL stuff reduces this overhead to ~4.5μs for me. Here is the code I added:

julia_do.call_fast <- julia$do.call_fast <- function(func_name, arg_list) {
    r <- .julia$do.call_(list(fname = func_name, args = arg_list, need_return = "R", show_value = FALSE))
    if (inherits(r, "error")) stop(r)
    r
}

julia_call_fast <- julia$call_fast <- function(func_name, ...)
    julia$do.call_fast(func_name, list(...))

And benchmark:

bench::mark(julia_call("sqrt", 2), julia_call_fast("sqrt", 2))[, 1:3]
# A tibble: 2 × 3
  expression                          min   median
  <bch:expr>                     <bch:tm> <bch:tm>
1 "julia_call(\"sqrt\", 2)"         6.4µs    7.0µs
2 "julia_call_fast(\"sqrt\", 2)"    4.1µs    4.5µs

Happy to make a PR if you want these added _fast equivalents. I also understand if saving ~2.5μs per call isn't worth the new API.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing julia_call and julia$do.call_ entry points and compare their current overhead-related behavior with the proposed wrappers. Confirm the fast variants preserve the shown error handling and return behavior, then benchmark julia_call against julia_call_fast to verify the intended reduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.