A much faster mgsub — Stable Diffusion Tips & Insights
    Neura MarketNeura Market/Stable Diffusion
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityStable DiffusionStable Diffusion
    DeepSeekDeepSeekCoPilotCoPilotMidjourneyMidjourney
    View All Directories
    OverviewPromptsBlogVideosGuidesCoursesCommunityModelsLoRAsComfyUI WorkflowsTrending
    Stable DiffusionBlogA much faster mgsub
    Back to Blog
    A much faster mgsub
    opensource

    A much faster mgsub

    Mark May 6, 2026
    0 views

    Celebrating a new release of the 1154th most download R package!


    title: A much faster mgsub published: true description: Celebrating a new release of the 1154th most download R package! tags: cover_image: https://s3.amazonaws.com/mgsub/logo_faster.jpg published_at: 2026-05-06 12:00 +0000

    I've never thought of myself as a developer and honestly, neither have most other people. My job for the last several years has been anything but, despite the juice I try to squeeze from that orange. But there was a glorious time back in 2018 when I was part of an awesome team and we would challenge each other solve problems in interesting ways (not coincidentally when I last posted here). One of these problems seemed pretty minor at first but turned into a fun solve - how do you simultaneously substitute multiple strings safely? So you have 'hey, ho, let's go!' and you want to replace 'hey' with 'ho' and 'ho' with 'hey' (it's a dumb example, I know). If you do your substitutions one at a time you end up with either 'hey, hey' or 'ho, ho' depending on the order. In the R language (I grew up as a statistician and it will always be my first love) I solved it and I felt pretty proud. I had a blog at the time and I gloated about how other attempts to solve the problem in R invariably ran into problems because they took shortcuts. I humbly acknowledged there was a performance difference between the different solutions but crowed that nobody would care! Safety was all that mattered! The author of one of the packages (much bigger than mine) noted that the performance difference became significant on larger bodies of text and that for most practical use cases, the edge cases weren't a real risk. Humbled (and honored that he still included my package as a dependency in case safety was critical) I started thinking about how to solve the problem.

    R, like many high level languages, is built on lower level languages, specifically C and Fortran and provided mechanisms for writing functions in those languages to be more performant in addition to having support for C++ which can call R through it's C API.

    I have finally gotten around to converting key functions to C++ and oh my, is the performance better. I had two benchmarks, first, a list of 10,000 strings with 20 matches and 20 replacements. The second was a single string with nearly 200,000 characters (equivalent to more than a 100 page book) also with 20 matches and 20 replacements. Average time to complete the work is listed in the table below.

    TaskBase RC++Improvement
    10,000 Strings4s1s4x
    200,000 Characters48s9.5s5x

    I thought I must have done something wrong when I saw the results initially and so I reran them only to get the same results again. So I'm excited to be publishing up version 2.0 of mgsub to CRAN. There may be no new functionality, but there's a lot more performance.

    And who knows? Maybe this will take me from the 1154th position in lifetime downloads to 1153rd!

    Tags

    opensourceperformanceprogrammingshowdev

    Comments

    More Blog

    View all
    Context bankruptcy: The case for strategic forgetting for AI Agentsai

    Context bankruptcy: The case for strategic forgetting for AI Agents

    Most of us have seen a coding agent fail to complete a task we know it can do. We just don't...

    J
    James O'Reilly
    Parallel Compliance Engine: Drive-to-Sheets Multi-Agent Orchestrationgooglecloud

    Parallel Compliance Engine: Drive-to-Sheets Multi-Agent Orchestration

    When building Generative AI applications, developers often encounter a massive bottleneck: sequential...

    A
    Aryan Irani
    Is It Ethical to Post and Ask About Circuits on Dev.to?discuss

    Is It Ethical to Post and Ask About Circuits on Dev.to?

    I’ve been thinking about sharing some electronic circuit posts on Dev.to — small circuits, DIY...

    C
    codebunny20
    The One-Click Exporter: AI Studio Antigravity, Probed to Its Limitsagents

    The One-Click Exporter: AI Studio Antigravity, Probed to Its Limits

    What nobody tells you about exporting your multi-agent prototype to a local workspace. Every...

    L
    leslysandra
    Guarding the till while autonomous data agents do the diggingagenticarchitect

    Guarding the till while autonomous data agents do the digging

    Autonomous agents are genuinely good at answering messy business questions. Give one an LLM and a set...

    S
    Sireesha Pulipati
    Return on Attention: Why AI Code Reviews Are Wearing Us Outai

    Return on Attention: Why AI Code Reviews Are Wearing Us Out

    PR volume went up, ticket quality didn't, and the gap got filled with LLMs on both sides of the review: bots reviewing, bots replying, bots occasionally arguing with bots about priorities that only existed in a teammate's head. Our CEO named the actual problem, and it's bigger than code review.

    C
    christine

    Stay up to date

    Get the latest Stable Diffusion prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Stable Diffusion and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this Stable Diffusion resource

    • Automate GitHub Release Notifications with Scheduled Checksn8n · $16.62 · Related topic
    • Automate PDF Download and Delivery via Webhookn8n · $15.83 · Related topic
    • Automate Release Management with Sentry.io and N8Nn8n · $14.33 · Related topic
    • Automated GitHub Release Notifications via Emailn8n · $11.93 · Related topic
    Browse all workflows