Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive memory usage caused by unique synthetic NFGs in string #1648

Open
Maxdamantus opened this issue Jan 17, 2022 · 1 comment
Open

Comments

@Maxdamantus
Copy link

Using unique graphemes containing 2 or more code points seems to result in memory complexity that is quadratic to the number of graphemes. Example with 50,000 unique graphemes:

$ raku -e 'for 0..50000 { my @a = $_, 0x300; print @a.chrs; };' >test.txt
$ ls -lh test.txt 
-rw-r--r-- 1 max max 242K Jan 17 22:34 test.txt
$ raku -e 'slurp;' <test.txt
Killed
$ raku -v
Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2021.09.
Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
Built on MoarVM version 2021.09.

# dmesg | grep 'Out of memory' | tail -1
[106097.011005] Out of memory: Killed process 16841 (raku) total-vm:15931556kB, anon-rss:15799148kB, file-rss:4kB, shmem-rss:0kB, UID:1000 pgtables:31092kB oom_score_adj:0

Memory consumption seems to be approximately 8.5*(graphemes/1000)^2 MiB, so 44k graphemes will exhaust the memory on my 16 GiB system.

@MasterDuke17
Copy link
Contributor

Here's where heaptrack says the memory is being allocated (for 30k so it wouldn't get killed).

Welcome to Rakudo™ v2021.12-118-g888f05d25.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2021.12-67-g4b2de6d1d.

synthetic_graphemes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants