Skip to content

Commit

Permalink
Add a type assertion to remove some invalidations
Browse files Browse the repository at this point in the history
This removes about 55 invalidations from Base._any(). Not sure why
storage_read() fails to infer by itself, perhaps because it's using atomics?
  • Loading branch information
JamesWrigley committed Apr 2, 2024
1 parent ac520da commit f7bdf66
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/storage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,10 @@ function sra_migrate!(sra::SimpleRecencyAllocator, state::RefState, ref_id, to_m
# and go to the "to" device. The passed-in ref is inserted into the
# "from" device.
if ismissing(to_mem)
# Try to minimize reads/writes
sstate = storage_read(state)
# Try to minimize reads/writes. Note the type assertion to help the
# compiler with inference, this removes some Base._any() invalidations.
sstate::StorageState = storage_read(state)

if sstate.data !== nothing
# Try to keep it in memory
to_mem = true
Expand Down

0 comments on commit f7bdf66

Please sign in to comment.