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

specialize some collection and iterator operations to run in-place #70793

Merged
merged 63 commits into from
Sep 3, 2020

Commits on Sep 3, 2020

  1. unrelated typo fix

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    076417e View commit details
    Browse the repository at this point in the history
  2. bench

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    038394a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bb2d533 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    2a32739 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    73a982e View commit details
    Browse the repository at this point in the history
  6. implement drop handling

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    88b7ae6 View commit details
    Browse the repository at this point in the history
  7. use add instead of offset

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    328a75f View commit details
    Browse the repository at this point in the history
  8. fix doc link

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    f904d03 View commit details
    Browse the repository at this point in the history
  9. simplify pointer arithmetic

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    bead910 View commit details
    Browse the repository at this point in the history
  10. update benches

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    6c5c47b View commit details
    Browse the repository at this point in the history
  11. recover vectorization

    switch to try_fold and segregate the drop handling to keep
    collect::<Vec<u8>>() and similar optimizer-friendly
    
    It comes at the cost of less accurate debug_asserts and code complexity
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    2320650 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    b90816d View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    07a8c1b View commit details
    Browse the repository at this point in the history
  14. restore Vec::extend specialization for vec::IntoIter sources that

    was lost during refactoring
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    631543d View commit details
    Browse the repository at this point in the history
  15. use memmove instead of generic in-place iteration for IntoIter source

    this is the original SpecExtend<_, IntoIter> logic except generalizing
    the fast-path to include a memmove
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    a4e385a View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    2f700d0 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    bb4f888 View commit details
    Browse the repository at this point in the history
  18. cyclic in-place reuse bench

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    8ac96e6 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    a9c78e3 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    a596ff3 View commit details
    Browse the repository at this point in the history
  21. use From specializations on extend if extended Vec is empty

    this enables in-place iteration and allocation reuse in additional cases
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    582fbb1 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    dac0edf View commit details
    Browse the repository at this point in the history
  23. specialize creating a Vec from a slice iterator where T: Copy

    this was already implemented for Extend but not for FromIterator
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    290fe89 View commit details
    Browse the repository at this point in the history
  24. improve comments

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    cc67c8e View commit details
    Browse the repository at this point in the history
  25. remove redundant code

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    8c816b9 View commit details
    Browse the repository at this point in the history
  26. fix some in-place-collect edge-cases

    - it's an allocation optimization, so don't attempt to do it on ZSTs
    - drop the tail of partially exhausted iters
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    00a32eb View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    2b0b2ae View commit details
    Browse the repository at this point in the history
  28. bench in-place zip

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    3d5e9f1 View commit details
    Browse the repository at this point in the history
  29. add in-place iteration for Zip

    this picks the left hand side as source since it might be more natural to
    consume that as IntoIter source
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    0f122e1 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    085eb20 View commit details
    Browse the repository at this point in the history
  31. support in-place iteration for most adapters

    `Take` is not included since users probably call it with small constants
    and it doesn't make sense to hold onto huge allocations in that case
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    21a17d1 View commit details
    Browse the repository at this point in the history
  32. make tidy happy

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    70293c6 View commit details
    Browse the repository at this point in the history
  33. remove unecessary feature flag

    # Conflicts:
    #	library/alloc/src/lib.rs
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    fbb3371 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    fd16202 View commit details
    Browse the repository at this point in the history
  35. bench larger allocations

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    e115184 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    e85cfa4 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    0856771 View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    c731648 View commit details
    Browse the repository at this point in the history
  39. avoid exposing that binary heap's IntoIter is backed by vec::IntoIter…

    …, use a private trait instead
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    2a51e57 View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    ab382b7 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    6ed05fd View commit details
    Browse the repository at this point in the history
  42. pacify tidy

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    9596e5a View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    0d2d033 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    fe350dd View commit details
    Browse the repository at this point in the history
  45. Configuration menu
    Copy the full SHA
    470bf54 View commit details
    Browse the repository at this point in the history
  46. remove redundant cast

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    a7a8b52 View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    6ad1334 View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    771b8ec View commit details
    Browse the repository at this point in the history
  49. work around compiler overhead around lambdas in generics by extractin…

    …g them into free functions
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    872ab78 View commit details
    Browse the repository at this point in the history
  50. increase comment verbosity

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    fa34b39 View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    5530858 View commit details
    Browse the repository at this point in the history
  52. pacify tidy

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    55d1296 View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    8063833 View commit details
    Browse the repository at this point in the history
  54. Configuration menu
    Copy the full SHA
    bec9f92 View commit details
    Browse the repository at this point in the history
  55. fix benchmark compile errors

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    a62cd1b View commit details
    Browse the repository at this point in the history
  56. avoid applying in-place collect specialization in type-length test

    the test was sized to match external iteration only, since
    vec's in-place collect now uses internal iteration we collect into
    a different type now.
    Note that any other try-fold based operation such as count() would also
    have exceeded the type length limit for that iterator.
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    7badb7a View commit details
    Browse the repository at this point in the history
  57. get things to work under min_specialization by leaning more heavily o…

    …n #[rustc_unsafe_specialization_marker]
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    9aeea00 View commit details
    Browse the repository at this point in the history
  58. please tidy

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    7492f76 View commit details
    Browse the repository at this point in the history
  59. remove empty Vec extend optimization

    The optimization meant that every extend code path had to emit llvm
    IR for from_iter and extend spec_extend, which likely impacts
    compile times while only improving a few edge-cases
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    435219d View commit details
    Browse the repository at this point in the history
  60. Configuration menu
    Copy the full SHA
    acdd441 View commit details
    Browse the repository at this point in the history
  61. Configuration menu
    Copy the full SHA
    6464586 View commit details
    Browse the repository at this point in the history
  62. improve comments and naming

    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    8e5fe55 View commit details
    Browse the repository at this point in the history
  63. fix debug assertion

    The InPlaceIterable debug assert checks that the write pointer
    did not advance beyond the read pointer. But TrustedRandomAccess
    never advances the read pointer, thus triggering the assert.
    Skip the assert if the source pointer did not change during iteration.
    the8472 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    2f23a0f View commit details
    Browse the repository at this point in the history