Skip to content

ffi: add getFunction cache-miss benchmark - #66456

Open
HoonDongKang wants to merge 1 commit into
nodejs:mainfrom
HoonDongKang:ffi/get-function-cache-miss
Open

HoonDongKang wants to merge 1 commit into
nodejs:mainfrom
HoonDongKang:ffi/get-function-cache-miss

Conversation

@HoonDongKang

@HoonDongKang HoonDongKang commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

The comments in get-function.js, added in #64969, describe measuring trampoline creation. However, callable caching introduced in #64971 causes the measured loop to reuse the callable created during warmup, so those comments no longer reflect what the benchmark measures.

Add a cache-miss benchmark to cover first-time function resolution, including trampoline creation.

  • Add get-function-cache-miss.js to measure the first getFunction() call on each library instance. Instances are created before timing, and warmup uses a separate instance to leave the measured caches empty. This includes symbol resolution, signature preparation, and callable creation.

  • Update the existing benchmark comments to describe cache-hit lookups.

Results from 30 runs per signature, measuring cache-hit and cache-miss paths:

Benchmark Signature Mean ops/sec 95% confidence interval
Cache hit (get-function.js) fast 1,159,294.1 ±1.52%
Cache hit (get-function.js) slow 591,408.3 ±1.59%
Cache miss (get-function-cache-miss.js) fast 108,394.0 ±3.96%
Cache miss (get-function-cache-miss.js) slow 145,445.0 ±1.52%

Refs: #64969
Refs: #64971

Assisted-by: Codex:Astra-medium

The existing get-function benchmark reuses the callable cached during
warmup, so it no longer measures trampoline creation.

Add a cache-miss benchmark that resolves a function once per library
instance. Construct the instances before timing to exclude library
loading while including symbol resolution, signature preparation,
and callable creation.

Update the existing benchmark comments to describe cache-hit lookups.

Signed-off-by: HoonDongKang <d159123@naver.com>
Assisted-by: Codex:Astra-medium
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added benchmark Issues and PRs related to Node.js benchmarks and benchmarking infrastructure. ffi Issues and PRs related to experimental Foreign Function Interface support. labels Oct 2, 2026
@addaleax addaleax added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. benchmark Issues and PRs related to Node.js benchmarks and benchmarking infrastructure. ffi Issues and PRs related to experimental Foreign Function Interface support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants