What is causing my C++ to surpass my Rust code speed only when doing extra large processing?

67 points Lite3000

Windows 10

Edit: I "optimized" the C++ and Rust code:

sort TXT CPP2 - https://pastebin.com/EWka0XTx
Sort TXT RUST2 - https://pastebin.com/UHDb3wYy

2.8 MB txt file:
Rust: 121 ms
C++: 83 ms

128 MB txt file:
Rust: 4 seconds
C++: 2.9 seconds

Fastest Rust code from a commenter: https://pastebin.com/da8KzXV9

\-------------------

OLD test results:

Calculating first 555,000 prime numbers (sieve of Eratosthenes):
Rust: 25.9 milliseconds
C++: 46 milliseconds

Sorting txt file in Chinese (2.8 MB) (Rust is faster with 1 MB file too):
Rust: 69 milliseconds
C++: 101 milliseconds

Sorting 131 MB txt file in English (same executables as last test):
Rust: 7 seconds
C++ 4 seconds