Skip to content

Commit 69ca31f

Browse files
authored
Merge pull request #74 from JuliaData/jps/sra-dec-ctrs
SimpleRecencyAllocator: Decr ctrs in delete_from_device
2 parents fa35a59 + 321ed88 commit 69ca31f

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/datastore.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ function setup_global_device!(cfg::DiskCacheConfig)
521521
# This detects if a disk cache was already set up
522522
@warn(
523523
"Setting the disk cache config when one is already set will lead to " *
524-
"unexpected behavior and likely cause issues. Please restart the process" *
525-
"before changing the disk cache configuration." *
524+
"unexpected behavior and likely cause issues. Please restart the process " *
525+
"before changing the disk cache configuration. " *
526526
"If this warning is unexpected you may need to " *
527527
"clear the `JULIA_MEMPOOL_EXPERIMENTAL_FANCY_ALLOCATOR` ENV."
528528
)

src/storage.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,12 +1013,14 @@ function delete_from_device!(sra::SimpleRecencyAllocator, state::RefState, id::I
10131013
if (idx = findfirst(x->x==id, sra.mem_refs)) !== nothing
10141014
delete_from_device!(CPURAMDevice(), state, id)
10151015
deleteat!(sra.mem_refs, idx)
1016+
sra.mem_size[] -= state.size
10161017
end
10171018
if (idx = findfirst(x->x==id, sra.device_refs)) !== nothing
10181019
if !sra.retain[]
10191020
delete_from_device!(sra.device, state, id)
10201021
end
10211022
deleteat!(sra.device_refs, idx)
1023+
sra.device_size[] -= state.size
10221024
end
10231025
delete!(sra.ref_cache, id)
10241026
end

test/runtests.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ end
198198
# They know about this DRef
199199
@assert haskey(MemPool.datastore_counters, $key2)
200200
# They own it, and are told when others receive it (and we have received it, but they're already aware of that)
201-
@show MemPool.datastore_counters[$key2].worker_counter[]
202201
@assert MemPool.datastore_counters[$key2].worker_counter[] >= 1
203202
@assert length(MemPool.datastore_counters[$key2].recv_counters) == 0
204203
# They don't hold a local reference to it
@@ -639,6 +638,23 @@ sra_ondisk_pos(sra, ref, idx) =
639638
@test isempty(sra.mem_refs)
640639
@test isempty(sra.device_refs)
641640
@test length(readdir(dirname)) == 8
641+
642+
# Counters are properly cleared (https://github.com/JuliaParallel/DTables.jl/issues/60)
643+
sra = MemPool.SimpleRecencyAllocator(8*10, sdevice2, 8*10_000, :LRU)
644+
function generate()
645+
poolset(collect(1:10); device=sra)
646+
poolset(collect(1:10); device=sra)
647+
return
648+
end
649+
generate()
650+
@test sra.mem_size[] > 0
651+
@test sra.device_size[] > 0
652+
for _ in 1:3
653+
GC.gc()
654+
yield()
655+
end
656+
@test sra.mem_size[] == 0
657+
@test sra.device_size[] == 0
642658
end
643659

644660
@testset "Mountpoints and Disk Stats" begin

0 commit comments

Comments
 (0)