Skip to content
Snippets Groups Projects
  1. Oct 31, 2023
  2. Oct 20, 2023
    • Georges Racinet's avatar
      rust-index: optimize find_gca_candidates() on less than 8 revisions · 1b23aaf5eb7b
      Georges Racinet authored
      This is expected to be by far the most common case, given that, e.g.,
      merging involves using it on two revisions.
      
      Using a `u8` as support for the bitset obviously divides the amount of
      RAM needed by 8. To state the obvious, on a repository with 10 million
      changesets, this spares 70MB. It is also possible that it'd be slightly
      faster, because it is easier to allocate and provides better cache locality.
      
      It is possible that some exhaustive listing of the traits implemented by
      `u8` and `u64` would avoid the added duplication, but that can be done later
      and would need a replacement for the `MAX` consts.
      1b23aaf5eb7b
    • Georges Racinet's avatar
      rust-index: simplification in find_gca_candidates() · 61a6ef876efd
      Georges Racinet authored
      `parent_seen` can be made a mutable ref, making this part more obvious,
      not needing to be commented so much.
      
      The micro-optimization of avoiding the union if `parent_seen` and
      `current_seen` agree is pushed down in the `union()` method of the
      fast, `u64` based bit set implementation (in case it matters).
      61a6ef876efd
    • Georges Racinet's avatar
      e553cd209215
    • Georges Racinet's avatar
      rust-index: avoid some cloning in find_gca_candidates() · 83091c14058c
      Georges Racinet authored
      Instead of keeping the information whether the current revision is
      poisoned on `current_seen`, we extract it as a boolean.
      
      This also allows us to simplify the explanation of `seen[r].is_poisoned()`,
      as the exceptional case where it is poisoned right after `r` has been
      determined to be a solution does no longer exist.
      83091c14058c
  3. Oct 18, 2023
    • Georges Racinet's avatar
      rust-index: implement common_ancestors_heads() and ancestors() · 89ce6a49bfeb
      Georges Racinet authored
      The only differences betwwen `common_ancestors_heads()` and
      `find_gca_candidates()` seems to be that:
      
      - the former accepts "overlapping" input revisions (meaning with duplicates).
      - limitation to 24 inputs (in the C code), that we translate to using the
        arbitrary size bit sets in the Rust code because we cannot bail to Python.
      
      Given that the input is expected to be small in most cases, we take the
      heavy handed approach of going through a HashSet and wait for perfomance
      assessment
      
      In case this is used via `hg-cpython`, we can anyway absorb the overhead
      by having `commonancestorheads` build a vector of unique values
      directly, and introduce a thin wrapper over `find_gca_candidates`, to take
      care of bit set type dispatching only.
      
      As far as `ancestors` is concerneed, this is just chaining
      `common_ancestors_heads()` with `find_deepest_revs`.
      89ce6a49bfeb
  4. Oct 17, 2023
    • Georges Racinet's avatar
      rust-index: find_gca_candidates bit sets genericization · 43241f31cf5b
      Georges Racinet authored
      This allows to use arbitratry size of inputs in `find_gca_candidates()`.
      We're genericizing so that the common case of up to 63 inputs can be
      treated with the efficient implementation backed by `u64`.
      
      Some complications with the borrow checker came, because arbitrary sized
      bit sets will not be `Copy`, hence mutating them keeps a mut ref on the `seen`
      vector. This is solved by some cloning, most of which can be avoided,
      preferably in a follow-up after proof that this works (hence after exposition
      to Python layer).
      
      As far as performance is concerned, calling `clone()` on a `Copy` object
      (good case when number of revs is less than 64) should end up just doing a
      copy, according to this excerpt of the `Clone` trait documentation:
      
        Types that are Copy should have a trivial implementation of Clone.
        More formally: if T: Copy, x: T, and y: &T, then let x = y.clone();
        is equivalent to let x = *y;.
        Manual implementations should be careful to uphold this invariant;
        however, unsafe code must not rely on it to ensure memory safety.
      
      We kept the general structure, hence why there are some double negations.
      This also could be made nicer in a follow-up.
      
      The `NonStaticPoisonableBitSet` is included to ensure that the
      `PoisonableBitSet` trait is general enough (had to correct `vec_of_empty()` for
      instance). Moving the genericization one level to encompass the `seen`
      vector and not its elements would be better for performance, if worth it.
      43241f31cf5b
  5. Nov 02, 2023
  6. Oct 30, 2023
  7. Nov 02, 2023
  8. Oct 30, 2023
  9. Sep 30, 2023
    • Georges Racinet's avatar
      rust-index: slicechunktodensity returns Rust result · 8cb31833b486
      Georges Racinet authored
      Ready for removal of the scaffolding.
      
      This time, we allow ourselves a minor optimization: we avoid
      allocating for each chunk. Instead, we reuse the same vector,
      and perform at most one allocation per chunk.
      The `PyList` constructor will copy the buffer anyway.
      8cb31833b486
  10. Nov 02, 2023
  11. Sep 29, 2023
  12. Oct 30, 2023
  13. Sep 19, 2023
  14. Sep 30, 2023
  15. Aug 03, 2023
  16. Aug 02, 2023
  17. Aug 03, 2023
  18. Aug 02, 2023
  19. Oct 30, 2023
  20. Nov 02, 2023
    • Raphaël Gomès's avatar
      rust-index: implementation of __getitem__ · 002b49905aac
      Raphaël Gomès authored
      Although the removed panic tends to prove if the full test suite
      did pass that the case when the input is a node id does not happen,
      it is best not to remove it right now.
      
      Raising IndexError is crucial for iteration on the index to stop,
      given the default CPython sequence iterator, see for instance
      https://github.com/zpoint/CPython-Internals/blobs/master/BasicObject/iter/iter.md
      This was spotted by `test-rust-ancestors.py`, which does simple interations on
      indexes (as preflight checks).
      
      In `revlog.c`, `index_getitem` defaults to `index_get` when called
      on revision numbers, which does raise `IndexError` with the same message as
      the one we are introducing here.
      002b49905aac
  21. Sep 27, 2023
  22. Nov 02, 2023
  23. Sep 30, 2023
    • Georges Racinet's avatar
      rust-index: return variables systematic naming convention · 16d477bb0078
      Georges Racinet authored
      To help knowing at a glance when a method is ready, making
      us more comofortable when we are close to the final removal of
      scaffolding, we introduce the systematic variable names `rust_res` and
      `c_res`. The goal of this series is to always return the formet.
      
      We take again the case of `pack_header` as example.
      
      Our personal opinion is to usually avoid such poor semantics as `res`, but
      usually accept it when it close to the actual return, which will be the
      case in most methods of this series. Also, the name can simply be dropped
      when we remove the scaffolding. To follow on the example, the body of
      `pack_header()` should become this in the final version:
      
      ```
          let index = self.index(py).borrow();
          let packed = index.pack_header(args.get_item(py, 0).extract(py)?);
          Ok(PyBytes::new(py, &packed).into_object());
      ```
      
      in these cases it is close to the actual return and will be removed
      at the end entirely.
      16d477bb0078
  24. Sep 29, 2023
    • Georges Racinet's avatar
      rust-index: results comparison helper with details · 52bbb57a76ad
      Georges Racinet authored
      This is a bit simpler to call and has the advantage of systematically log
      the encountered deviation.
      
      To avoid committing dead code, we apply it to the `pack_header` method, that
      was already returning the Rust result.
      52bbb57a76ad
  25. Sep 27, 2023
  26. Oct 18, 2023
  27. Aug 03, 2023
  28. Oct 30, 2023
  29. Jun 29, 2023
  30. Jun 28, 2023
Loading