SShortSingh.
Back to feed

Rails optimization cuts role queries by up to 99% on Forem's dev.to codebase

0
·1 views

A performance optimization merged into Forem, the open-source codebase behind dev.to, has reduced redundant database role queries by 75% to 99.3% across four key request paths. The core issue was that Rolify's authorization checks repeatedly issued COUNT or EXISTS SQL queries for the same users, even when their role data could have been loaded once. The fix modifies the Authorizer layer to inspect Active Record's in-memory association state, using cached role data when available and falling back to database queries only when necessary. Preloading roles via Active Record eliminated per-user N+1 query patterns in the admin member list and CSV export paths. The changes were regression-tested and merged upstream, also delivering measurable reductions in SQL duration, memory allocations, and overall request time.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Fitz Framework Lets WASM Components Call Server Functions Without HTTP Boilerplate

Fitz, a full-stack web framework, introduces an @rpc decorator that automatically generates both a server-side HTTP endpoint and a client-side fetch stub from a single async function declaration. Developers can call server logic directly from a WebAssembly component as if it were a local function, using standard await syntax, with no hand-written HTTP handlers, fetch calls, or JSON parsing required. The same type definition is compiled for both the server and the WASM client, eliminating type drift between front and back ends. This is the seventh installment in a series documenting Fitz's component model, and the feature draws conceptual parallels to server actions in Next.js, tRPC, and Remix. The framework handles serialization, routing, and async state updates automatically, requiring no external dependencies beyond the built-in HTTP stack.

0
ProgrammingDEV Community ·

Fitz Framework Lets WASM Components Call Server Functions Without Manual API Wiring

Fitz, a web framework, introduces an @rpc decorator that allows developers to mark server-side async functions and call them directly from WebAssembly client components as if they were local calls. The compiler automatically generates both the server-side HTTP endpoint (POST /__rpc/function_name) and a client-side fetch stub, eliminating the need to write routes, JSON glue code, or duplicate type definitions. A single shared type defined in the server module is compiled into both a native struct for the backend and a WASM struct for the frontend, preventing type drift between the two sides. The approach draws comparison to existing solutions like Next.js Server Actions, tRPC, and Phoenix, but requires no external dependencies, code generators, or special directives beyond the single decorator. This feature is presented as Part 7 of the ongoing FitzLiveViews series, building on earlier work covering server-rendered and WebSocket-based component compilation.

0
ProgrammingDEV Community ·

Open-Source AgentJIT Compiles AI Agent Workflows from 30s LLM Chains to 0.1ms Python

A developer has open-sourced AgentJIT, a just-in-time compiler designed to eliminate latency and cost inefficiencies in AI agent workflows. The tool works by tracing an agent's tool-call sequence on its first run and compiling the resulting execution path into a deterministic Python AST pipeline for all subsequent runs. This approach reduces multi-step LLM chain execution times from up to 45 seconds down to under 0.1 milliseconds, with no token costs on compiled runs. The compiler automatically inserts runtime input guards that trigger a fallback to the original LLM agent if unexpected inputs are detected, preventing crashes or regressions. AgentJIT is available as a self-contained Python library with no mandatory external dependencies and can be applied via simple decorators.

0
ProgrammingDEV Community ·

Oracle Autonomous AI Database 26ai Merges AI, Analytics, and Vector Search in One Platform

Oracle's Autonomous AI Database 26ai is a converged database platform designed to handle relational data, JSON, graph, spatial data, and vector embeddings within a single system. The platform aims to eliminate the complexity of managing multiple specialized tools by combining database storage, machine learning, analytics, and application development capabilities together. A key feature is its autonomous operation, which automates routine administrative tasks such as patching, backups, and performance monitoring, reducing the need for dedicated database administrators. Oracle AI Vector Search, another highlight of the platform, enables semantic similarity searches using numerical embeddings rather than exact keyword matching, powering technologies like Retrieval-Augmented Generation and enterprise knowledge search. The platform targets organizations looking to adopt AI solutions without building and maintaining complex multi-technology architectures.

Rails optimization cuts role queries by up to 99% on Forem's dev.to codebase · ShortSingh