-
Notifications
You must be signed in to change notification settings - Fork 316
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
Issue#622: change usize to u64 #641
Changes from all commits
b4350f7
030ab6a
1c09f4d
00ee679
4eea591
26fb92a
199b942
dcc7df4
9ba1e69
1983d77
6c994b9
7f93edb
a6cb048
aba47f8
69e7780
e3d732b
bdc5ff4
b7818d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ impl SectorManager for DiskManager { | |
file.seek(SeekFrom::Start(start_offset)) | ||
.map_err(|err| SectorManagerErr::CallerError(format!("{:?}", err)))?; | ||
|
||
let mut buf = vec![0; usize::from(num_bytes)]; | ||
let mut buf = vec![0; (u64::from(num_bytes)) as usize]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may be missing something, but I think that if In other words, I think this is fundamentally a matter of us wanting to address more than 32-bits worth of memory; and trying to get around it only indirects the issue. It seems to me that the only simple way to avoid this is to avoid the situation. That's probably done most gracefully by putting a bounds check into the (removed above) conversion to I'm starting to think the main solution to this is to never create sectors larger than 4GiB (max) if we are on a 32-bit system. We could, and perhaps should, check that when the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one of places I remain there for future decision. Originally, I put an TODO comment there in the code to reflect that as you mentioned, but, not sure why it could not pass the fmt check, then deleted it in the commit b7818d0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's how I see it: Code like the above, where we are creating/indexing vectors/slices must use For now, there is no plan to try to support replication with less RAM than required to hold a sector — so even if we can incrementally remove some instances of allocation/reference that require 64 bits, we still won't have changed the fundamental fact that the system can't handle the situation. I think we should defer rippling partial changes which create the illusion that we can address sectors larger than the architecture will allow. Instead, we should use If we really want to expose
Given the second option, we could also just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agreed, we could add the boundary check in places where u64 to usize functions for 32-bit system. Do you prefer we put it into this commit, or we could do it in the next commit? I am thinking the best way is to ask compiler to do this, i.e. we have the code in place, and insert some compiler indicators to let the compiler decide if the code should be in or not in the binary depending on the system type (32-bit or 64-bit). I am not that familiar to add this kind of compiler indicator in rust, anyone has any suggestions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Interesting. Should a mining rig operator who is running a 32-bit system be able to verify a PoSt or PoRep proof generated for sectors with size > 4GiB (by some other miner)? Both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. There's no reason why 32-bit systems should be unable to verify large sectors. As long as sectors are not greater than 128GiB, we should still be able to represent If and when we need to verify sectors over 128GiB, we will need to revisit this. I suggest we code this in such a way that we can't silently fail to do so in that event. |
||
|
||
file.read_exact(buf.as_mut_slice()) | ||
.map_err(|err| SectorManagerErr::CallerError(format!("{:?}", err)))?; | ||
|
@@ -315,7 +315,7 @@ pub mod tests { | |
let output_bytes_written = buf.len(); | ||
|
||
// ensure that we reported the correct number of written bytes | ||
assert_eq!(contents.len(), usize::from(n)); | ||
assert_eq!(contents.len(), u64::from(n) as usize); | ||
|
||
// ensure the file we wrote to contains the expected bytes | ||
assert_eq!(contents[0..32], buf[0..32]); | ||
|
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.
With large enough sectors (> 128GiB), nodes will exceed
u32
too.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.
not only nodes, and perhaps sector counts as well in some other files (when a big repo > 1EB, the sector number could > 4G), I would think it is better to do incremental changes in multiple commits, and make sure every step is correct.
How do you think about this? @porcuquine