Skip to content

Commit

Permalink
QUERY_MEM: Add cache override
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsamaroo committed Jan 10, 2024
1 parent 93ae638 commit a74be1e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
strategy:
matrix:
julia-version:
- '~1.7'
- '~1.8'
- '~1.9'
- 'nightly'
Expand Down
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"

[compat]
DataStructures = "0.18"
julia = "1.7"
ScopedValues = "1"
julia = "1.8"

[extras]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
1 change: 1 addition & 0 deletions src/MemPool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Serialization, Sockets, Random
import Serialization: serialize, deserialize
export DRef, FileRef, poolset, poolget, mmwrite, mmread, cleanup
import .Threads: ReentrantLock
using ScopedValues

## Wrapping-unwrapping of payloads:

Expand Down
3 changes: 2 additions & 1 deletion src/storage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ QueriedMemInfo() = QueriedMemInfo(UInt64(0), UInt64(0))
const QUERY_MEM_AVAILABLE = Ref(QueriedMemInfo())
const QUERY_MEM_CAPACITY = Ref(QueriedMemInfo())
const QUERY_MEM_PERIOD = 10 * 1000^2 # 10ms
const QUERY_MEM_OVERRIDE = ScopedValue(false)
function _query_mem_periodically(kind::Symbol)
if !(kind in (:available, :capacity))
throw(ArgumentError("Invalid memory query kind: $kind"))
Expand All @@ -197,7 +198,7 @@ function _query_mem_periodically(kind::Symbol)
end
mem_info = mem_bin[]
now_ns = time_ns()
if mem_info.last_ns < now_ns - QUERY_MEM_PERIOD
if QUERY_MEM_OVERRIDE[] || mem_info.last_ns < now_ns - QUERY_MEM_PERIOD
if kind == :available
new_mem_info = QueriedMemInfo(free_memory(), now_ns)
elseif kind == :capacity
Expand Down

0 comments on commit a74be1e

Please sign in to comment.