afaligner icon indicating copy to clipboard operation
afaligner copied to clipboard

Change allocation strategy of the distance matrix to avoid overcommit

Open r4victor opened this issue 5 years ago • 7 comments

The DTWBD() function that performs sequence alignment allocates the whole distance matrix at once. This allocation may request a lot of memory. On Linux and Mac OS this is not a problem because they overcommit:

Overcommit refers to the practice of giving out virtual memory with no guarantee that physical storage for it exists).

And in practice, when the matrix is large, only elements in window are actually used. Windows simply won't allocate memory and return NULL. This caused some bugs before (Issue 1).

The solution is to change the code so that only elements in window are allocated. Like this, for example.

r4victor avatar Feb 12 '21 12:02 r4victor

I tried this on linux as well, I still get the same issue.

ravigupta-art avatar Feb 04 '22 08:02 ravigupta-art

@ravigupta-art did you try turning on overcommit first? Run:

echo 1 | sudo tee /proc/sys/vm/overcommit_memory

In your terminal first.

bhattarai333 avatar Feb 13 '22 14:02 bhattarai333

I had the same issue in Linux and running the code suggested by @bhattarai333 made it work for me.

$ echo 1 | sudo tee /proc/sys/vm/overcommit_memory

versae avatar Jan 14 '23 16:01 versae

This fixes it for me initially, but then I get a "Killed". Error message.. How much ram is needed for a sync? Is 8gb not enough?

WoxWik avatar Feb 01 '23 02:02 WoxWik

@WoxWik, the RAM needed depends on the length of audio files. For example, when syncing a book with chapters up to an hour long (https://librivox.org/the-picture-of-dorian-gray-by-oscar-wilde/), the used memory peaks at about 1GB (tested on M1 MacBook). The used memory grows linearly with the audio length and the allocated memory grows quadratically. 8GB should be enough unless you sync much longer audio files.

r4victor avatar Mar 12 '23 10:03 r4victor

is there any workaround to this issue? i have an 8gb ram laptop and i really needed to sync a 6hour audiobook with this setup. do you happen to know of any software i could use to merge these epub files perhaps, or do you know of any way that perhaps the task could be split into various subtasks within the audiofile ram limits?

alexthesilva avatar Dec 24 '23 16:12 alexthesilva