Commit Graph

8 Commits

Author SHA1 Message Date
Jun Wu
ad60893b3f treestate: implement importmap in Rust
Summary:
Importing via Python is too slow. Therefore let's implement a native code
path for importing from other dirstate maps.

As we're here, modify treedirstate's import implementation so it skips
untracked files.

Reviewed By: markbt

Differential Revision: D7912557

fbshipit-source-id: ff1673ece2396a89fcc01e8b04041a6754cad885
2018-06-13 18:17:26 -07:00
Jun Wu
f4fdd7deea zstd: use Rust-backed bindings for its support
Summary:
This allows us to remove the Python binding without breaking existing zstd
users (commitcloud bundles). It might also make the future Rust migration
easier.

Using `zstd` create for its streaming APIs. `zstdelta`'s APIs cannot be used
since it requires decompressed length to be known, which wouldn't work for
streaming compressed data.

Note: For easier implementation, the Python land no longer processes data
in a streaming way. This is probably fine for the current bundle use-case.
In the long term, we might want to revisit the bundle format entirely.

As we're here, also expose zstdelta's APIs and add a test for it.

Reviewed By: DurhamG

Differential Revision: D8342421

fbshipit-source-id: 89902d551f4616469d6e1bc9b334a1c37c884775
2018-06-12 13:22:23 -07:00
Jun Wu
1f83a4dc00 treestate: require visitor to provide whether it modifies a file or not
Summary:
This is subtle. If visitor changes file state, `Node.id` should be set to
`None` to mark it as "changed".

In practise, treedirstate uses visitor to rewrite mtime to -1 if mtime is
"fsnow". Those rewritten mtime all belong to "changed" nodes (because "fsnow"
can only increase, and on-disk entries cannot have "mtime == fsnow" because
they would be written to -1 during the previous write), so it's not a problem
yet.

It is safer to not depend on the fact that "visitor" can only change "changed"
nodes. On the other hand, detecting changes for all filestate fields could be
undesirably expensive. So let's make the visitor provide the "changed or not"
information. Surely the visitor knows what it does.

Reviewed By: markbt

Differential Revision: D7909167

fbshipit-source-id: 21e71302cf1db86c1330b294baddd51cc8a96026
2018-06-11 14:32:42 -07:00
Jun Wu
ce8e166ebe treestate: add API to get directory's aggregated states
Summary:
Add an internal `get_dir` API to return aggregated states. It is exposed via
`.get('dir/')` python interface.

This is useful for implementing `hastrackeddir` of the dirstatemap class.

Reviewed By: markbt

Differential Revision: D7909173

fbshipit-source-id: 100a8f36237a6b911a4bfb4afbb4c63b98611317
2018-05-26 14:05:18 -07:00
Jun Wu
ee83f12849 treestate: move hgext.extlib.treedirstate to mercurial.rust.treestate
Summary:
Going to make changes to `mercurial/` for cleaner fsmonitor support
directly. So let's move the Rust python bridge there first.

Reviewed By: markbt

Differential Revision: D7909174

fbshipit-source-id: 454d784b5dca18a3af9328fc7b2f342cd4188cf6
2018-05-26 14:05:18 -07:00
Jun Wu
7de540805d setup: build rust extensions in a shared directory
Summary:
This avoids building shared dependencies (ex. regex) over and over. The only
downside is cargo will take a lock and cannot build projects in parallel.
But `setup.py` does not support building extensions in parallel. So it's
fine.

Changed `matcher` to also enable lto like existing extensions, so `cpython`
build result can be reused.

Before (on devserver):

  $ time python setup.py build_rust_ext
  real    2m19.401s
  user    3m35.118s
  sys     0m8.277s
  $ du -hs build/temp.linux-x86_64-2.7/
  115M    build/temp.linux-x86_64-2.7/

After:

  $ time python setup.py build_rust_ext
  real    2m4.371s
  user    2m25.864s
  sys     0m5.198s
  $ du -hs build/temp.linux-x86_64-2.7/
  58M     build/temp.linux-x86_64-2.7/

`cargo` builds things in parallel. The speed improvement would be more
significant on laptops.

Differential Revision: D7512429

fbshipit-source-id: 378e721890bdfe53c8adbe364ad5f0b374023ff5
2018-04-13 21:51:49 -07:00
Jun Wu
5ea461493e build: build Rust matcher
Summary: Build the new Rust matcher with both buck and setup.py

Reviewed By: markbt

Differential Revision: D7319607

fbshipit-source-id: c5944a28602495a9127acb20b59eb95632a9a1f5
2018-04-13 21:51:40 -07:00
Jun Wu
2136058b36 matcher: expose Rust matcher's features to Python
Summary:
It only contains a `gitignorematcher` which exposes `GitignoreMatcher`
features to Python.

Reviewed By: markbt

Differential Revision: D7319605

fbshipit-source-id: 846964a551813f9b0933bc30f4a0ba3f85362944
2018-04-13 21:51:40 -07:00