Skip to content

Commit 4e3846e

Browse files
committed
Steps needed to remove boxing from view/table ops
Sadly these do not work yet due to the ICE from rust-lang/rust#53443
1 parent 3e97953 commit 4e3846e

File tree

6 files changed

+29
-39
lines changed

6 files changed

+29
-39
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dist: trusty
22
language: rust
33
cache: cargo
44
rust:
5-
- nightly-2019-01-10
5+
- nightly-2019-01-21
66
env:
77
- SETTLE_TIME=2000
88
script:

noria-benchmarks/vote/orchestrator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ fn run_clients(
900900
any_not_overloaded = false;
901901
} else if !stderr.is_empty() {
902902
eprintln!("{} reported:", host);
903-
let stderr = stderr.trim_right().replace('\n', "\n > ");
903+
let stderr = stderr.trim_end().replace('\n', "\n > ");
904904
eprintln!(" > {}", stderr);
905905
}
906906
}
@@ -969,7 +969,7 @@ fn ec2_instance_type_cores(it: &str) -> Option<u16> {
969969
"nano" | "micro" | "small" => Some(1),
970970
"medium" | "large" => Some(2),
971971
t if t.ends_with("xlarge") => {
972-
let mult = t.trim_right_matches("xlarge").parse::<u16>().unwrap_or(1);
972+
let mult = t.trim_end_matches("xlarge").parse::<u16>().unwrap_or(1);
973973
Some(4 * mult)
974974
}
975975
_ => None,

noria-server/dataflow/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![feature(nll)]
22
#![feature(box_syntax)]
33
#![feature(box_patterns)]
4-
#![feature(if_while_or_patterns)]
54
#![deny(unused_extern_crates)]
65

76
#[cfg(debug_assertions)]

noria/src/table.rs

+19-25
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ pub struct TableEndpoint(SocketAddr);
3434
impl Service<()> for TableEndpoint {
3535
type Response = multiplex::MultiplexTransport<Transport, Tagger>;
3636
type Error = tokio::io::Error;
37-
type Future = Box<Future<Item = Self::Response, Error = Self::Error> + Send>;
37+
// have to repeat types because https://github.com/rust-lang/rust/issues/57807
38+
existential type Future: Future<Item = multiplex::MultiplexTransport<Transport, Tagger>, Error = tokio::io::Error>;
3839

3940
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
4041
Ok(Async::Ready(()))
4142
}
4243

4344
fn call(&mut self, _: ()) -> Self::Future {
44-
Box::new(
4545
tokio::net::TcpStream::connect(&self.0)
4646
.and_then(|s| {
4747
s.set_nodelay(true)?;
@@ -54,8 +54,7 @@ impl Service<()> for TableEndpoint {
5454
})
5555
.map(AsyncBincodeStream::from)
5656
.map(AsyncBincodeStream::for_async)
57-
.map(|t| multiplex::MultiplexTransport::new(t, Tagger::default())),
58-
)
57+
.map(|t| multiplex::MultiplexTransport::new(t, Tagger::default()))
5958
}
6059
}
6160

@@ -261,8 +260,8 @@ impl fmt::Debug for Table {
261260
impl Service<Input> for Table {
262261
type Error = TableError;
263262
type Response = <TableRpc as Service<Tagged<LocalOrNot<Input>>>>::Response;
264-
// existential once https://github.com/rust-lang/rust/issues/53443 is fixed
265-
type Future = Box<Future<Item = Tagged<()>, Error = Self::Error> + Send>;
263+
// have to repeat types because https://github.com/rust-lang/rust/issues/57807
264+
existential type Future: Future<Item = Tagged<()>, Error = TableError>;
266265

267266
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
268267
for s in &mut self.shards {
@@ -277,8 +276,7 @@ impl Service<Input> for Table {
277276
// TODO: check each row's .len() against self.columns.len() -> WrongColumnCount
278277

279278
if self.shards.len() == 1 {
280-
// when Box goes away, this becomes future::Either::A
281-
Box::new(
279+
future::Either::A(
282280
self.shards[0]
283281
.call(
284282
if self.dst_is_local {
@@ -337,8 +335,7 @@ impl Service<Input> for Table {
337335
}
338336
}
339337

340-
// when Box goes away, this becomes future::Either::B
341-
Box::new(
338+
future::Either::B(
342339
wait_for
343340
.fold((), |_, _| Ok(()))
344341
.map_err(TableError::from)
@@ -487,14 +484,12 @@ impl Table {
487484
fn quick_n_dirty<Request>(
488485
self,
489486
r: Request,
490-
) -> Box<Future<Item = Self, Error = AsyncTableError> + Send>
487+
) -> impl Future<Item = Table, Error = AsyncTableError> + Send
491488
where
492489
Request: Send + 'static,
493490
Self: Service<Request, Error = TableError>,
494491
<Self as Service<Request>>::Future: Send,
495492
{
496-
// Box is needed for https://github.com/rust-lang/rust/issues/53984
497-
Box::new(
498493
self.ready()
499494
.map_err(|e| match e {
500495
TableError::TransportError(e) => AsyncTableError::from(e),
@@ -508,8 +503,7 @@ impl Table {
508503
error: e,
509504
}),
510505
})
511-
}),
512-
)
506+
})
513507
}
514508

515509
/// Insert a single row of data into this base table.
@@ -556,25 +550,25 @@ impl Table {
556550

557551
if key.len() != self.key.len() {
558552
let error = TableError::WrongKeyColumnCount(self.key.len(), key.len());
559-
return Box::new(future::err(AsyncTableError {
553+
return future::Either::A(future::err(AsyncTableError {
560554
table: Some(self),
561555
error,
562-
})) as Box<_>;
556+
}));
563557
}
564558

565559
let mut set = vec![Modification::None; self.columns.len()];
566560
for (coli, m) in u {
567561
if coli >= self.columns.len() {
568562
let error = TableError::WrongColumnCount(self.columns.len(), coli + 1);
569-
return Box::new(future::err(AsyncTableError {
563+
return future::Either::A(future::err(AsyncTableError {
570564
table: Some(self),
571565
error,
572-
})) as Box<_>;
566+
}));
573567
}
574568
set[coli] = m;
575569
}
576570

577-
self.quick_n_dirty(TableOperation::Update { key, set })
571+
future::Either::B(self.quick_n_dirty(TableOperation::Update { key, set }))
578572
}
579573

580574
/// Perform a insert-or-update on this base table.
@@ -585,7 +579,7 @@ impl Table {
585579
self,
586580
insert: Vec<DataType>,
587581
update: V,
588-
) -> Box<Future<Item = Self, Error = AsyncTableError> + Send>
582+
) -> impl Future<Item = Table, Error = AsyncTableError> + Send
589583
where
590584
V: IntoIterator<Item = (usize, Modification)>,
591585
{
@@ -596,7 +590,7 @@ impl Table {
596590

597591
if insert.len() != self.columns.len() {
598592
let error = TableError::WrongColumnCount(self.columns.len(), insert.len());
599-
return Box::new(future::err(AsyncTableError {
593+
return future::Either::A(future::err(AsyncTableError {
600594
table: Some(self),
601595
error,
602596
}));
@@ -606,18 +600,18 @@ impl Table {
606600
for (coli, m) in update {
607601
if coli >= self.columns.len() {
608602
let error = TableError::WrongColumnCount(self.columns.len(), coli + 1);
609-
return Box::new(future::err(AsyncTableError {
603+
return future::Either::A(future::err(AsyncTableError {
610604
table: Some(self),
611605
error,
612606
}));
613607
}
614608
set[coli] = m;
615609
}
616610

617-
self.quick_n_dirty(TableOperation::InsertOrUpdate {
611+
future::Either::B(self.quick_n_dirty(TableOperation::InsertOrUpdate {
618612
row: insert,
619613
update: set,
620-
})
614+
}))
621615
}
622616

623617
/// Trace the next modification to this base table.

noria/src/view.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,22 @@ pub struct ViewEndpoint(SocketAddr);
3030
impl Service<()> for ViewEndpoint {
3131
type Response = multiplex::MultiplexTransport<Transport, Tagger>;
3232
type Error = tokio::io::Error;
33-
type Future = Box<Future<Item = Self::Response, Error = Self::Error> + Send>;
33+
// have to repeat types because https://github.com/rust-lang/rust/issues/57807
34+
existential type Future: Future<Item = multiplex::MultiplexTransport<Transport, Tagger>, Error = tokio::io::Error>;
3435

3536
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
3637
Ok(Async::Ready(()))
3738
}
3839

3940
fn call(&mut self, _: ()) -> Self::Future {
40-
Box::new(
4141
tokio::net::TcpStream::connect(&self.0)
4242
.and_then(|s| {
4343
s.set_nodelay(true)?;
4444
Ok(s)
4545
})
4646
.map(AsyncBincodeStream::from)
4747
.map(AsyncBincodeStream::for_async)
48-
.map(|t| multiplex::MultiplexTransport::new(t, Tagger::default())),
49-
)
48+
.map(|t| multiplex::MultiplexTransport::new(t, Tagger::default()))
5049
}
5150
}
5251

@@ -214,8 +213,8 @@ impl fmt::Debug for View {
214213
impl Service<(Vec<Vec<DataType>>, bool)> for View {
215214
type Response = Vec<Datas>;
216215
type Error = ViewError;
217-
// existential once https://github.com/rust-lang/rust/issues/53443 is fixed
218-
type Future = Box<Future<Item = Self::Response, Error = Self::Error> + Send>;
216+
// have to repeat types because https://github.com/rust-lang/rust/issues/57807
217+
existential type Future: Future<Item = Vec<Datas>, Error = ViewError>;
219218

220219
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
221220
for s in &mut self.shards {
@@ -234,7 +233,6 @@ impl Service<(Vec<Vec<DataType>>, bool)> for View {
234233
}
235234

236235
let node = self.node;
237-
Box::new(
238236
futures::stream::futures_ordered(
239237
self.shards
240238
.iter_mut()
@@ -259,8 +257,7 @@ impl Service<(Vec<Vec<DataType>>, bool)> for View {
259257
})
260258
}),
261259
)
262-
.concat2(),
263-
)
260+
.concat2()
264261
}
265262
}
266263

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2019-01-11
1+
nightly-2019-01-21

0 commit comments

Comments
 (0)