A much faster mgsub — Perplexity Tips & Insights
    Neura MarketNeura Market/Perplexity
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityTrending
    PerplexityBlogA 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
    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught megemma

    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught me

    I ported the whole Gemma-4 family — E2B, E4B, 12B, 31B, and the 26B-A4B MoE — to run on...

    X
    xbill
    Hey DEV, I'm Tobore. Let's actually connect.community

    Hey DEV, I'm Tobore. Let's actually connect.

    Hey DEV, I'm Tobore. Let's actually connect. I've been on here for a while now, mostly writing and...

    L
    Laurina Ayarah
    I burned through thousands of AI tokens. Then a friend did it for freeai

    I burned through thousands of AI tokens. Then a friend did it for free

    (yep, kinda clickbait, just for the funsies 😊) At the beginning of the year, I relaunched my...

    P
    Paulo Henrique
    Claude might be saturating your machineai

    Claude might be saturating your machine

    My laptop was sitting idle with the fan at full tilt. Nothing was running that I knew of. The culprit...

    S
    Sidhant Panda
    Automated GitHub Code Reviews Using Google Geminigithubactions

    Automated GitHub Code Reviews Using Google Gemini

    I Built a Thing! TL;DR — Google Gemini-based Pull Request reviews and Issue Triaging for...

    D
    Darren "Dazbo" Lester
    What is an "agentic harness," actually?ai

    What is an "agentic harness," actually?

    I've been hearing the word "harness" thrown around a lot lately. I assumed it just meant "the IDE" or...

    T
    Tilde A. Thurium

    Stay up to date

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

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Perplexity 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.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this Perplexity resource

    • Automate SEO-Optimized Blog Creation with GPT-4, Perplexity AI & Multi-Language Supportn8n · $24.99 · Related topic
    • Automate SEO Blog Content Creation with GPT-4, Perplexity AI, and WordPressn8n · $24.99 · Related topic
    • Automate SEO Blog Creation + Social Media with GPT-4, Perplexity, and WordPressn8n · $24.99 · Related topic
    • Auto-Generate SEO Blog Posts with Perplexity, GPT, Leonardo & WordPressn8n · $14.99 · Related topic
    Browse all workflows