Commit Graph

43513 Commits

Author SHA1 Message Date
Liubov Dmitrieva
2d82868f9f scm daemon, write pid file (to be used for restart after log rotation)
Summary: write pid file

Reviewed By: markbt

Differential Revision: D8331445

fbshipit-source-id: 47492ffc9cc87a2ef228ce9581873dec6e01e369
2018-06-08 06:31:10 -07:00
Durham Goode
63fe3fd2c3 packs: add remediation for failures while loading packs
Summary:
In a previous diff we added logic to delete corrupt packs in the cache
directories, but the logic only caught issues after the pack was loaded. We also
need to catch issues while loading the pack. This happens when a pack file is 0
length.

Reviewed By: quark-zju

Differential Revision: D8324248

fbshipit-source-id: c2fcb4f69c4627cce316d626e91f752ef562a0d9
2018-06-07 17:50:56 -07:00
Jun Wu
7ae93c7eef cleanup: remove bundled python-zstandard
Summary:
We use lz4 compression in production. Regarding on zstd, our approach would
be using the Rust `lib/zstdelta` library. So there is no need to keep the
Python binding.

This makes `make local` faster and also makes internal code search about
zstd cleaner.

Reviewed By: DurhamG, phillco

Differential Revision: D8302882

fbshipit-source-id: a6c34d6fea59140caeac158274388ba75a28fb29
2018-06-07 16:21:47 -07:00
Kostia Balytskyi
45a8ff9b73 auditor: add a config option to enable wvfs path auditor caching
Summary:
The reason caching is disabled seems to be that symlinks can change where
paths points to, while some properties of that path are cached.

Sometimes we know that symlinks are not used in the repo, so we'd like hg
to let us shoot ourselves in the foot.

The motivation here is that I have a specially crafted rebase operation,
which makes on the order of 400000 stat-like syscalls without caching and
on the order of 6000 with caching. This can save ~20s on Windows.

Note that this setting is disabled by default so we can't break anything.
FWIW, we already have an unsafe config option, which allows us to opt into the "we don't do crazy stuff with symlinks" behavior, it's called `unsafe.filtersuspectsymlink`, setting it to false speeds up Windows `status` and we do so for `ovrsource` on Windows.

Reviewed By: quark-zju

Differential Revision: D8297129

fbshipit-source-id: ec751d18b50b042f28f68c9e1a3634ab94a4e7c3
2018-06-07 15:53:07 -07:00
Jun Wu
687bff8f61 connectionpool: fix undefined variable
Summary: `self.repo` is undefined here.

Reviewed By: phillco

Differential Revision: D8321105

fbshipit-source-id: 7b61bb40ee06dd923cb2d7a64a9fe97da2b924a9
2018-06-07 15:53:07 -07:00
Phil Cohen
48219d6c07 log maxxrss from within mercurial
Summary:
An updated version of D8174246 with a test. Max memory usage is very useful to us to understand which commands are using too much memory, and the existing wrapper metrics don't work when chg is used (they measure chg's usage).

Windows support will come later as it is a bit more involved.

Reviewed By: DurhamG

Differential Revision: D8318584

fbshipit-source-id: 323450bc7ab376014d70106beb5d4fdcc7fba0c8
2018-06-07 11:50:46 -07:00
Jun Wu
cde52cfb13 cleanup: remove leftover directories
Summary:
`hgsubversion` and `lz4revlog` were moved to `hgext`. So the top-level
directories can be removed.

Reviewed By: DurhamG, phillco

Differential Revision: D8302880

fbshipit-source-id: 3b783b97f5d77585d406c9e405b4dffe17dd284e
2018-06-07 11:50:46 -07:00
Durham Goode
eabf7f1b4d treemanifest: add root-only sqltreestrip option
Summary:
In the new corruption fix strategy, we're only going to strip the
entries from the root treemanifest revlog. This will leave all the
still-referenced sub-trees available for fetching if clients still have old
references to them, while preventing new references from being taken from the
root nodes.

Reviewed By: phillco

Differential Revision: D8284287

fbshipit-source-id: 4cc20bfdbf7ae5d32074dae22da4d37717ee5728
2018-06-07 11:06:01 -07:00
Adrian Catană
1a84d01de5 profiling - modify file opening for profiling
Summary:
Needed for windows to allow us write to a tempfile created in Rust. Should do it in a different way?
Context: we create a NameTempFile from Rust that we pass as argument to hg as profiling.output=named_temp_file. When open with 'w', the mercurial command fails with "abort: Permission denied". As far as I read, it might be because of how the Win32 API works. Under the hood, Python's open function is calling the CreateFile function, and if that fails, it translates the Windows error code into a Python IOError. From CreateFile documentation:
If CREATE_ALWAYS and FILE_ATTRIBUTE_NORMAL are specified, CreateFile fails and sets the last error to ERROR_ACCESS_DENIED if the file exists and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_SYSTEM attribute. To avoid the error, specify the same attributes as the existing file.
I might be wrong though... any other suggestions?

Reviewed By: ikostia

Differential Revision: D8099420

fbshipit-source-id: c3077cc5d7bc03c8f2eeafdac3467db62c20a669
2018-06-07 07:50:38 -07:00
Phil Cohen
30fd816525 tests: disable test-subrepo-git.t pending a git issue
Summary:
See t30174052 -- new version of FB git seems to have trouble pushing to other dirs. Let's turn these tests off for now to resume the contbuild.

Disable test-hggit-branch-bookmark-suffix.t too.

Reviewed By: DurhamG

Differential Revision: D8306205

fbshipit-source-id: b8f10f0158e38608ed5b6a96bd8da52aa211f8d7
2018-06-06 15:43:25 -07:00
Jun Wu
5cf10d244c template: improve error handling when template function signature mismatch
Summary:
Template function requires input arguments. They do not always exist.
If any argument is missing, just return an empty value, instead of crash.

Reviewed By: mitrandir77

Differential Revision: D8221246

fbshipit-source-id: ff3839398bdc620bff61d1b19b1512010c06388e
2018-06-06 15:43:25 -07:00
Jun Wu
47b327c175 rebase: use command-level template (BC)
Summary:
Use the command-level template and the `nodechanges` template keyword.
Drop the use of formatter.

`-Tjson` is not treated specially so it will just print `json`. If we'd like
to make it output `{"nodehcnages": ...}` (probably not a list with one
element), it's doable by having some mapping from `json` to a default
template.

Reviewed By: mitrandir77

Differential Revision: D8221076

fbshipit-source-id: 75575a98324d0d069789e0e915d5aa282ca0d4bb
2018-06-06 15:43:25 -07:00
Jun Wu
caf2d3031d templatekw: implement nodechanges as a template keyword
Summary: Will be used by the next change.

Reviewed By: mitrandir77

Differential Revision: D8221077

fbshipit-source-id: c9713175dfaab0b090f81d2c9d4f4d9d63a0771c
2018-06-06 15:43:25 -07:00
Jun Wu
e8c21b7691 template: add a way to support command-level template cleanly
Summary:
There mercurial template language is a powerful language. But it has some
limitations right now:

- It's focused on "commit". If there is no commit, things become harder.
- The related formatter concept is coupled with "a list of things". If there
  is no list, things become impossible.
- Some commands use formatter/template partially, and that does not play
  very well with `ui.write`, and is difficult to document.

This patch starts to solve all the issues, by introducing command-level
template state, and with the vision:

- Anything could be used as an "environment" passed to the template
  language, a commit, a file, a line, a "command" with customized
  properties, etc.
  - If a template keyword function is incompatible with the environment, it
    should fail gracefully.
- The template language is a super set of other things. `-Tjson` should not
  be magical, but an alias of `{some complex expression | json}`.
  - Discourage the use of formatter.
- Template keywords can be registered and documented.

This would remove the limitations of the template language and unleash its
full potential.

Note there are still some cases where the formatter is desirable. For example,
`hg log` with a large revset should be able to stream its output. The command
template feature added right now only renders things at the end of a command,
and is not (and requires significant effort to be) streaming-friendly.

Reviewed By: mitrandir77

Differential Revision: D8221078

fbshipit-source-id: 26fed50025c4676af277686382ce2d36f1faed97
2018-06-06 15:43:25 -07:00
Jun Wu
1499191e20 template: add a utility function to render template
Summary:
The added method takes an environment (`props`), and a program written in
the template language, execute the program, and pass output to `ui.write`.

The API is similar to the upstream [1]. But it avoids `ctx` intentionally.
Since the "environment" should be more flexible than having to have a `ctx`.

[1]: aa32940279

Reviewed By: mitrandir77

Differential Revision: D8221079

fbshipit-source-id: 94ee5c563f943330ef91966a4883c5733cc8dac9
2018-06-06 15:43:25 -07:00
Saurabh Singh
bdbcbf962b remove templates for svnpath and svnuuid
Summary:
According to scuba chart https://fburl.com/scuba/mn5nfdna, these are
not used by any critical client, don't seem useful and can be removed.

Reviewed By: quark-zju

Differential Revision: D8232616

fbshipit-source-id: ae07cfb00bfe45cd6f8c31f3fa0871c9ba1fdadf
2018-06-06 15:07:25 -07:00
Jun Wu
c5b267584b treestate: migrate to rand 0.5 to fix cargo test without breaking buck
Summary:
The pull request [1] is still open, which means `quickcheck::rand` is still
private when building with `cargo`. It only works with a patched quickcheck.
We cannot revert D8234503 since that will break buck build. So there is no
choice but upgrade to rand 0.5.

[1]: https://github.com/BurntSushi/quickcheck/pull/204

Reviewed By: DurhamG

Differential Revision: D8297404

fbshipit-source-id: 19937c49ae96a39e326b1b54eb00e6e2944193c2
2018-06-06 12:54:37 -07:00
Jun Wu
c0ae67d984 treestate: implement treestate.py:treestatemap
Summary: Implement most methods, similar to treedirstatemap.

Reviewed By: markbt

Differential Revision: D7909176

fbshipit-source-id: d20e4642ee381cc1cfe7c774071c8c3c1e493f45
2018-06-06 12:22:16 -07:00
Jun Wu
2073e88f0c treestate: initial Python dirstatemap class
Summary:
Add a class with methods defined in `dirstate.dirstatemap` so it could be
used as a drop-in replacement. The actual logic is not implemented yet.

Reviewed By: markbt

Differential Revision: D7909170

fbshipit-source-id: 5c1ae1bf4341d6368f5c9824487e7702f93043a7
2018-06-06 12:22:16 -07:00
Phil Cohen
b54cbaa464 commitcloudsubscriber: use old import syntax
Summary: The Ubuntu and Windows builders have an older rustc that doesn't support this syntax.

Reviewed By: DurhamG

Differential Revision: D8301570

fbshipit-source-id: 56990a804053a4dc78e41789c7b577bcf82868d7
2018-06-06 12:06:18 -07:00
Lukasz Langa
408782f48a Update to 18.6b1
Summary:
Better handling of parentheses.

ignore-unit-failures

Reviewed By: carljm

Differential Revision: D8294476

fbshipit-source-id: d0bdfd14d1b39cf19ac8a8a3c6d74c9f4fea8b13
2018-06-05 22:19:55 -07:00
Jun Wu
5d9fba271f chg: restart server automatically if handshake takes too long
Summary:
Usually the handshake process is pretty quick (<0.01 seconds):

  chg: debug: 0.000148 try connect to ...
  chg: debug: 0.000338 connected to server
  chg: debug: 0.000359 initialize context buffer with size 4096
  chg: debug: 0.008225 hello received: ...
  chg: debug: 0.008269 capflags=0x7b03, pid=31941
  chg: debug: 0.008282 request setprocname, block size 17
  chg: debug: 0.008316 request attachio
  chg: debug: 0.008978 response read from channel r, size 4
  chg: debug: 0.009045 request chdir, block size 45
  chg: debug: 0.009092 version matched (6119653365548183087)

However, we have seen some OSX cases where the handshake and basically
everything takes much longer:

  chg: debug: 0.000139 try connect to ...
  chg: debug: 0.000297 connected to server
  chg: debug: 0.000321 initialize context buffer with size 4096
  chg: debug: 0.192316 hello received: ...
  chg: debug: 0.192362 capflags=0x7b03, pid=55634
  chg: debug: 0.192373 request setprocname, block size 17
  chg: debug: 0.192420 request attachio
  chg: debug: 0.229009 response read from channel r, size 4
  chg: debug: 0.229072 request chdir, block size 34
  chg: debug: 0.229111 version matched (6119653365548183087)

(See P59677258 for the full paste)

If restart the chg server, the problem goes away and commands will be fast
again.

Unfortunately I'm not sure about the root cause of the problem. Maybe it's
Python's GC doing something very expensive? Maybe it's OSX thinking the server
process is "inactive" and put it to some state that's very slow to recover? Or maybe
it's some weird 3rdparty service?

For now, what we do know are:
- The slowness *sometimes* reproduces with chg.
- The slowness goes away if chg server is restarted.

As a last resort, detect the slowness by measuring the handshake time, then
restart the server accordingly. To avoid an infinite restart loop on slow machines,
the restart can only happen once.

The threshold is set to 0.05 seconds, which is roughly 5x the normal value, and
can be disabled by `CHGSTARTTIMECHECK=0`.

Reviewed By: phillco

Differential Revision: D8294468

fbshipit-source-id: 75246ea4d872045664e7feadb0acc47dfa1d8eae
2018-06-05 22:02:50 -07:00
Jun Wu
6445ad552d hgrc: only enable remotenames.fastheaddiscovery for clients
Summary:
It could affect pushrebase behavior - pushrebase server might have a large
set of "missing" nodes, and take that as the commits to rebase. Then fail
with "cannot rebase public commits".

Maybe there is a better way to fix it so it only affects pull but not push.
But for now it seems safer to disable it for automation.

Reviewed By: DurhamG

Differential Revision: D8049229

fbshipit-source-id: 3612e2fb2c1c825e8974156c27b03966ee745c98
2018-06-05 22:02:49 -07:00
Wez Furlong
31bcfbe58e hg: disable check-code tests for C code
Summary:
They're actively fighting against the clang-format config
and don't have an auto-fix.

Reviewed By: quark-zju

Differential Revision: D8283622

fbshipit-source-id: 2de45f50e6370a5ed14915c6ff23dc843ff14e8a
2018-06-05 19:21:43 -07:00
Durham Goode
d36c6ea530 pushrebase: fix bundle pack file ordering
Summary:
Previously, when adding temporary pack files to the local data store,
we added them at the end. This causes problems with the recently added ondemand
generating datastores, since when we go down the line of stores we will hit the
generating store (which will create a tree from flat manifest, which is slow)
before we hit the bundle store that actually contains the data.

Let's reorder the stores so the bundle stores go at the front, since they are
likely to be used.

Reviewed By: phillco

Differential Revision: D8291415

fbshipit-source-id: 4f9799cf755b2b1f7fe8d8d1c041a3b3f2c7e463
2018-06-05 17:55:28 -07:00
Durham Goode
c244d056b9 treemanifest: auto-format code
Summary: This fixes various clang formatter lint warnings.

Reviewed By: phillco, singhsrb

Differential Revision: D8283573

fbshipit-source-id: c466ccaf8d5e50a7421fd34e43cf49559431d416
2018-06-05 16:40:44 -07:00
Durham Goode
d34a99a394 commitcloud: avoid using nested includes
Summary:
The windows and ubuntu builds don't have a version of rust that
supports these features, so this breaks the build.

Reviewed By: phillco, quark-zju, singhsrb

Differential Revision: D8289651

fbshipit-source-id: d08b141b4d9996e3b899ac0604225ad34f863990
2018-06-05 16:06:56 -07:00
Durham Goode
6bad025052 treemanifest: fix build warning about shadowed variables
Summary:
Optimized builds were giving a warning about shadowed variables, which
broke some of our continuous builds. Let's fix those.

Reviewed By: phillco

Differential Revision: D8287865

fbshipit-source-id: 8a2d023be93499ed6458a35ba8e8cb4d83d59e4a
2018-06-05 14:35:59 -07:00
Wez Furlong
a09e44a469 pass down CHG path from above
Summary:
I've been troubleshooting eden integration test failures on my
devserver and traced it to some slightly off behavior in the telemetry
wrapper.

The wrapper was setting `CHGHG` to `hg.real` rather than the computed
path to the `hg.real` executable.  In the eden integration tests this
path is the buck generated `hg.par`.  The problem this caused was running
the installed hg.real rather than the one from the test environment
and this caused resolution of the eden extension to fail.

Once I fixed that up I found that chg had detected a problem with the
paths to the hg executable that were being used; we were picking up `chg`
from the system path and had a similar issue to above.

I introduced an environmental variable `CHG_BIN` to hold the desired path
and set it to the buck built `chg` binary.

In the process of this I found that `chg` was triggering a UBSAN issue
by passing a nullptr as the second argument to `memcpy`.  I've included
the trivial fix for that in this diff also.

Reviewed By: quark-zju

Differential Revision: D8274636

fbshipit-source-id: 7ee0740cbfb447ab41b9e08308767d42790ba296
2018-06-05 13:54:26 -07:00
Phil Cohen
3d72ef23a5 log a reason for every watchman state invalidation
Summary:
We want to better understand why people are getting "scanning working copy", so this is a first step towards that -- log every time we call `invalidate()` with the reason.

If one reason ends up dominating the others (e.g., "exception") we can drill down later.

Reviewed By: quark-zju

Differential Revision: D8272450

fbshipit-source-id: 46cb963eefa5ca60df81bdcd8f1e232855c106b7
2018-06-05 12:46:27 -07:00
Durham Goode
88c0f8e820 treemanifest: support subdir requests in gettreepack
Summary:
Previously, if a client sent a gettreepack request and specified a
non-root directory, the server would go back to the root of the tree and send
the whole tree. Now that treemanifest has a walksubdirtrees function for
iterating over a specific subset of a tree, we can make it return just the
subset.

This diff does delete the treememoizer class. This was previously used to keep
trees in memory if they would be needed again (for instance, as a base node for
a future tree). We aren't able to provide this functionality when using
walksubdirtrees, because python doesn't have access to the underlying sub
directory tree objects. This class was probably unnecessary anyway, since we
usually only request a small number of trees at once.

Reviewed By: quark-zju

Differential Revision: D8217360

fbshipit-source-id: 1db970659eabe2829acc6d49a15eeb9345ce4a5b
2018-06-05 11:45:25 -07:00
Durham Goode
dee59f7ffc treemanifest: add a subdir tree walking api
Summary:
In a future diff we'll be adding the ability to request just a
subsection of a tree. In order to do that, we need to expose an api that can
iterate of just a subsection of the tree.

Since the treemanifest object itself acts mostly like a dictionary, and doesn't
expose sub-tree functionality, we expose sub-tree walks as a limited use class
level function.

Reviewed By: quark-zju

Differential Revision: D8216726

fbshipit-source-id: 0d72ef041fd6a973387f975b21e55c82f7ec789c
2018-06-05 11:45:25 -07:00
Saurabh Singh
5427b362d1 fix method naming
Summary:
A recent change renamed the methods assuming they were rust methods
but these methods are used in the python code and therefore, already had the
correct naming. This broke the one of the python tests calling the methods
which will pass now.

Reviewed By: DurhamG, quark-zju

Differential Revision: D8279742

fbshipit-source-id: 01761ad033c6669a0ae54dc1beb853a0d56df27d
2018-06-05 09:08:21 -07:00
Liubov Dmitrieva
c80a2aafcb scm daemon: refactoring (remove unused crates)
Summary: just refactoring to improve the code quality

Reviewed By: markbt

Differential Revision: D8276584

fbshipit-source-id: bf0317e91f96d2f7fee24ea69c0f33a0aed54a98
2018-06-05 07:11:55 -07:00
Liubov Dmitrieva
ae7ece9cd5 scm daemon: refactoring
Summary:
just refactoring to improve the code quality

the main improvement is that I separated TcpReceiver to a different service,
any other services can register callbacks with TcpReceiver service.

For WorkspaceSubscriberService callbacks are implemented using mpsc channel to notify the main WorkspaceSubscriberService thread and single atomic flag that allows running subscriptions to join.

Another improvement is that I added logic to run cloud sync on the first keep alive after connection errors

Reviewed By: markbt

Differential Revision: D8226109

fbshipit-source-id: 3fe513da9273b28b2262948ecdf620821e7ab313
2018-06-05 07:11:55 -07:00
Liubov Dmitrieva
80f63e9451 scm daemon: refactoring (improve messages correctness)
Summary: just refactoring to improve the code quality

Reviewed By: markbt

Differential Revision: D8276563

fbshipit-source-id: afca70b9b487450fbaab897dff5cd79d6c3a0108
2018-06-05 04:36:07 -07:00
Mark Thomas
3bf1e7d0b3 infinitepushbackup: back up commits stack-by-stack
Summary:
Use the new stack-by-stack commit backup for infinitepushbackup as well as
commitcloud.

Reviewed By: DurhamG

Differential Revision: D8241380

fbshipit-source-id: 0c1481ad1ab5759ab642d0b02c7fe08523056292
2018-06-05 04:36:07 -07:00
Mark Thomas
0dae30bde0 infinitepushbackup: remove savelatestbackupinfo
Reviewed By: DurhamG

Differential Revision: D8241384

fbshipit-source-id: 1db1606f50ad0991518a263d9aa7a61561bd8cd7
2018-06-05 04:36:07 -07:00
Mark Thomas
84b7a0a84f commitcloud: push commits stack-by-stack
Summary:
Rather than pushing a bundle containing all unpushed draft commits, instead
push stack by stack.  This reduces the individual bundle size, and means
failure to push some commits means we can still make progress.

Reviewed By: DurhamG

Differential Revision: D8241383

fbshipit-source-id: 6f1528613fa228627fe156a8e4720dd46929ebe2
2018-06-05 04:36:07 -07:00
Mark Thomas
eabd9c0d16 commitcloud: use repo connectionpool
Summary:
Use the repo connectionpool to connect to the server.  This allows sensible
re-use of connections whilst gracefully handling errors.

Reviewed By: DurhamG

Differential Revision: D8241382

fbshipit-source-id: f43669a32e4b1ff57193ea0959c57ff14526a998
2018-06-05 04:36:07 -07:00
Mark Thomas
6c0784b884 commitcloud: split pushing of commits and infinitepushbookmarks
Summary:
Split the pushing of commitcloud commits and infinitepush bookmarks into
separate functions, in preparation for pushing commits stack-by-stack.

Reviewed By: DurhamG

Differential Revision: D8241385

fbshipit-source-id: dc82c3470259b0ff738ebcdf6901ee8052405379
2018-06-05 04:36:06 -07:00
Mark Thomas
1a7b16bacb infinitepush: refactor pushing draft heads into infinitepush
Summary:
Refactor pushing of draft heads into infinitepush; we want to call this from
infinitepushbackup, too.

Reviewed By: DurhamG

Differential Revision: D8241381

fbshipit-source-id: d5eb06efd6cd9382e016b0738d9b3e89e524de53
2018-06-05 04:36:06 -07:00
Mark Thomas
140361f6ff infinitepush: remove cleanup in pushbackupbundle
Summary:
Remove the cleanup from pushbackupbundle.  As we now wait for the bundle
response, this is no longer necessary, and it prevents re-use of the
connection.

Reviewed By: DurhamG

Differential Revision: D8241379

fbshipit-source-id: a885198c49dce1beb1385a61a209d299ed3d2d02
2018-06-05 04:36:06 -07:00
Mark Thomas
5180dd5cf2 infinitepush: split backups into infinitepushbackup extension
Summary:
Split the infinitepush backups code into a separate module.

The infinitepush extension is responsible for providing scratch pushes, as well
as the server-side implementation for storing scratch bundles.

The infinitepushbackup extension uses this feature to provide automatic backup
support.  It is an alternative to the commitcloud extension, and the two will
be mutually exclusive.

Reviewed By: DurhamG

Differential Revision: D8204418

fbshipit-source-id: 9279c426da35d451a5e7b39a72f2c91d364e3fd4
2018-06-05 04:36:06 -07:00
Mark Thomas
abdd30febd connectionpool: add configurable reuse lifetime for connections
Summary:
Re-using long-running connections can cause problems, as the `hg serve` process
on the server may be using large amounts of resources.  Add a new configuration
option `connectionpool.lifetime`.  Connections that are older than that time
will be closed and not re-used.

Reviewed By: DurhamG

Differential Revision: D8204415

fbshipit-source-id: ac937778e3dc79e77e367017db2141066bd17263
2018-06-05 04:36:06 -07:00
Liubov Dmitrieva
c7b0012cfe build: build rust binaries
Summary:
build rust binaries as part of mercurial build

by default they appear together with hg and chg in the folder called scripts but it can be configured.

Reviewed By: quark-zju

Differential Revision: D8270436

fbshipit-source-id: df928b89e6530c285c3eab438769c53f545d4098
2018-06-05 03:53:25 -07:00
Jun Wu
c65612acc9 indexedlog: index: stop iteration if an error is encountered
Summary:
Without this change, code doing `index.get(...).values().collect()` might
end up with an infinite loop.

Reviewed By: DurhamG

Differential Revision: D8156510

fbshipit-source-id: 5497aa354de7d49cfc4308a025856608ce981a1e
2018-06-05 00:12:29 -07:00
Jun Wu
798e55d53d indexedlog: index: change APIs to take file lengths instead of root offsets
Summary:
Previously, the index API optionally takes a root offset. This is
inconvenient for the caller since they probably need to record both
valid file length and root offsets. Since root nodes are always at
the end of the index. Let's just simplify the API to take a logical
file length instead of a root offset.

Reviewed By: DurhamG

Differential Revision: D8156512

fbshipit-source-id: 7029272a61c9990e6484bca7ebbff64e2233c6cd
2018-06-05 00:12:29 -07:00
Jun Wu
68660cc443 indexedlog: utils: make mmap_readonly optionally take file length
Summary:
Previously, `mmap_readonly` always reads file length, and uses that for mmap
length. In many cases we do know the desired file length and it's cleaner to
not `mmap` unused bytes. So let's add a parameter to do that.

Note: The `stat` call is still needed. Since `mmap` wouldn't return an error
of the requested length is greater than the file length.

Reviewed By: DurhamG

Differential Revision: D8156523

fbshipit-source-id: 991aa28f3542eaff24387dcc6a7302122fb6962f
2018-06-05 00:12:29 -07:00
Jun Wu
c43312ad9c indexedlog: utils: move xxhash to utils
Summary: The function will be reused in another module.

Reviewed By: DurhamG

Differential Revision: D8156522

fbshipit-source-id: 2aff6f2e4b8fc9b5d2c000e12ac2d940f7fab407
2018-06-05 00:12:29 -07:00