Skip to content

Commit fa2699e

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 17d8e8d commit fa2699e

File tree

6 files changed

+29
-39
lines changed

6 files changed

+29
-39
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 19 additions & 25 deletions
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
.map(|mut s| {
4747
s.write_all(&[CONNECTION_FROM_BASE]).unwrap();
@@ -50,8 +50,7 @@ impl Service<()> for TableEndpoint {
5050
})
5151
.map(AsyncBincodeStream::from)
5252
.map(AsyncBincodeStream::for_async)
53-
.map(|t| multiplex::MultiplexTransport::new(t, Tagger::default())),
54-
)
53+
.map(|t| multiplex::MultiplexTransport::new(t, Tagger::default()))
5554
}
5655
}
5756

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

263262
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
264263
for s in &mut self.shards {
@@ -273,8 +272,7 @@ impl Service<Input> for Table {
273272
// TODO: check each row's .len() against self.columns.len() -> WrongColumnCount
274273

275274
if self.shards.len() == 1 {
276-
// when Box goes away, this becomes future::Either::A
277-
Box::new(
275+
future::Either::A(
278276
self.shards[0]
279277
.call(
280278
if self.dst_is_local {
@@ -333,8 +331,7 @@ impl Service<Input> for Table {
333331
}
334332
}
335333

336-
// when Box goes away, this becomes future::Either::B
337-
Box::new(
334+
future::Either::B(
338335
wait_for
339336
.fold((), |_, _| Ok(()))
340337
.map_err(TableError::from)
@@ -483,14 +480,12 @@ impl Table {
483480
fn quick_n_dirty<Request>(
484481
self,
485482
r: Request,
486-
) -> Box<Future<Item = Self, Error = AsyncTableError> + Send>
483+
) -> impl Future<Item = Table, Error = AsyncTableError> + Send
487484
where
488485
Request: Send + 'static,
489486
Self: Service<Request, Error = TableError>,
490487
<Self as Service<Request>>::Future: Send,
491488
{
492-
// Box is needed for https://github.com/rust-lang/rust/issues/53984
493-
Box::new(
494489
self.ready()
495490
.map_err(|e| match e {
496491
TableError::TransportError(e) => AsyncTableError::from(e),
@@ -504,8 +499,7 @@ impl Table {
504499
error: e,
505500
}),
506501
})
507-
}),
508-
)
502+
})
509503
}
510504

511505
/// Insert a single row of data into this base table.
@@ -552,25 +546,25 @@ impl Table {
552546

553547
if key.len() != self.key.len() {
554548
let error = TableError::WrongKeyColumnCount(self.key.len(), key.len());
555-
return Box::new(future::err(AsyncTableError {
549+
return future::Either::A(future::err(AsyncTableError {
556550
table: Some(self),
557551
error,
558-
})) as Box<_>;
552+
}));
559553
}
560554

561555
let mut set = vec![Modification::None; self.columns.len()];
562556
for (coli, m) in u {
563557
if coli >= self.columns.len() {
564558
let error = TableError::WrongColumnCount(self.columns.len(), coli + 1);
565-
return Box::new(future::err(AsyncTableError {
559+
return future::Either::A(future::err(AsyncTableError {
566560
table: Some(self),
567561
error,
568-
})) as Box<_>;
562+
}));
569563
}
570564
set[coli] = m;
571565
}
572566

573-
self.quick_n_dirty(TableOperation::Update { key, set })
567+
future::Either::B(self.quick_n_dirty(TableOperation::Update { key, set }))
574568
}
575569

576570
/// Perform a insert-or-update on this base table.
@@ -581,7 +575,7 @@ impl Table {
581575
self,
582576
insert: Vec<DataType>,
583577
update: V,
584-
) -> Box<Future<Item = Self, Error = AsyncTableError> + Send>
578+
) -> impl Future<Item = Table, Error = AsyncTableError> + Send
585579
where
586580
V: IntoIterator<Item = (usize, Modification)>,
587581
{
@@ -592,7 +586,7 @@ impl Table {
592586

593587
if insert.len() != self.columns.len() {
594588
let error = TableError::WrongColumnCount(self.columns.len(), insert.len());
595-
return Box::new(future::err(AsyncTableError {
589+
return future::Either::A(future::err(AsyncTableError {
596590
table: Some(self),
597591
error,
598592
}));
@@ -602,18 +596,18 @@ impl Table {
602596
for (coli, m) in update {
603597
if coli >= self.columns.len() {
604598
let error = TableError::WrongColumnCount(self.columns.len(), coli + 1);
605-
return Box::new(future::err(AsyncTableError {
599+
return future::Either::A(future::err(AsyncTableError {
606600
table: Some(self),
607601
error,
608602
}));
609603
}
610604
set[coli] = m;
611605
}
612606

613-
self.quick_n_dirty(TableOperation::InsertOrUpdate {
607+
future::Either::B(self.quick_n_dirty(TableOperation::InsertOrUpdate {
614608
row: insert,
615609
update: set,
616-
})
610+
}))
617611
}
618612

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

noria/src/view.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,18 @@ 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
.map(AsyncBincodeStream::from)
4343
.map(AsyncBincodeStream::for_async)
44-
.map(|t| multiplex::MultiplexTransport::new(t, Tagger::default())),
45-
)
44+
.map(|t| multiplex::MultiplexTransport::new(t, Tagger::default()))
4645
}
4746
}
4847

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

216215
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
217216
for s in &mut self.shards {
@@ -230,7 +229,6 @@ impl Service<(Vec<Vec<DataType>>, bool)> for View {
230229
}
231230

232231
let node = self.node;
233-
Box::new(
234232
futures::stream::futures_ordered(
235233
self.shards
236234
.iter_mut()
@@ -255,8 +253,7 @@ impl Service<(Vec<Vec<DataType>>, bool)> for View {
255253
})
256254
}),
257255
)
258-
.concat2(),
259-
)
256+
.concat2()
260257
}
261258
}
262259

rust-toolchain

Lines changed: 1 addition & 1 deletion
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)