SShortSingh.
Back to feed

Custom UTF-8 decoder caused 32x slowdown and OOM crashes in Node.js service

0
·1 views

A developer profiling a Node.js service discovered that processing three concurrent 18.7 MB JSON-RPC responses crashed the process due to out-of-memory errors on a 1 GB heap. The culprit was a custom UTF-8 decoder that created nearly 20 million intermediate array elements and individual character strings per response, consuming up to 794 MB of heap each. Replacing the custom function with the native TextDecoder API reduced processing time from 928ms to 10ms and heap usage from 794 MB to 47.6 MB per response. The fix was a single line of code, with the fatal: true option preserving the original error-handling behavior for invalid UTF-8 input. The case highlights how technically correct custom implementations of platform-native operations can become severe performance liabilities at scale.

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 ·

How One Team Built a WhatsApp AI Agent Serving 20 Industries With 99.7% Uptime

An engineering team has shared 18 months of lessons from running SARA, an open-source WhatsApp AI agent deployed across businesses in 20 industries. The system uses a four-provider AI chain — Groq, Cerebras, SambaNova, and Mistral — with automatic failover and exponential backoff, achieving 99.7% uptime over six months at near-zero inference cost by leveraging free tiers. SARA can execute over 30 real-world actions such as booking reservations, checking inventory, and generating invoices, with a risk-assessment gate that requires human approval for high-stakes operations. The architecture addresses WhatsApp-specific challenges including message ordering, multilingual date parsing, and privacy by anonymizing personal data before it reaches any language model. SARA is released under the AGPL-3.0 license on GitHub, with industry-specific agent definitions available separately under Apache-2.0.

0
ProgrammingHacker News ·

No Reports of AI Systems Forcing Companies to Recognize Worker Unions

A social media post on Mastodon by user Neil highlighted a notable absence in AI-related incident reports. Despite widespread concerns about AI going rogue or causing unintended consequences, no documented cases exist of an AI system compelling a company to recognize a workers union. The observation gained traction on Hacker News, accumulating 34 points and 8 comments. The post appears to draw an ironic contrast between feared AI risks and the kinds of outcomes that might actually benefit workers.

0
ProgrammingDEV Community ·

Dev team built 32,000 AI build prompts to ease Midnight blockchain's steep learning curve

A development team created Creative Midnight, a tool generating around 32,000 self-contained build prompts to help developers onboard onto Midnight, a zero-knowledge Layer 1 blockchain. Midnight's complex setup — involving version-sensitive packages, Docker dependencies, WASM polyfills, and testnet token access — was consuming hours of hackathon developers' time before they could begin building. The team compiled 1,996 project ideas across ten creative disciplines, each paired with a private-state mechanic tailored to Midnight's ZK architecture. For each idea, prompts are dynamically composed per network target and operating system, bundling pinned package versions, toolchain commands, wallet boot code, and known failure fixes. The project aims to eliminate repetitive environment setup so developers can focus on their actual ideas rather than infrastructure troubleshooting.

Custom UTF-8 decoder caused 32x slowdown and OOM crashes in Node.js service · ShortSingh