Skip to content

Add Falcon support and per-fiber allocation counts - #638

Closed
jtarchie wants to merge 1 commit into
scoutapp:masterfrom
jtarchie:falcon-support
Closed

jtarchie wants to merge 1 commit into
scoutapp:masterfrom
jtarchie:falcon-support

Conversation

@jtarchie

Copy link
Copy Markdown

Under Falcon the agent has no server integration, so it reports the app server as null and starts lazily on each worker's first request. This adds ServerIntegrations::Falcon. It reports falcon and starts the agent in every forked worker through Process._fork, which also covers workers the supervisor restarts. It deliberately does not start in the preloading parent, which serves no requests and keeps forking: a reporting thread caught mid-request at fork time could leave locks held in the child.

The bigger problem is allocations. Falcon runs many requests on one thread as fibers, and the allocation counter is per OS thread, so each request was charged for the allocations of every request overlapping it. At about 44 overlapping requests per worker, a request allocating about 24k objects was reported at about 4M. The extension now charges allocations to the running fiber on RUBY_EVENT_FIBER_SWITCH. With this branch, the same Rails app under real Falcon reports about 24k whether requests overlap or not, and the per-request layers, SQL and HTTP spans are unchanged. The full suite passes locally on Ruby 4.0.7 with and without SCOUT_USE_PREPEND (287 runs, 0 failures), and new tests cover both changes.

🤖 Generated with Claude Code

Falcon preloads the app, forks worker processes, and serves many
concurrent requests per worker as fibers on one thread. Without an
integration the agent falls back to Null: it reports the app server
as "null" and starts lazily on each worker's first request.

ServerIntegrations::Falcon reports "falcon" and starts the agent in
every forked child through Process._fork (Ruby >= 3.1), so workers the
supervisor restarts are covered too. It defers start in the preloading
parent, which serves no requests, so no reporting thread is mid-request
when Falcon forks.

The allocation counter is per OS thread, so every request on a Falcon
worker was charged for the allocations of every request overlapping
it. The extension now charges allocations to the running fiber on each
RUBY_EVENT_FIBER_SWITCH, and Allocations.count returns the current
fiber's total. Single-fiber threads see no change.
@jtarchie jtarchie closed this Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant