JuliaInterop / JuliaInterop/JuliaCall
Proposal: _fast variants for lower-overhead Julia calls
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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