-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Conversation
this is 10x slower then what is in the loom repo |
woot! want to give a quick look on the design? ill merge and squash and add a test for dup/sender |
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
==========================================
+ Coverage 91.57% 91.85% +0.27%
==========================================
Files 12 14 +2
Lines 724 1031 +307
==========================================
+ Hits 663 947 +284
- Misses 61 84 +23
Continue to review full report at Codecov.
|
Anatoly, can you rebase on the latest? |
fn run_read_from(&mut self, socket: &UdpSocket) -> Result<usize> { | ||
self.packets.resize(BLOCK_SIZE, Packet::default()); | ||
let mut i = 0; | ||
for p in self.packets.iter_mut() { |
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.
enumerate()?
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 is really dumb, but, if i used an enumerate, i would still need a mut to return the value outside of the loop. If i had a return instead of a break, then the return statement at the end of the function would be unreachable.
IO(std::io::Error), | ||
JSON(serde_json::Error), | ||
AddrParse(std::net::AddrParseError), | ||
JoinError(Box<Any + Send + 'static>), |
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.
That seems odd. What's going on here?
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 am converting the join error type into the result type. It has a really weird signature because its a return value of the closure that is passed into spawn.
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.
That `static most likely comes from the possibility of the thread outliving the parent thread. You can get that out of there by either using an explicit lifetime or using scoped threads from crossbeam.
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.
seems like a big change just for the type. for a return value the 'static' isn't a huge problem because all-most all the apis just return ()
src/result.rs
Outdated
|
||
fn addr_parse_error() -> Result<SocketAddr> { | ||
let r = "12fdfasfsafsadfs".parse()?; | ||
return Ok(r); |
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.
These two lines can be reduced to:
"12fdfasfsafsadfs".parse()
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.
it doesn't do the conversion
--> src/result.rs:74:9
|
73 | fn join_error() -> Result<()> {
| ---------- expected `std::result::Result<(), resul
t::Error>` because of return type
74 | thread::spawn(|| panic!("hi")).join()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `result::Erro
r`, found struct `std::boxed::Box`
|
= note: expected type `std::result::Result<(), result::Error>`
found type `std::result::Result<_, std::boxed::Box<std::any::Any
+ std::marker::Send + 'static>>`
fn join_error() -> Result<()> {
thread::spawn(|| panic!("hi")).join()
}
or
fn join_error() -> Result<()> {
Result::from(thread::spawn(|| panic!("hi")).join())
}
doesn't work either
src/result.rs
Outdated
} | ||
|
||
fn join_error() -> Result<()> { | ||
thread::spawn(|| panic!("hi")).join()?; |
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.
Same with this and the next few
src/streamer.rs
Outdated
fn read_from(&mut self, socket: &UdpSocket) -> Result<()> { | ||
let sz = self.run_read_from(socket)?; | ||
self.packets.resize(sz, Packet::default()); | ||
return Ok(()); |
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.
The last line of a function should just be an expression, not a statement. In most of you functions, can you replace return Ok(());
with just Ok(())
?
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.
yar, you cant teach an old c-dog new tricks
src/streamer.rs
Outdated
r: Receiver<SharedPacketData>, | ||
) -> JoinHandle<()> { | ||
spawn(move || loop { | ||
match recv_send(&sock, recycler.clone(), &r) { |
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.
Looks like this could reduce to:
if recv_send(&sock, recycler.clone(), &r).is_err() && exit.lock().unwrap() {
break;
}
|
||
pub type Result<T> = std::result::Result<T, Error>; | ||
|
||
impl std::convert::From<std::sync::mpsc::RecvError> for Error { |
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.
Cool way to do it.
* message needs to fit into 256 bytes * allocator to keep track of blocks of messages * udp socket receiver server that fills up the block as fast as possible * udp socket sender server that sends out the block as fast as possible
@garious do you know how to enable ipv6 on travis? |
No, I don't know how to enable ipv6, but if it's not easy to do and you want to keep moving forward, guard your new functionality with a feature flag. Are you planning to close this PR in favor of the other? |
no, pipelining |
No description provided.