Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for RFC #2116: fallible collection allocation #48043
Comments
aturon
added
B-RFC-approved
T-libs
C-tracking-issue
labels
Feb 7, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
snf
Feb 22, 2018
Contributor
Hi, this feature will require oom and try_reserve to be implemented. I'm needing try_reserve and I'm willing to work (slowly) on it if noone else does.
I see that the previous commit by @Gankro is here and seems to match the RFC description.
Is there anything else I should consider before rebasing that PR?
|
Hi, this feature will require |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
snf
Mar 3, 2018
Contributor
I can use some mentorship on what's the best way to implement oom=panic/abort . Should I emit a global variable through rustc depending on this case?
I was taking inspiration from #32900 but there might be an easier way to emit a boolean global variable.
|
I can use some mentorship on what's the best way to implement oom=panic/abort . Should I emit a global variable through rustc depending on this case? I was taking inspiration from #32900 but there might be an easier way to emit a boolean global variable. |
whitequark
referenced this issue
Mar 5, 2018
Open
Handle out-of-memory errors during DMA sequence recording #945
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
cc @Gankro, can you help mentor? |
added a commit
that referenced
this issue
Mar 9, 2018
added a commit
that referenced
this issue
Mar 12, 2018
added a commit
that referenced
this issue
Mar 12, 2018
snf
referenced this issue
Mar 12, 2018
Closed
AsmJS' malloc aborts on OOM instead of returning NULL #48968
added a commit
that referenced
this issue
Mar 13, 2018
added a commit
that referenced
this issue
Mar 14, 2018
added a commit
that referenced
this issue
Mar 15, 2018
kennytm
referenced this issue
Mar 19, 2018
Open
Tracking issue for `unstable_name_collision` compatibility lint #48919
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
SimonSapin
Apr 5, 2018
Contributor
try_reserve methods are implemented in Nightly, but the accepted RFC also includes the ability to make allocation failure cause a panic rather than abort and that part is not implemented. Unfortunately the RFC does not discuss how this would be implemented, other than being controlled by a flag in Cargo.toml. It’s not clear to me how this can work.
|
|
SimonSapin
referenced this issue
Apr 5, 2018
Merged
Add GlobalAlloc trait + tweaks for initial stabilization #49669
SimonSapin
referenced this issue
Apr 20, 2018
Closed
Tracking issue for the GlobalAlloc trait and related APIs #49668
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
glandium
May 4, 2018
Contributor
Unfortunately the RFC does not discuss how this would be implemented, other than being controlled by a flag in Cargo.toml. It’s not clear to me how this can work.
We've been talking about panic::set_hook-like hooking for the new oom lang item in #49668, this could be how this works.
We've been talking about panic::set_hook-like hooking for the new oom lang item in #49668, this could be how this works. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
SimonSapin
May 29, 2018
Contributor
@alexcrichton, how does #51041 fit with the goal of implementing some way to opt into oom=panic?
|
@alexcrichton, how does #51041 fit with the goal of implementing some way to opt into oom=panic? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
alexcrichton
May 29, 2018
Member
@SimonSapin we'd decide that the regression is acceptable, and we'd revert the change.
|
@SimonSapin we'd decide that the regression is acceptable, and we'd revert the change. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
SimonSapin
May 29, 2018
Contributor
You use a conditional tense, but oom=panic is already in an accepted RFC (though the implementation strategy is not quite settled).
|
You use a conditional tense, but |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
alexcrichton
May 29, 2018
Member
Ok sure, we can figure it out in the implementation details? AFAIK there's no need to revert the change as it has basically no benefit today. It's a trivial change to revert as well, it's one line in the standard library
|
Ok sure, we can figure it out in the implementation details? AFAIK there's no need to revert the change as it has basically no benefit today. It's a trivial change to revert as well, it's one line in the standard library |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
3n-mb
Jun 24, 2018
This example in playground asks for 1024*1024*1024*1000 bytes on a server, via v.try_reserve(len)? without giving an error.
Is this RFC implementation is not at the point, at which errors in such cases will start to show up?
Or, is this a gross over-commit by underlying OS, and this state of affairs will stay like this?
Can try_reserve in principle reserve only realistic things?
3n-mb
commented
Jun 24, 2018
|
This example in playground asks for Is this RFC implementation is not at the point, at which errors in such cases will start to show up? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
SimonSapin
Jun 24, 2018
Contributor
When an error is returned is entirely dependent of the underlying allocator. As far as I know Linux usually overcommits, Windows doesn’t.
https://play.rust-lang.org/?gist=aa668f38117983d1951b58307df04880&version=nightly allocates 120 PB but fails at 130 PB, it is exhausting 48 bits of address space.
Even on Linux though, this API can be useful for 32-bit programs when exhausting the address space is much more realistic.
|
When an error is returned is entirely dependent of the underlying allocator. As far as I know Linux usually overcommits, Windows doesn’t. https://play.rust-lang.org/?gist=aa668f38117983d1951b58307df04880&version=nightly allocates 120 PB but fails at 130 PB, it is exhausting 48 bits of address space. Even on Linux though, this API can be useful for 32-bit programs when exhausting the address space is much more realistic. |
SimonSapin
added
B-RFC-implemented
and removed
B-RFC-approved
labels
Jun 27, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
SimonSapin
Jun 27, 2018
Contributor
#43596 was the pre-RFC feature request for oom=panic. I’ve repurposed it as the tracking issue for that feature, since it and try_reserved are likely to be stabilized at different times. This leaves this issue as tracking only try_reserve.
|
#43596 was the pre-RFC feature request for |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
#52420 will change |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
SimonSapin
Aug 1, 2018
Contributor
Will, or would. I’ve comment there that such a change in public API design merits being discussed separately from a large PR.
|
Will, or would. I’ve comment there that such a change in public API design merits being discussed separately from a large PR. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Ericson2314
Aug 2, 2018
Contributor
Yeah definitely. Even if it weren't for the 2018 delaying considering these things, I wouldn't expect it to be merged quick. I just make the PR to prove the feasibility and make my ideas clearer to / interactive for others.
Ignoring the benefits of allocator polymorphism itself (that would be #42774), I see 4 big benefits:
-
Self discipline: Applications can prevent themselves statically from forgetting to handled allocations failures.
-
Race freedom: allocation divergence due to
try_reservinginsufficient space are statically prevented. -
Expressiveness: Unclear how to do
try_reserve-like things for "deep" data structures (those containing indirecation). -
Library flexibility: Implement functionality just once with a parameteric error type, and you get fallibility polymorphism: downstream can instantiate with
!to get today's divergence, orAllocErrorto allow them to be explicitly handled.
I thus advocating going with error polymorphism and abandoning try_reverve (I rather reuse try_ for the Result<(), E> copies of every method we'll need for backwards compat). (But, my PR keeps the existing meaning of try_reserve so as to allow a transition period where people can try both approaches.)
|
Yeah definitely. Even if it weren't for the 2018 delaying considering these things, I wouldn't expect it to be merged quick. I just make the PR to prove the feasibility and make my ideas clearer to / interactive for others. Ignoring the benefits of allocator polymorphism itself (that would be #42774), I see 4 big benefits:
I thus advocating going with error polymorphism and abandoning |
aturon commentedFeb 7, 2018
•
edited by SimonSapin
Edited 4 times
-
SimonSapin
edited Jun 27, 2018 (most recent)
-
SimonSapin
edited Jun 27, 2018
-
SimonSapin
edited Apr 5, 2018
-
kennytm
edited Mar 15, 2018
This is a tracking issue for the
try_reservepart of the RFC "fallible collection allocation" (rust-lang/rfcs#2116).Steps: