Compare commits

...

2 Commits

Author SHA1 Message Date
Claude Bot
a8eb01cf2e Refactor FFI analytics to track only successful completions
Move analytics.Features.ffi increments from internal compile functions
to the JS host function return points. This ensures we only count FFI
usage when operations successfully complete and return to JavaScript:

- dlopen (FFI.open): Increment after library loads and symbols compile
- TCC compile (Bun__FFI__cc): Increment after C code compiles successfully
- Callbacks (FFI.callback): Increment after callback wrapper compiles

Removed increments from internal helpers (CompileC.compile,
Function.compile, Function.compileCallback) to avoid double-counting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 23:49:03 +00:00
Claude Bot
6a6e861ded Add "ffi" to analytics.Features and track FFI usage
Track FFI feature usage by incrementing analytics.Features.ffi when:
- dlopen is called to load dynamic libraries
- TCC.compile is invoked for CompileC.compile
- TCC.compile is invoked for Function.compile
- TCC.compile is invoked for Function.compileCallback

This provides visibility into FFI usage across the Bun runtime.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 23:23:31 +00:00
2 changed files with 6 additions and 0 deletions

View File

@@ -87,6 +87,7 @@ pub const Features = struct {
pub var yarn_migration: usize = 0;
pub var pnpm_migration: usize = 0;
pub var yaml_parse: usize = 0;
pub var ffi: usize = 0;
comptime {
@export(&napi_module_register, .{ .name = "Bun__napi_module_register_count" });

View File

@@ -802,6 +802,8 @@ pub const FFI = struct {
bytes_to_free_on_error = "";
compile_c.symbols = .{};
bun.analytics.Features.ffi += 1;
const js_object = lib.toJS(globalThis);
jsc.Codegen.JSFFI.symbolsValueSetCached(js_object, globalThis, obj);
return js_object;
@@ -851,6 +853,7 @@ pub const FFI = struct {
.compiled => {
const function_ = bun.default_allocator.create(Function) catch unreachable;
function_.* = func.*;
bun.analytics.Features.ffi += 1;
return JSValue.createObject2(
globalThis,
ZigString.static("ptr"),
@@ -1149,6 +1152,8 @@ pub const FFI = struct {
.functions = symbols,
});
bun.analytics.Features.ffi += 1;
const js_object = lib.toJS(global);
jsc.Codegen.JSFFI.symbolsValueSetCached(js_object, global, obj);
return js_object;