-
Notifications
You must be signed in to change notification settings - Fork 4.5k
rework accounts hash calc dedup to avoid kernel file error #33195
rework accounts hash calc dedup to avoid kernel file error #33195
Conversation
Codecov Report
@@ Coverage Diff @@
## master #33195 +/- ##
=======================================
Coverage 82.1% 82.1%
=======================================
Files 786 786
Lines 211596 211608 +12
=======================================
+ Hits 173777 173843 +66
+ Misses 37819 37765 -54 |
150471e
to
8103560
Compare
8103560
to
c14466c
Compare
let map = unsafe { MmapMut::map_mut(&data) }; | ||
let map = map.unwrap_or_else(|e| { | ||
error!( | ||
"Failed to map the data file (size: {}): {}.\n | ||
Please increase sysctl vm.max_map_count or equivalent for your platform.", | ||
self.capacity, e | ||
); | ||
std::process::exit(1); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that in append_vec.rs
if creating the Mmap fails we'll call exit()
, but that feels strange to me. Seems like a panic
or expect
would work here too. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks to be copied from append vec, where stephen wrote this 3 years ago.
Some thoughts:
error messages get logged immediately.
Panics get delayed sometimes and eaten until a thread is joined (IIRC).
Either way it is an error condition. I'm not sure what is best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, likely won't matter much, since if we cannot create a new mmap file then it's likely the whole system is borked.
I tend to think a library function shouldn't call exit
, but instead assert its invariants. We also get a backtrace with panics, but I doubt it would contain useful information. I'd lean towards doing an expect
with a message like "create accounts hashes mmap file".
Not a dealbreaker for me, so I defer to you on this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some inconsistency.
Here's an info I added a few years ago: #17727
Sometimes we just unwrap the mmap.
solana/accounts-db/src/cache_hash_data.rs
Line 96 in 527a4bb
Ok(unsafe { MmapMut::map_mut(file).unwrap() }) |
26cd7a8
to
2991a4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Can the title of this PR be updated before merging? (Mainly to remove the 'wip') |
* in hash calc, calculate max_inclusive_num_pubkeys * in hash calc, dedup uses mmap files to avoid os panic * as_mut_ptr * remove unsafe code * refactor count in hash files --------- Co-authored-by: HaoranYi <haoran.yi@solana.com> (cherry picked from commit 4dfe62a) # Conflicts: # runtime/src/accounts_hash.rs
…ckport of #33195) (#33204) * rework accounts hash calc dedup to avoid kernel file error (#33195) * in hash calc, calculate max_inclusive_num_pubkeys * in hash calc, dedup uses mmap files to avoid os panic * as_mut_ptr * remove unsafe code * refactor count in hash files --------- Co-authored-by: HaoranYi <haoran.yi@solana.com> (cherry picked from commit 4dfe62a) # Conflicts: # runtime/src/accounts_hash.rs * fix merge conflicts --------- Co-authored-by: Jeff Washington (jwash) <jeff.washington@solana.com>
Problem
#33174
Summary of Changes
use mmap file instead of
BufWriter
. The temp file is mmapped for reading anyway.This avoids the
BufWriter
api completely.Fixes #