Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work towards removing headers from exchange allocations #7495

Merged
merged 7 commits into from Jul 1, 2013
Merged

work towards removing headers from exchange allocations #7495

merged 7 commits into from Jul 1, 2013

Conversation

thestinger
Copy link
Contributor

With these changes, exchange allocator headers are never initialized, read or written to. Removing the header will now just involve updating the code in trans using an offset to only do it if the type contained is managed.

The only thing blocking removing the initialization of the last field in the header was ~fn since it uses it to store the dynamic size/types due to captures. I temporarily switched it to a closure_exchange_alloc lang item (it uses the same exchange_free) and #7496 is filed about removing that.

Since the exchange_free call is now inlined all over the codebase, I don't think we should have an assert for null. It doesn't currently ever happen, but it would be fine if we started generating code that did do it. The exchange_free function also had a comment declaring that it must not fail, but a regular assert would cause a failure. I also removed the atomic counter because valgrind can already find these leaks, and we have valgrind bots now.

Note that exchange free does not currently print an error an out-of-memory when it aborts, because our io code may allocate. We could probably get away with a #[rust_stack] call to a stdio function but it would be better to make a write system call.

* stop using an atomic counter, this has a significant cost and
  valgrind will already catch these leaks
* remove the extra layer of function calls
* remove the assert of non-null in free, freeing null is well defined
  but throwing a failure from free will not be
* stop initializing the `prev`/`next` pointers
* abort on out-of-memory, failing won't necessarily work
@emberian
Copy link
Member

memory bench:

benchmark

Saw ~740ms speedup in clock time, ~740ms speedup in cpuacct time.

@thestinger
Copy link
Contributor Author

@cmr: well I don't expect there to be any noticeable change until the headers are actually gone. That's probably just from the atomic counter not being there, but that mostly has an effect in parallel code.

@thestinger
Copy link
Contributor Author

This is working on Linux and Windows but not on OS X. I'm trying to figure out where it goes wrong.

this is no longer used, exchange allocations do not set ref_count
the only user of the tydesc is ~fn, and it doesn't use this glue code
this makes the exchange allocation header completely unused, and leaves
it uninitialized
bors added a commit that referenced this pull request Jun 30, 2013
With these changes, exchange allocator headers are never initialized, read or written to. Removing the header will now just involve updating the code in trans using an offset to only do it if the type contained is managed.

The only thing blocking removing the initialization of the last field in the header was ~fn since it uses it to store the dynamic size/types due to captures. I temporarily switched it to a `closure_exchange_alloc` lang item (it uses the same `exchange_free`) and #7496 is filed about removing that.

Since the `exchange_free` call is now inlined all over the codebase, I don't think we should have an assert for null. It doesn't currently ever happen, but it would be fine if we started generating code that did do it. The `exchange_free` function also had a comment declaring that it must not fail, but a regular assert would cause a failure. I also removed the atomic counter because valgrind can already find these leaks, and we have valgrind bots now.

Note that exchange free does not currently print an error an out-of-memory when it aborts, because our `io` code may allocate. We could probably get away with a `#[rust_stack]` call to a `stdio` function but it would be better to make a write system call.
@bors bors closed this Jul 1, 2013
@bors bors merged commit 4a29d6e into rust-lang:master Jul 1, 2013
bors added a commit that referenced this pull request Jul 1, 2013
bors added a commit that referenced this pull request Jul 8, 2013
This is work continued from the now landed #7495 and #7521 pulls.

Removing the headers from unique vectors is another project, so I've separated the allocator.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 29, 2021
Improve conflicting rlibs error again

changelog: none

Now you can do `rm <paste>` and 🐇💨

```text
thread 'compile_test' panicked at '
----------------------------------------------------------------------
ERROR: Found multiple rlibs for crates: `clippy_lints`, `clippy_utils`
Try running `cargo clean` or remove the following files:

target/debug/deps/libclippy_lints-9117c875159004e0.rlib \
target/debug/deps/libclippy_lints-fe45157be7ff9444.rlib \
target/debug/deps/libclippy_utils-5eba1e07a9846ed0.rlib \
target/debug/deps/libclippy_utils-ccbc08fcf64de262.rlib

For details on this error see rust-lang/rust-clippy#7343
----------------------------------------------------------------------
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants