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

port from ~[T] to Vec<T> #11875

Closed
1 of 3 tasks
thestinger opened this issue Jan 28, 2014 · 8 comments
Closed
1 of 3 tasks

port from ~[T] to Vec<T> #11875

thestinger opened this issue Jan 28, 2014 · 8 comments
Labels
I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@thestinger
Copy link
Contributor

Annoying issues, but not hard blockers:

This is a significant performance improvement for any vectors that are grown, and will reduce heap allocation since zero-length vectors do not allocate and it does not have a header.

test bench::old_push              ... bench:     43200 ns/iter (+/- 804)
test bench::old_push_preallocated ... bench:     42948 ns/iter (+/- 4043)
test bench::push                  ... bench:      7190 ns/iter (+/- 245)
test bench::push_preallocated     ... bench:      6606 ns/iter (+/- 170)
#[cfg(test)]
extern mod extra;

#[cfg(test)]
mod bench {
    use std;
    use std::vec_ng::Vec;
    use extra::test::BenchHarness;

    static size: uint = 10000;

    #[bench]
    fn push(bh: &mut BenchHarness) {
        bh.iter(|| {
            let mut xs = Vec::with_capacity(16);
            for i in range(0, size) {
                xs.push(i);
            }
        });
    }

    #[bench]
    fn old_push(bh: &mut BenchHarness) {
        bh.iter(|| {
            let mut xs = std::vec::with_capacity(16);
            for i in range(0, size) {
                xs.push(i);
            }
        });
    }

    #[bench]
    fn push_preallocated(bh: &mut BenchHarness) {
        bh.iter(|| {
            let mut xs = Vec::with_capacity(size);
            for i in range(0, size) {
                xs.push(i);
            }
        });
    }

    #[bench]
    fn old_push_preallocated(bh: &mut BenchHarness) {
        bh.iter(|| {
            let mut xs = std::vec::with_capacity(size);
            for i in range(0, size) {
                xs.push(i);
            }
        });
    }
}

I moved the priority tag here from the old issue, as this is the same core issue but without the distractions of past issues and discussions that are no longer relevant.

@pnkfelix
Copy link
Member

cc me

@alexcrichton
Copy link
Member

The P- tags need to be added through the triage meeting, not manually, removing for now.

@alexcrichton
Copy link
Member

(also nominating)

@thestinger
Copy link
Contributor Author

@alexcrichton: The P- tag was already on this issue. I just closed the old one instead of heavily editing it and making the comments there irrelevant. If it's going to have to go through a meeting again, I'll just close this and edit the old one.

@alexcrichton
Copy link
Member

Oh sorry, I should have read the issue more closely!

@nikomatsakis
Copy link
Contributor

cc me

@aturon
Copy link
Member

aturon commented Jun 3, 2014

cc me

@thestinger
Copy link
Contributor Author

Keeping this metabug around no longer makes sense, since the blockers didn't actually end up blocking it.

bors added a commit to rust-lang-ci/rust that referenced this issue Dec 1, 2023
Fix `box_default` behaviour with empty `vec![]` coming from macro arg

Fix rust-lang#11868

changelog: [`box_default`]: do not warn on `Box::new(vec![])` if the `vec![]` comes from a macro argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

No branches or pull requests

5 participants