I rewrote jscpd (copy/paste detector, 223 languages) in Rust for v5 β benchmarks show 24β37x faster than the Node.js version
JavaScript/TypeScript Code Duplication (JSCPD) Ignore Imports - Stack Overflow
jscpd v4.2.0 just landed with Svelte support β thought this community might find it useful! π§Ή
Finding duplicate code?
Β» npm install jscpd
Hey r/rust π
I'm the author of jscpd β a copy/paste detection CLI tool for source code, supporting 223 languages/formats. It's been around for years as a TypeScript/Node.js tool. Starting with v5, I rewrote the core engine in Rust.
Here are the actual benchmark numbers (10 runs, Apple Silicon, v4.2.5 Node.js vs v5.0.4 native binary):
Target v4 (Node.js) v5 (Rust) Speedup βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ fixtures (548 files, 1.5 MB) 1.030s 0.030s 34.3x svelte (9K files, 164 MB) 15.803s 0.428s 36.9x CopilotKit (17K files, 902 MB) 82.890s 3.440s 24.1x
A few things that stand out from the data:
Startup overhead is gone. On the tiny fixtures run, v4 takes 1.03s β that's almost entirely Node.js startup. v5 is 0.03s, consistent to the millisecond across all 10 runs (std dev: 0.000s).
Multi-threading shows up clearly. On CopilotKit, v5 reports 7.3s user time vs 3.4s real time β it's genuinely using multiple cores. v4 is strictly single-threaded (user β real throughout).
Blame mode is a special story. v4 shells out to git blame per file, which tanks its --blame performance badly (3.57s vs 1.03s baseline β a 3.5x regression from its own non-blame mode). v5 uses gitoxide for in-process blame, so --blame adds only ~0.10s. Same feature, night and day.
Detection improved too. v5 finds more clones on large codebases β on CopilotKit, 22,487 vs 12,272 clones β likely due to better token counting and different maxSize defaults.
The CLI is still installable via npm (npm i -g jscpd) since most users are in the JS ecosystem, but under the hood it's a native binary now. Pre-built binaries for Linux/macOS/Windows ship with each release.
The 223-language support survived the rewrite intact β everything from TypeScript and Rust to COBOL, Terraform, and Solidity.
Would love any feedback from the Rust community on the implementation β especially around the tokenizer architecture and language registry design. Code at github.com/kucherenko/jscpd, site at jscpd.dev.
Happy to answer questions about the rewrite process or the profiling methodology.
Hi everyone! π
I'm fairly new here, so I hope this kind of post is welcome β please let me know if there's a better place to share it!
I just wanted to give a heads-up that jscpd v4.2.0 has landed with official Svelte support, and I thought the community might find it genuinely useful.
What is jscpd?
If you haven't come across it before, jscpd is a copy/paste detector for source code. It scans your project, finds duplicated blocks across files, and reports them β a really handy tool for spotting technical debt before it piles up. It supports 150+ languages and formats, and now .svelte is officially one of them.
Why does this matter for us?
Svelte's component model makes it wonderfully easy to build UIs quickly β but in larger projects it's easy to accidentally duplicate logic across components: repeated event handlers, similar reactive declarations, copy-pasted template sections. Having a tool that understands .svelte file structure (rather than just treating them as plain text) means you can actually catch those patterns automatically.
Getting started is pretty simple:
npm install -g jscpd jscpd --format svelte ./src
You can also add it to your CI pipeline with a threshold to fail the build if duplication gets too high:
jscpd --format svelte --threshold 5 ./src
I've been wanting this for a while in my own Svelte projects, so I was really happy to see it land. Huge thanks to the maintainers for making it happen! π
Full changelog here if you're curious: https://github.com/kucherenko/jscpd/blob/master/CHANGELOG.md
Hope this is helpful to someone β happy to answer any questions if I can! π