Commit Graph

23440 Commits

Author SHA1 Message Date
bors
f1b87726b7 auto merge of #10048 : ibukanov/rust/mkdir-fix, r=brson
The patch replaces mkdir -p dir with (umask 022 && mkdir -p dir). Sadly mkdir -m 755 -p dir does not work if it creates parent directories as those parents will have umask permissions, not the one passed with -m option.   

Closes #10046
2013-10-26 01:11:11 -07:00
Alex Crichton
357ef1f69c Rewrite boxed_region/memory_region in Rust
This drops more of the old C++ runtime to rather be written in rust. A few
features were lost along the way, but hopefully not too many. The main loss is
that there are no longer backtraces associated with allocations (rust doesn't
have a way of acquiring those just yet). Other than that though, I believe that
the rest of the debugging utilities made their way over into rust.

Closes #8704
2013-10-26 01:10:39 -07:00
bors
d53159a643 auto merge of #10070 : alexcrichton/rust/fewer-missiles, r=brson
This optimizes the `home_for_io` code path by requiring fewer scheduler
operations in some situtations.

When moving to your home scheduler, this no longer forces a context switch if
you're already on the home scheduler. Instead, the homing code now simply pins
you to your current scheduler (making it so you can't be stolen away). If you're
not on your home scheduler, then we context switch away, sending you to your
home scheduler.

When the I/O operation is done, then we also no longer forcibly trigger a
context switch. Instead, the action is cased on whether the task is homed or
not. If a task does not have a home, then the task is re-flagged as not having a
home and no context switch is performed. If a task is homed to the current
scheduler, then we don't do anything, and if the task is homed to a foreign
scheduler, then it's sent along its merry way.

I verified that there are about a third as many `write` syscalls done in print
operations now. Libuv uses write to implement async handles, and the homing
before and after each I/O operation was triggering a write on these async
handles. Additionally, using the terrible benchmark of printing 10k times in a
loop, this drives the runtime from 0.6s down to 0.3s (yay!).
2013-10-26 00:06:09 -07:00
Alex Crichton
7a1d97e62c Enhance timers to create ports
In addition to being able to sleep the current task, timers should be able to
create ports which get notified after a period of time.

Closes #10014
2013-10-25 22:12:55 -07:00
bors
c5074ae646 auto merge of #10082 : brson/rust/gyp, r=huonw
The upstream repo has been offline for hours. A single point of failure is plenty.
2013-10-25 21:09:37 -07:00
Brian Anderson
b4dabd4094 Point gyp submodule toward github 2013-10-25 20:23:53 -07:00
Brian Anderson
a849c476f5 Encapsulate the lock-free mpsc queue in the MessageQueue type 2013-10-25 19:56:49 -07:00
Brian Anderson
1ce5081f4d Add links to original mpmc and mpsc implementations 2013-10-25 19:46:35 -07:00
Brian Anderson
49d9135eea Tidy 2013-10-25 18:33:05 -07:00
Jason Toffaletti
5e91ac10b6 minor 2013-10-25 18:27:46 -07:00
Jason Toffaletti
8c95f558d0 minor 2013-10-25 18:27:46 -07:00
Jason Toffaletti
1916732cfd fix bug introduced by previous clean up. more clean up. 2013-10-25 18:27:45 -07:00
Jason Toffaletti
89c91208a7 clean up 2013-10-25 18:27:45 -07:00
Jason Toffaletti
c372fa5556 add padding to prevent false sharing 2013-10-25 18:27:45 -07:00
Jason Toffaletti
5876e21225 add multi-producer multi-consumer bounded queue to use for sleeper list 2013-10-25 18:27:45 -07:00
Jason Toffaletti
bf0e6eb346 add cache line padding 2013-10-25 18:27:45 -07:00
Jason Toffaletti
c62d604531 lock-free queue for scheduler message queue 2013-10-25 18:27:45 -07:00
Brian Anderson
9a773da681 Remove ancient emacs mode lines from test cases
These are relics that serve no purpose.
2013-10-25 17:41:54 -07:00
Alex Crichton
e4c6523c65 Fire fewer homing missiles
This optimizes the `home_for_io` code path by requiring fewer scheduler
operations in some situtations.

When moving to your home scheduler, this no longer forces a context switch if
you're already on the home scheduler. Instead, the homing code now simply pins
you to your current scheduler (making it so you can't be stolen away). If you're
not on your home scheduler, then we context switch away, sending you to your
home scheduler.

When the I/O operation is done, then we also no longer forcibly trigger a
context switch. Instead, the action is cased on whether the task is homed or
not. If a task does not have a home, then the task is re-flagged as not having a
home and no context switch is performed. If a task is homed to the current
scheduler, then we don't do anything, and if the task is homed to a foreign
scheduler, then it's sent along its merry way.

I verified that there are about a third as many `write` syscalls done in print
operations now. Libuv uses write to implement async handles, and the homing
before and after each I/O operation was triggering a write on these async
handles. Additionally, using the terrible benchmark of printing 10k times in a
loop, this drives the runtime from 0.6s down to 0.3s (yay!).
2013-10-25 16:18:01 -07:00
bors
dcdcd309fb auto merge of #10067 : sanxiyn/rust/addr-of-bot, r=thestinger
Fix #5500.
2013-10-25 12:56:20 -07:00
bors
953e56052f auto merge of #10066 : sanxiyn/rust/mut-ptr-clone, r=thestinger 2013-10-25 11:46:11 -07:00
bors
baeed886aa auto merge of #10060 : alexcrichton/rust/cached-stdout, r=brson
Almost all languages provide some form of buffering of the stdout stream, and
this commit adds this feature for rust. A handle to stdout is lazily initialized
in the Task structure as a buffered owned Writer trait object. The buffer
behavior depends on where stdout is directed to. Like C, this line-buffers the
stream when the output goes to a terminal (flushes on newlines), and also like C
this uses a fixed-size buffer when output is not directed at a terminal.

We may decide the fixed-size buffering is overkill, but it certainly does reduce
write syscall counts when piping output elsewhere. This is a *huge* benefit to
any code using logging macros or the printing macros. Formatting emits calls to
`write` very frequently, and to have each of them backed by a write syscall was
very expensive.

In a local benchmark of printing 10000 lines of "what" to stdout, I got the
following timings:

  when |  terminal   |  redirected
----------|---------------|--------
before |  0.575s     |   0.525s
after  |  0.197s     |   0.013s
  C    |  0.019s     |   0.004s

I can also confirm that we're buffering the output appropriately in both
situtations. We're still far slower than C, but I believe much of that has to do
with the "homing" that all tasks due, we're still performing an order of
magnitude more write syscalls than C does.
2013-10-25 10:36:09 -07:00
Alex Crichton
e8f72c38f4 Cache and buffer stdout per-task for printing
Almost all languages provide some form of buffering of the stdout stream, and
this commit adds this feature for rust. A handle to stdout is lazily initialized
in the Task structure as a buffered owned Writer trait object. The buffer
behavior depends on where stdout is directed to. Like C, this line-buffers the
stream when the output goes to a terminal (flushes on newlines), and also like C
this uses a fixed-size buffer when output is not directed at a terminal.

We may decide the fixed-size buffering is overkill, but it certainly does reduce
write syscall counts when piping output elsewhere. This is a *huge* benefit to
any code using logging macros or the printing macros. Formatting emits calls to
`write` very frequently, and to have each of them backed by a write syscall was
very expensive.

In a local benchmark of printing 10000 lines of "what" to stdout, I got the
following timings:

  when |  terminal   |  redirected
----------------------------------
before |  0.575s     |   0.525s
after  |  0.197s     |   0.013s
  C    |  0.019s     |   0.004s

I can also confirm that we're buffering the output appropriately in both
situtations. We're still far slower than C, but I believe much of that has to do
with the "homing" that all tasks due, we're still performing an order of
magnitude more write syscalls than C does.
2013-10-25 10:31:57 -07:00
Seo Sanghyeon
f04886b6bf Allow taking address of bottom 2013-10-25 19:15:29 +09:00
Seo Sanghyeon
568576bab0 Implement Clone trait for mutable unsafe pointers 2013-10-25 18:43:55 +09:00
bors
deeca5d586 auto merge of #10054 : alexcrichton/rust/basic-event-loop, r=brson
This is more progress towards #9128 and all its related tree of issues. This implements a new `BasicLoop` on top of pthreads synchronization primitives (wrapped in `LittleLock`). This also removes the wonky `callback_ms` function from the interface of the event loop.

After #9901 is taking forever to land, I'm going to try to do all this runtime work in much smaller chunks than before. Right now this will not work unless #9901 lands first, but I'm close to landing it (hopefully), and I wanted to go ahead and get this reviewed before throwing it at bors later on down the road.

This "pausible idle callback" is also a bit of a weird idea, but it wasn't as difficult to implement as callback_ms so I'm more semi-ok with it.
2013-10-25 00:46:11 -07:00
Alex Crichton
64a5c3bc1e Implement a basic event loop built on LittleLock
It's not guaranteed that there will always be an event loop to run, and this
implementation will serve as an incredibly basic one which does not provide any
I/O, but allows the scheduler to still run.

cc #9128
2013-10-24 23:49:11 -07:00
bors
ac82d185b0 auto merge of #10061 : thestinger/rust/rustc, r=alexcrichton 2013-10-24 23:36:10 -07:00
Luqman Aden
523a28decc libsyntax: Get rid of obsolete obsolete warning. 2013-10-25 01:50:57 -04:00
Luqman Aden
26488b7465 librustc: Don't emit unused mut lint twice. 2013-10-25 01:50:57 -04:00
Luqman Aden
f5e64aeb41 Test for mut in ident patterns. 2013-10-25 01:50:56 -04:00
Luqman Aden
99b7662971 libsyntax: Get rid of some logic for some obsolete syntax. 2013-10-25 01:21:07 -04:00
Luqman Aden
12308db3d2 libsyntax/librustc: Allow mut qualifier in patterns. 2013-10-25 01:21:07 -04:00
Daniel Micay
327878e628 remove some dead trans code 2013-10-24 21:58:47 -04:00
bors
c16a95c587 auto merge of #10059 : thestinger/rust/glue, r=pcwalton
Closes #10045
2013-10-24 18:56:05 -07:00
Daniel Micay
d497e6e954 stop trying to outsmart LLVM inline heuristics
Closes #10045
2013-10-24 20:41:23 -04:00
bors
b0c475229a auto merge of #10055 : pcwalton/rust/arc-clone-inline, r=alexcrichton
r? @thestinger
2013-10-24 17:36:07 -07:00
Alex Crichton
3ee5ef12fb Remove the 'callback_ms' function from EventLoop
This is a peculiar function to require event loops to implement, and it's only
used in one spot during tests right now. Instead, a possibly more robust apis
for timers should be used rather than requiring all event loops to implement a
curious-looking function.
2013-10-24 15:17:27 -07:00
Alex Crichton
3b30377e14 Fix a bug with the scheduler and destructor order
The PausibleIdleCallback must have some handle into the event loop, and because
struct destructors are run in order of top-to-bottom in order of fields, this
meant that the event loop was getting destroyed before the idle callback was
getting destroyed.

I can't confirm that this fixes a problem in how we use libuv, but it does
semantically fix a problem for usage with other event loops.
2013-10-24 15:16:58 -07:00
bors
3f5b2219cc auto merge of #9901 : alexcrichton/rust/unix-sockets, r=brson
Large topics:

* Implemented `rt::io::net::unix`. We've got an implementation backed by "named pipes" for windows for free from libuv, so I'm not sure if these should be `cfg(unix)` or whether they'd be better placed in `rt::io::pipe` (which is currently kinda useless), or to leave in `unix`. Regardless, we probably shouldn't deny windows of functionality which it certainly has.
* Fully implemented `net::addrinfo`, or at least fully implemented in the sense of making the best attempt to wrap libuv's `getaddrinfo` api
* Moved standard I/O to a libuv TTY instead of just a plain old file descriptor. I found that this interacted better when closing stdin, and it has the added bonus of getting things like terminal dimentions (someone should make a progress bar now!)
* Migrate to `~Trait` instead of a typedef'd object where possible. There are only two more types which are blocked on this, and those are traits which have a method which takes by-value self (there's an open issue on this)
* Drop `rt::io::support::PathLike` in favor of just `ToCStr`. We recently had a lot of Path work done, but it still wasn't getting passed down to libuv (there was an intermediate string conversion), and this allows true paths to work all the way down to libuv (and anything else that can become a C string).
* Removes `extra::fileinput` and `extra::io_util`


Closes #9895 
Closes #9975
Closes #8330
Closes #6850 (ported lots of libraries away from std::io)
cc #4248 (implemented unix/dns)
cc #9128 (made everything truly trait objects)
2013-10-24 14:26:15 -07:00
Alex Crichton
188e471339 Another round of test fixes and merge conflicts 2013-10-24 14:22:35 -07:00
Alex Crichton
d425218395 Bring io::signal up to date with changes to rt::rtio 2013-10-24 14:22:35 -07:00
Do Nhat Minh
b5a02e0784 wrapping libuv signal for use in Rust
descriptive names
easier-to-use api
reorganize and document
2013-10-24 14:22:35 -07:00
Alex Crichton
816e46dd63 Fixing some tests, adding some pipes
This adds constructors to pipe streams in the new runtime to take ownership of
file descriptors, and also fixes a few tests relating to the std::run changes
(new errors are raised on io_error and one test is xfail'd).
2013-10-24 14:22:35 -07:00
Alex Crichton
262b958a4b Migrate std::run to libuv processes 2013-10-24 14:22:35 -07:00
Alex Crichton
6bb1df9251 Remove std::io once and for all! 2013-10-24 14:22:34 -07:00
Alex Crichton
c4907cfd14 Remove std::io from ebml 2013-10-24 14:21:58 -07:00
Alex Crichton
620ab3853a Test fixes and merge conflicts 2013-10-24 14:21:58 -07:00
Alex Crichton
279c351820 Move stdin to using libuv's pipes instead of a tty
I was seeing a lot of weird behavior with stdin behaving as a tty, and it
doesn't really quite make sense, so instead this moves to using libuv's pipes
instead (which make more sense for stdin specifically).

This prevents piping input to rustc hanging forever.
2013-10-24 14:21:58 -07:00
Alex Crichton
6b70ddfba1 Remove io::read_error
The general idea is to remove conditions completely from I/O, so in the meantime
remove the read_error condition to mean the same thing as the io_error condition.
2013-10-24 14:21:57 -07:00