Skip to content

feat: transparent huge page stacks and per-thread stack cache - #158

Open
CertainLach wants to merge 1 commit into
rust-lang:masterfrom
CertainLach:push-mmksotrnlmll
Open

CertainLach wants to merge 1 commit into
rust-lang:masterfrom
CertainLach:push-mmksotrnlmll

Conversation

@CertainLach

Copy link
Copy Markdown

I'm not sure if this fits the scope of stacker, so this PR is mostly for discussion.

I don't know if it will be useful in rustc (I haven't ran benchmarks here), but those changes allow me to greatly improve execution times in https://github.com/CertainLach/jrsonnet, which is a stack-heavy interpreter.

It does not seem to affect non-huge-page users (In fact, grow_cold seems to improve the performance in some cases)

Change-Id: Iddf7b68cedee5844c207adbe8f8eeb4b6a6a6964
Signed-off-by: Yaroslav Bolyukin <iam@lach.pw>
Comment thread tests/cache.rs
use std::thread;

#[inline(never)]
fn deep_marker() -> *mut u8 {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure that's UB according to Rust, but but given that this library already operates on stack, I think this may be legal? Will drop this test if not

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...Or, maybe I should just rewrite it to use rust_psm_stack_pointer(), at least that resolves the question of what happens if let local happens to be allocated in heap, which rustc never does right now

@CertainLach

Copy link
Copy Markdown
Author

I also don't like that it depends on a couple of globals/thread_locals, but I haven't figured a clean way on how to make user pass its own collection of cached stacks without changing too much of a public API/creating too many redundant functions. If the change seems useful enough to be included - I might refactor the implementation with API breakages included.


#[cfg(any(target_os = "linux", target_os = "android"))]
fn huge_page_size() -> Option<usize> {
static SIZE: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might switch to OnceLock

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant