Skip to content

Commit

Permalink
Merge pull request #74 from JuliaData/jps/sra-dec-ctrs
Browse files Browse the repository at this point in the history
SimpleRecencyAllocator: Decr ctrs in delete_from_device
  • Loading branch information
jpsamaroo committed Nov 16, 2023
2 parents fa35a59 + 321ed88 commit 69ca31f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/datastore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ function setup_global_device!(cfg::DiskCacheConfig)
# This detects if a disk cache was already set up
@warn(
"Setting the disk cache config when one is already set will lead to " *
"unexpected behavior and likely cause issues. Please restart the process" *
"before changing the disk cache configuration." *
"unexpected behavior and likely cause issues. Please restart the process " *
"before changing the disk cache configuration. " *
"If this warning is unexpected you may need to " *
"clear the `JULIA_MEMPOOL_EXPERIMENTAL_FANCY_ALLOCATOR` ENV."
)
Expand Down
2 changes: 2 additions & 0 deletions src/storage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1013,12 +1013,14 @@ function delete_from_device!(sra::SimpleRecencyAllocator, state::RefState, id::I
if (idx = findfirst(x->x==id, sra.mem_refs)) !== nothing
delete_from_device!(CPURAMDevice(), state, id)
deleteat!(sra.mem_refs, idx)
sra.mem_size[] -= state.size
end
if (idx = findfirst(x->x==id, sra.device_refs)) !== nothing
if !sra.retain[]
delete_from_device!(sra.device, state, id)
end
deleteat!(sra.device_refs, idx)
sra.device_size[] -= state.size
end
delete!(sra.ref_cache, id)
end
Expand Down
18 changes: 17 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ end
# They know about this DRef
@assert haskey(MemPool.datastore_counters, $key2)
# They own it, and are told when others receive it (and we have received it, but they're already aware of that)
@show MemPool.datastore_counters[$key2].worker_counter[]
@assert MemPool.datastore_counters[$key2].worker_counter[] >= 1
@assert length(MemPool.datastore_counters[$key2].recv_counters) == 0
# They don't hold a local reference to it
Expand Down Expand Up @@ -639,6 +638,23 @@ sra_ondisk_pos(sra, ref, idx) =
@test isempty(sra.mem_refs)
@test isempty(sra.device_refs)
@test length(readdir(dirname)) == 8

# Counters are properly cleared (https://github.com/JuliaParallel/DTables.jl/issues/60)
sra = MemPool.SimpleRecencyAllocator(8*10, sdevice2, 8*10_000, :LRU)
function generate()
poolset(collect(1:10); device=sra)
poolset(collect(1:10); device=sra)
return
end
generate()
@test sra.mem_size[] > 0
@test sra.device_size[] > 0
for _ in 1:3
GC.gc()
yield()
end
@test sra.mem_size[] == 0
@test sra.device_size[] == 0
end

@testset "Mountpoints and Disk Stats" begin
Expand Down

0 comments on commit 69ca31f

Please sign in to comment.