Граф коммитов

48 Коммитов

Автор SHA1 Сообщение Дата
Ted Mielczarek 371119c4d6 update serde to 0.9.13 to pick up a fix for OsString deserialization on Windows (fixes Windows breakage) 2017-04-07 06:55:26 -04:00
Ted Mielczarek 580c393f8c When hashing Rust compile arguments, sort -L and --cfg args as well as --extern 2017-04-03 10:21:13 -04:00
Ted Mielczarek e2e7fbd8a5 bump serde to 0.9.12 to pick up OsStr[ing] support 2017-03-28 10:24:28 -04:00
Felix Obenhuber dc31690674 Add a Redis cache variant
This cache module uses a Redis instance. To make sccache use this,
set SCCACHE_REDIS to redis://[:<passwd>@]<hostname>[:port][/<db>].
The maximum and current cache size is retrieved from the INFO and
CONFIG GET redis command.
2017-03-27 12:34:05 -07:00
Alex Crichton a996ae6c2a Move from protobuf to bincode for a wire format
This commit migrates away from the `protobuf` crate to instead just working with
bincode on the wire as a serialization format. This is done by leveraging a few
different crates:

* The `bincode` and `serde_derive` crates are used to define serialization
  for Rust structures as well as provide a bincode implementation.
* The `tokio_io::codec::length_delimited` module implements framing via length
  prefixes to transform an asynchronous stream of bytes into a literal `Stream`
  of `BytesMut`.
* The `tokio_serde_bincode` crate is then used to tie it all together, parsing
  these `BytesMut` as the request/response types of sccache.

Most of the changes here are related to moving away from the protobuf API
throughout the codebase (e.g. `has_foo` and `take_foo`) towards a more
rustic-ish API that just uses enums/structs. Overall it felt quite natural (as
one would expect) to just use the raw enum/struct values.

This may not be quite as performant as before but that doesn't really apply to
sccache's use case where perf is hugely dominated by actually compiling and
hashing, so I'm not too too worried about that.

My personal motivation for this is twofold:

1. Using `protobuf` was a little clunky throughout the codebase and definitely
   had some sharp edges that felt good to smooth out.
2. There's currently what I believe some mysterious segfault and/or stray write
   happening in sccache and I'm not sure where. The `protobuf` crate had a lot
   of `unsafe` code and in lieu of actually auditing it I figured it'd be good
   to kill two birds with one stone. I have no idea if this fixes my segfault
   problem (I never could reproduce it) but I figured it's worth a shot.
2017-03-27 09:29:12 -07:00
Alex Crichton 76982eee57 Update to using the new tokio-io crate
This is an abstraction of the Tokio stack now and doesn't have much impact on
sccache itself but I figured it'd be good to update a few deps and pick up the
recent version of things!

Plus that and I'd like to start using the length_delimited module soon...
2017-03-24 18:37:04 -07:00
Ted Mielczarek cf7b400c90 Store file permissions for files in cache 2017-03-24 05:53:21 -04:00
Alex Crichton 5a20118ca5 Update futures dependency required by futures-cpupool
Shoulda run the last commit through CI!
2017-03-21 16:15:56 -07:00
Alex Crichton 5f6932b6b6 Update the futures-cpupool dependency
Previous versions of futures-cpupool depended on crossbeam which unfortunately
has known segfaults (spurious) so the updated version no longer uses
futures-cpupool and instead relies on channels in the standard library.
2017-03-21 16:09:12 -07:00
Alex Crichton 8968eba6c9 Remove dependency on `named_pipe`
I was sporadically receiving a segfault locally when trying to debug issues on
Windows and in tracking this down I discovered blackbeam/named_pipe#3 which
leads to segfaults locally on startup.

This switches the one use case to the relevant functionality in
`mio-named-pipes` (already pulled in as part of `tokio-process`) and then
otherwise mirrors the same logic as the Unix version, just waiting for a byte
with a timeout.
2017-03-21 15:51:53 -04:00
Alex Crichton 1e6c6fc1e7 Merge pull request #76 from alexcrichton/update-mio-named-pipes
Update mio-named-pipes
2017-02-25 10:53:28 -06:00
Alex Crichton 01a057215d Update mio-named-pipes
This fixes a bug in EOF handling which can cause spurious failures on Windows
2017-02-25 08:29:47 -08:00
Alex Crichton 4eb8218848 Update gcc crate in Cargo.lock
Picks up support for `-C target-feature=+crt-static` on MSVC and such
2017-02-25 01:48:02 -08:00
Alex Crichton 0baea5a8b0 Update mio-named-pipes to fix compile error on windows 2017-02-17 13:39:01 -05:00
Alex Crichton 4071f3bc21 Remove raw `poll` in favor of `tokio-uds`
Now that we've got tokio at our fingertips it's much easier to time out simple
operations!
2017-02-17 13:39:01 -05:00
Alex Crichton f388dbd459 Integrate the Tokio branch of Hyper
This commit pulls in Hyper from its master branch which contains the
asynchronous/Tokio integration. All instances of HTTP, namely when
interacting with S3, are now all powered by async Hyper and work with
futures rather than synchronous requests on thread pools.
2017-02-17 13:39:01 -05:00
Alex Crichton 6b3e49d971 Integrate process spawning with tokio-process
This commit replaces all process spawning with the futures-powered
versions in the `tokio-process` crate. Most functions were already ready
to return futures, but a few minor updates were made to ensure that
functions could return futures.

Additionally, some `&CpuPool` arguments have shown up to allow executing
work on a thread pool, such as filesystem operations. A number of
compilers write data to tempdirs and such before running a compiler, and
these are all executed on thread pools rather than the main thread.

My main takeaway from this commit is that translating synchronous to
asynchronous code isn't always easy. The "easy" version ends up being
relatively wasteful in terms of clones for low-level performance, but
probably shouldn't matter much in the context of spawning processes.

Other than that though I found that there was a translation for all
patterns found didn't actually hit any bugs (yet at least) from the
translation.
2017-02-17 13:39:01 -05:00
Alex Crichton b59a12abfb Rewrite the server module with Tokio
This commit rewrites the `server` module of sccache to be backed with Tokio. The
previous version was written with `mio`, which Tokio is built on, but is
unfortunately less ergonomic. Tokio is the state-of-the-art for asynchronous
programming in Rust and sccache serves as a great testing ground for ergonomics!

It's intended that the support added here will eventually extend to many other
operations that sccache does as well. For example thread spawning has all been
replaced with `CpuPool` to have a shared pool for I/O operations and such
(namely the filesystem). Eventually the HTTP requests made by the S3 backend can
be integrated with the Tokio branch of Hyper as well to run that on the event
loop instead of in a worker thread. I'd also like to eventually extend this with
`tokio-process` as well to move process spawning off helper threads as well, but
I'm leaving that to a future commit as well.

Overall I found the transition was quite smooth, with the high level
architecture look like:

* The `tokio-proto` crate is used in streaming mode. The streaming part is used
  for the one RPC sccache gets which requires a second response to be sent later
  on. This second response is the "response body" in tokio-proto terms.
* All of sccache's logic is manifested in an implementation of the `Service`
  trait.
* The transport layer is provided with `tokio_core::io::{Framed, Codec}`, and
  simple deserialization/serialization is performed with protobuf.

Some differences in design are:

* The `SccacheService` for now is just a bunch of reference-counted pointers,
  making it cheap to clone. As the futures it returns progress they will each
  retain a reference to a cloned copy of the `SccacheService`. Before all this
  data was just stored and manipulated in a struct directly, but it's now
  directly managed through shared memory.
* The storage backends share a thread pool with the main server instead of
  spawning threads.

And finally, some things I've learned along the way:

* Sharing data between futures isn't a trivial operation. It took an explicit
  decision to use `Rc` and I'm not sure I'm 100% happy with how the ergonomics
  played out.
* Shutdown is pretty tricky here. I've tried to carry over all the previous
  logic but it definitely required not using `TcpServer` in tokio-proto at the
  very least, and otherwise required a few custom futures and such to track the
  various states. I have a hunch that tokio-proto could provide more options out
  of the box for something like this.
2017-02-15 06:19:56 -05:00
Ted Mielczarek 898f90824d Disable default features in error-chain to make the build continue to work with Rust 1.12 2017-01-31 07:24:47 -05:00
Ted Mielczarek 52630820ef Use error-chain to define Result+Error types, refactor cmdline::parse to use it. 2017-01-30 13:54:21 -05:00
Ted Mielczarek d83dd03de7 Use a named unix socket or named pipe to let the background server notify the client that it started successfully 2017-01-27 15:57:09 -05:00
Ted Mielczarek 1db21485e0 Add an `SCCACHE_ERROR_LOG` variable to redirect the server's stderr, so
we can get backtraces for unhandled panics.
2017-01-10 09:36:26 -05:00
Ted Mielczarek 52d9e699c4 Use my lru-cache branch until the changes land upstream 2016-12-07 12:15:01 -10:00
Ted Mielczarek 4308fa2932 use filetime 2016-12-07 12:15:01 -10:00
Ted Mielczarek 030ed02ab4 Make DiskCache limit the size of the on-disk cache by using LruDiskCache. Fixes #29 2016-12-07 12:15:01 -10:00
Ted Mielczarek e8b64ca447 Pull in app_dirs to get a better default local disk cache location 2016-11-17 10:59:15 -05:00
Ted Mielczarek a41f7e451e Don't block sending compile result to client on cache write. Fixes #19.
This change makes `get_cached_or_compile` return a `Future` for the
cache write instead of blocking on it. The server then waits for the
result on a thread. It also changes the server to record cache write
timings, and display the average in the stats.
2016-11-02 17:15:14 -04:00
Ted Mielczarek 1d591f811b daemonize the server process on unix 2016-10-26 16:22:52 -04:00
Ted Mielczarek 38e2b801fd make connecting to server a little more lenient when starting the server 2016-10-25 18:14:21 -04:00
Ted Mielczarek d115dc2c63 use local-encoding crate for stdout conversion 2016-09-21 15:57:28 -04:00
Ted Mielczarek 30199bef4a drop openssl dep from hyper for now 2016-08-25 15:34:42 -04:00
Ted Mielczarek 657cb895f1 drop rusoto, import some simple s3 code and use that 2016-08-12 14:03:37 -04:00
Ted Mielczarek 3444252dff use rusoto master YOLO 2016-08-08 21:15:03 -04:00
Ted Mielczarek 1565f6a85e switch back to released version of which, switch to a rusoto branch with a bug fix 2016-08-08 15:06:06 -04:00
Ted Mielczarek 4c460d133b use my fork of which-rs until a fix gets released 2016-07-27 12:47:31 -04:00
Ted Mielczarek fe628ffd62 Update to a released rusoto, and 'cargo update' while we're at it 2016-07-15 11:31:56 -04:00
Ted Mielczarek dc5f2e295d bump sha1 crate to 0.2.0 2016-07-15 10:42:08 -04:00
Stefan Ilic 11771a06da Started using which crate (#14) 2016-07-14 06:38:26 -04:00
Stefan Ilic 8b8bbc339c Start using fern for logging (#9) 2016-06-28 07:12:54 -04:00
Ted Mielczarek 86aa35b191 Detect MSVC -showIncludes prefix (not actually wired up to anything yet) 2016-06-24 07:01:25 -04:00
Ted Mielczarek 7676daf23c switch to the rusoto feature_mutex_credentials branch 2016-06-10 13:39:32 -04:00
Ted Mielczarek 7dd4054df7 cargo.lock 2016-06-08 12:25:37 -04:00
Ted Mielczarek 68eebc2694 Implement S3Cache
Unlike sccache1, you need to specify both bucket and region, like:
SCCACHE_BUCKET=sccache
SCCACHE_REGION=us-east-1

Pretty limited testing, no automated tests currently.
2016-06-03 15:09:38 -04:00
Ted Mielczarek c11f6635df Implement fetching/storing to cache, interfaces for doing so, implement a disk cache 2016-05-21 14:14:26 -04:00
Ted Mielczarek a29fc7c1fe turn Compiler into CompilerKind, make a Compiler struct to hold some more info about compilers 2016-05-18 14:30:11 -04:00
Ted Mielczarek 3f9ee125d1 drop format_size code in favor of number_prefix crate 2016-05-12 15:46:22 -04:00
Ted Mielczarek fdf70251cc Update deps, fix build with newer rust-protobuf 2016-05-12 15:14:13 -04:00
Ted Mielczarek 60b1a7333f Commit Cargo.lock 2016-05-12 15:03:37 -04:00