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

1892 Коммитов

Автор SHA1 Сообщение Дата
Alex Crichton bd24637441 Simplify clones on futures-related paths
This commit lifts out some logic of creation of `Command` structures to simplify
a few code paths and reduce clones, making it a little more ergonomic to
read/write. We'll just throw away the `Command` if we end up not using it!
2017-02-17 13:39:01 -05:00
Alex Crichton afebf21a0d Simplify writing temporary files
Add a helper which does all the grungy logic for us.
2017-02-17 13:39:01 -05:00
Alex Crichton 286df9b935 Knock out a TODO by printing termination signal
Print out the signal if the child terminated with one.
2017-02-17 13:39:01 -05: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 e500e46b35 Migrate to an `SFuture` ("sccache future") alias
At the same time also take more advantage of error-chain throughout the codebase
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 5f14d0be22 Reimplement get_cached_or_compile with futures
This commit just takes the synchronous version and reimplements it with
futures, using necessary combinators and such to prepare for running
commands with futures as well.

All process spawning/waiting still happens in a thread pool, this
commit just refactors methods to push futures all the way to down to the
lowest levels so we can integrate `tokio-process`.
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
Alex Crichton 4415a1e8df Fix a regression in us-east-1 buckets
It looks like the logic in #27 changed the default host name from
$bucket.s3.amazonaws.com to s3.amazonaws.com, but didn't accompany with changes
to upload to /$bucket in the path name. This restores the original behavior by
uploading to $bucket.s3.amazonaws.com without requiring changes to how paths are
constructed.
2017-02-02 16:35:36 -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
Jędrzej Nowacki 1b2b66fa58 Remove unused import
warning: unused import: `std::time::Duration`, #[warn(unused_imports)] on by default
   --> src/commands.rs:107:9
    |
107 |     use std::time::Duration;
    |         ^^^^^^^^^^^^^^^^^^^
2017-01-30 08:11:47 -05:00
Alex Crichton 2b6005293d Add support for gcc `@file` options
This commit adds support for the `@file` option that gcc/clang supports. This
option means that an `file` should be read and `@file` should be replaced with
all the options specified in `file`.

The online documentation indicates that gcc supports arguments with spaces
through quoting, but this seemed like it may be nontrivial to implement, so I
figured that for now those cases could continue to be un-cacheable.

Closes #43
2017-01-30 08:10:39 -05:00
Ted Mielczarek 319aacd7bd remove set_read_timeout because it's failing on mac. fixes #64 2017-01-30 06:32:28 -05:00
Mike Hommey 50ee9dd08b Support sccache being copied/hardlinked to a different name
Resolves #44.
2017-01-27 16:02:37 -05:00
Mike Hommey b4a44a911b Use CARGO_PKG_NAME as the App name for clap 2017-01-27 16:02:37 -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 277551dccc use cargo test --all on nightly 2017-01-27 12:08:58 -05:00
Ted Mielczarek bfa0d2a85b tweak build-release for windows 2017-01-27 11:45:55 -05:00
Ted Mielczarek bb3ba4a5b1 Fix a panic when a client connection occurs during shutdown. Fixes #63 2017-01-27 06:40:51 -05:00
Ted Mielczarek 8c083dfccc change SCCACHE_ERROR_LOG to open for append 2017-01-10 16:53:51 -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
Felix Obenhuber 0f5d67d42f Fix default logging initialization
If none of the logging environment variables are supplied
sccache creates a sccache2.log file on every sccache
invocation. Means, in every directory where a compilation takes
place a logfile is left afterwards. In the happy case this file
is empty. This can be kind of messy for larger projects where
the compiler invocation is done from multiple directories.

This patch changes the logging initialization:

* SCCACHE2_LOG_LEVEL is renamed to SCCACHE_LOG_LEVEL
* sccache2.log is renamed to sccache.log
* If none of RUST_LOG or SCCACHE_LOG_LEVEL is set, no logging is initialized.
* If RUST_LOG is set, only env_logger is used - no logfile is created.
2016-12-29 18:30:32 -05:00
Felix Obenhuber 2bdf30d691 Zero stats if -z --zero-stats is passed on cmdline
Straight forward implementation of clearing statistics
when -z or --zero-stats is passed on command line.
This command also outputs the stats upon successful
execution in order to provide feedback.
2016-12-20 05:51:04 -05:00
Felix Obenhuber f2f69e891c Fix average write duration and extend server stats (#52)
* Fix avg write duration and extend server stats

The average duration that is taken by a miss or hit is interesting
when testing different cache types. This patch adds the average time
taken by a cache miss and hit to the server stats. This measurements
can be entirely done in the server and do not need any changes to the
cache implementations.
Furthermore the calculation of the average duration for cache writes is
fixed (wrong factor used, that produced micros instead of millis).
2016-12-19 16:20:55 -05:00
Alex Newman d8a28bffad Add a snippet about logging level 2016-12-19 16:02:56 -05:00
Alex Newman 9c8cadc2d1 Fix to enable cargo install 2016-12-16 14:28:22 -05:00
Ted Mielczarek 2e3ea416f5 Fix get_cached_or_compile to not return preprocessor stdout if running the preprocessor fails
If running the preprocessor fails (because a #included file was not found, say)
sccache was returning the preprocessor stdout+stderr to the calling process,
which is wrong. This fixes it to just return the stderr, and drop the stdout.
2016-12-15 10:36:31 -05:00
Ted Mielczarek bcf3a7436f Try to use --features=unstable on nightly builds in CI 2016-12-13 10:59:21 -05:00
Ted Mielczarek c70dcf258f Don't create consoles for compiler invocations on Windows. Fixes #16.
This fixes the extra console windows that show up when the sccache server
creates compiler processes on Windows, but it only works on nightly Rust
currently, and requires building with `--features=unstable`, because it relies
on the not-yet-stable `windows_process_extensions` feature (https://github.com/rust-lang/rust/issues/37827).

Also I added a bunch of extra documentation to the mock_command traits.
2016-12-13 10:01:12 -05:00
Ted Mielczarek 6d7efe9bdc Fix races in the get_cached_or_compile tests.
As part of 030ed02ab4 I made `DiskCache::finish_put` write the cache entry to disk asynchronously, where previously it had been synchronous. This caused the `get_cached_or_compile` tests to be racy, specifically `test_compiler_get_cached_or_compile_cached`, which would store a cache entry and then immediately try to retrieve it. I've fixed this by making all the tests wait on the cache write future.
2016-12-13 08:16:03 -05:00
Harshavardhana aa5e965ac8 Add support for custom s3 endpoint url
Specify a new endpoint with `SCCACHE_ENDPOINT`
such as Minio https://github.com/minio/minio.

If not defaults to 's3.amazonaws.com'. Current
code for some reason was not working with custom
regions. Introduced a new ENV called `SCCACHE_REGION`
to handle cross region s3 URLs.
2016-12-13 01:12:50 -10:00
Ted Mielczarek decd0b1a99 Remove caveats about local disk cache from README 2016-12-07 12:54:26 -10:00
Ted Mielczarek 982ff329b2 Document Rust 1.12 as minimum required version, add Travis CI for it 2016-12-07 12:53:29 -10: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 be921be644 implement LruDiskCache 2016-12-07 12:15:01 -10:00
Yixi Zhang c77a8e81da More friendly README for Rust beginner 2016-12-06 15:54:58 -10:00
Ted Mielczarek a5d18f55ab Look for sccache binary in more places in system test. Should fix #37. 2016-12-01 06:36:52 -05:00
Ted Mielczarek 10fb1ad1c8 update readme a bit 2016-11-30 10:23:34 -05:00
Ms2ger 5591191bc1 Simplify loop in hash_key().
This also avoids an underflow if args is empty.
2016-11-30 09:17:28 -05:00
Christian Legnitto 6eadccc9d6 Do not cache if Clang modules are specified.
See https://twitter.com/TedMielczarek/status/800813453430624256.

`ccache` doesn't currently support them either. See this thread:

  https://lists.samba.org/archive/ccache/2016q3/001459.html

Support was disabled because of:

  https://bugzilla.samba.org/show_bug.cgi?id=11048

But looks like `ccache` may start supporting them soon with this PR:

  https://github.com/ccache/ccache/pull/130

...which may inform work that needs to be done for this project.
2016-11-21 21:40:41 -05:00
Mike Hommey 3da89195ce Merge the Rust reimplementation 2016-11-22 06:50:00 +09:00
Ted Mielczarek 5e0451f56c update readme 2016-11-21 09:48:06 -05:00
Ted Mielczarek b21198a718 Put sccache rev in tooltool manifests 2016-11-21 07:09:01 -05: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 89f4b44d01 fix AWS_IAM_CREDENTIALS_URL support 2016-11-16 16:06:16 -05:00