Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

initialize recycled data #967

Merged

Conversation

rob-solana
Copy link
Contributor

No description provided.

@rob-solana rob-solana requested a review from garious August 14, 2018 01:53
} else {
x

loop {
Copy link
Contributor Author

@rob-solana rob-solana Aug 14, 2018

Choose a reason for hiding this comment

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

I had to drop recursion here when I was using default::Default in my initial SWAG at this; I learned that Rust apparently isn't smart about tail recursion, and in our tests (where a lot of strong-ref'd blobs are in the recycler) 64k per stack frame was being allocated, we recursed WINDOW_SIZE frames, and it completely blew up (no stack backtrace or nothin').

I prefer the loop form, though. I'm not a Haskell guy ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably LLVM that's the problem, not Rust. Haskell's GHC had to go add another calling convention to LLVM to allow for tail recursion. The iterative version is fine my me. If you want to write a test for that, looks like thread::Builder lets you control the thread's stack size:

let builder = thread::Builder::new()
                  .name("kaboom".into())
                  .stack_size(32 * 1024 * 1024); // 32MB of stack space

    let handler = builder.spawn(|| {
        // stack-intensive operations
    }).unwrap();

    handler.join()  // <---   assert this returns an Err

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 on iterative version :-)

src/packet.rs Outdated
@@ -63,6 +63,19 @@ impl Default for Packet {
}
}

pub trait Recycle {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have called this Recyclable, but I don't see a precedent for that "-able" naming convention in Rust, which is too bad. Looks like Rustaceans would name it Reset. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reset works for me, too. I didn't think -able looked right.

src/packet.rs Outdated
// Recycle trait is an object that can re-initialize important parts
// of itself, similar to Default, but not necessarily a full clear
// also, we do it in-place.
fn reset(&mut self) -> ();
Copy link
Contributor

Choose a reason for hiding this comment

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

Did that -> () get by Clippy? Can you remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clippy keeps going away on my box(es) ...rust updates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rob-solana rob-solana merged commit 5f6cbe0 into solana-labs:master Aug 14, 2018
@@ -550,7 +550,7 @@ mod tests {

fn tmp_ledger_path(name: &str) -> String {
use std::env;
let out_dir = env::var("OUT_DIR").unwrap();
let out_dir = env::var("OUT_DIR").unwrap_or_else(|_| "target".to_string());
Copy link
Contributor

Choose a reason for hiding this comment

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

should be a function get_out_dir() -> String which can share this logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, eventually I'd like to collapse temp_dir stuff to a single implementation. I had to hurry up and throw this in because for some reason cargo stopped offering "OUT_DIR" in some of my test runs (like cargo watch -x test, maybe)...

impl Reset for Blob {
fn reset(&mut self) {
self.meta = Meta::default();
self.data[..BLOB_HEADER_SIZE].copy_from_slice(&[0u8; BLOB_HEADER_SIZE]);
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO: probably non-optimal memset

Copy link
Contributor

Choose a reason for hiding this comment

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

annoyingly doesn't seem like rust has a safe one at the moment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what's a better memset() look like?

Copy link
Contributor

@sakridge sakridge Aug 15, 2018

Choose a reason for hiding this comment

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

rust-lang/rfcs#2067

unsafe {
    ptr::write_bytes(self.slice.as_mut_ptr(), 0, self.slice.len() - 1);
}

I assume this is doing an allocation with a slice of 0 bytes and then doing a memcpy, but allocation is not needed just zero fill with simd movs.

} else {
x

loop {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 on iterative version :-)

@rob-solana rob-solana deleted the issue-907-init-recycled-data branch August 14, 2018 18:15
vkomenda pushed a commit to vkomenda/solana that referenced this pull request Aug 29, 2021
…olana-labs#967)

* Automate primordial accounts

* Add genesis account dumping as test

* Add test-dump-genesis-accounts feature flag to create state

* Run cargo fmt

* Delete gitignore

* Add test-bpf feature to genesis test

Co-authored-by: Justin Starry <justin@solana.com>
yihau pushed a commit that referenced this pull request May 7, 2024
…_window (backport of #904) (#967)

* quic: delay calling set_max_concurrent_uni_streams/set_receive_window (#904)

* quic: don't call connection.set_max_concurrent_uni_streams if we're going to drop a connection

Avoids taking a mutex and waking a task.

* quic: don't increase the receive window before we've actually accepted a connection

(cherry picked from commit 2770424)

# Conflicts:
#	streamer/src/nonblocking/quic.rs

* Fix merge conflicts

---------

Co-authored-by: Alessandro Decina <alessandro.d@gmail.com>
andreisilviudragnea pushed a commit to andreisilviudragnea/solana that referenced this pull request May 12, 2024
…_window (backport of solana-labs#904) (solana-labs#967)

* quic: delay calling set_max_concurrent_uni_streams/set_receive_window (solana-labs#904)

* quic: don't call connection.set_max_concurrent_uni_streams if we're going to drop a connection

Avoids taking a mutex and waking a task.

* quic: don't increase the receive window before we've actually accepted a connection

(cherry picked from commit 2770424)

# Conflicts:
#	streamer/src/nonblocking/quic.rs

* Fix merge conflicts

---------

Co-authored-by: Alessandro Decina <alessandro.d@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants