MemPool.jl
MemPool.jl copied to clipboard
`deleteat!` fails in `sra_migrate!`
https://github.com/JuliaData/MemPool.jl/blob/8508088b32caff629ce6905cb263f78cdc068cd6/src/storage.jl#L963
The call to reverse
above assumes to_delete
is in ascending order, which isn't necessarily the case. I didn't thoroughly test, so I don't know what combinations of to_mem
and sra.policy
cause an error, but I got an error about trying to delete an index that didn't exist when using a LRU policy (don't know if to_mem
was true or not). The problem did not occur when I switched to a MRU policy. Sorry I don't have a MWE, though I can reliably reproduce the issue.
My problem went away when I replaced reverse(to_delete)
with sort(to_delete; rev = true)
.
Yeah that's a good find - an alternative to sort(to_delete; rev=true)
is to call sort!(to_delete; rev=true)
, which would reuse the to_delete
array, and should still return it too. Would you be willing to open a PR? I don't know how exactly to test this, aside from implementing a stress-test for MemPool's swap-to-disk (which I do want to do once I find the time).
Sure, I can open a PR when I have time over the next couple of days. I'll ping you when it's ready.