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

SimpleRecencyAllocator: Decr ctrs in delete_from_device #74

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading