Commit Graph

43075 Commits

Author SHA1 Message Date
Saurabh Singh
51aa41fa78 run-tests: fix the tests when run with '--shell bash' configuration
Summary:
`run-tests.py` has an option to specify the shell for running the
tests. However, when run with the `--shell bash` configuration, several tests
fail with the `testrepohg: command not found` error. I could not find the
specific cause for this but changing the alias to a function resolved this
error. Also, fixed another related error by using double quotes during variable
expansion.

Reviewed By: quark-zju

Differential Revision: D7563731

fbshipit-source-id: 58e1b5b996ccdc20b8375dcd5f4f8e071bd9cdc1
2018-04-13 21:51:50 -07:00
Jun Wu
b43606ee98 ignore: add a way to disable hgignore
Summary:
This allows us to turn on and off hgignore support directly without changing
files in the working copy (which could be hard to revert cleanly).

Reviewed By: mjpieters

Differential Revision: D7544529

fbshipit-source-id: 14cc41e2ae361070f91bf3b8aa28dd5808e7fe99
2018-04-13 21:51:49 -07:00
Kaley Huang
9d4c4d34e7 seqimport-test: make src a glob expression instead of "p4"
Summary: When I run this test (test-fb-hgext-p4fastimport-seqimport.t) on my dev server, which has the same `p4d` as what we have in prod (P59384966), it fails the test due to reading the file from a different source P59381563. Since both `p4` and `rcs` are valid options for a read, this diff updates the test to not restrict to `p4` only.

Differential Revision: D7556357

fbshipit-source-id: b82d254841a31fe447452ee408bdb8e157854aab
2018-04-13 21:51:49 -07:00
Mateusz Kwapich
0865966eb6 use masterrev even if revset is specified
Summary:
sl assumed that the masterrev is missing from revset if any revset was
specified so it was failing back to current commit. This fixes this
behaviour by checking if masterrev is available.

Differential Revision: D7535692

fbshipit-source-id: 033088149b52293dce219b1dc7a04186bfc461b9
2018-04-13 21:51:49 -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
Stanislau Hlebik
2355414e71 mercurial: improve graft error message
Summary:
Previously `hg graft -r 'ancestor::descendant` printed no error message at all.
This diff fixes it.

Reviewed By: mjpieters

Differential Revision: D7533498

fbshipit-source-id: 5c4e41ecc3178495ad2f41ef53ef65f7fbb70212
2018-04-13 21:51:49 -07:00
Jun Wu
18c17ec9f1 tweakdefaults: use hint framework for prev
Summary:
A side effect is, the hint won't be printed out if fbamend is not enabled,
which is more "correct".

Reviewed By: markbt

Differential Revision: D7392130

fbshipit-source-id: 5b7aa4cc3083b03546c54965ce51040fab958b87
2018-04-13 21:51:49 -07:00
Jun Wu
213feff513 amend: use hint framework for auto rebase
Reviewed By: markbt

Differential Revision: D7392128

fbshipit-source-id: b502ac1d7595bd072b6bd4e96de69cde6cca1878
2018-04-13 21:51:49 -07:00
Jun Wu
238cda6c14 amend: use hint framework for restack
Summary: This allows people to silence the hint.

Reviewed By: markbt

Differential Revision: D7392127

fbshipit-source-id: ac16f952a178d567ce13e22946127456972ebe85
2018-04-13 21:51:49 -07:00
Jun Wu
10bf57de39 prune: use hint framework
Summary:
This allows users to silence the "hide" advice.

In the future, we might want to change "hide/unhide" to only affect visibility
without changing obsolesce. So "strip" is not fully deprecated yet.

Reviewed By: markbt

Differential Revision: D7392131

fbshipit-source-id: 2448d4c91dffce31d29e2dd99078cb555c9a8f8c
2018-04-13 21:51:49 -07:00
Jun Wu
0252fce55c hint: add a command to silence hints
Summary:
This allows people to silence hints as they like. It's done by modifying
user hgrc.

Reviewed By: markbt

Differential Revision: D7392133

fbshipit-source-id: 1365294217db92dfb3a0c81332a9fefd164795d4
2018-04-13 21:51:49 -07:00
Jun Wu
247f398309 rcutil: add a way to edit config files in-place
Summary: This allows us to change configs using code.

Reviewed By: mjpieters

Differential Revision: D7392129

fbshipit-source-id: 0960d4a322d6906469a79976031ab2b619dfa183
2018-04-13 21:51:49 -07:00
Jun Wu
14783221f6 hint: add a simple framework for registering hint messages
Summary:
This allows us to have a unified way to print hint messages at the end of a
command. It would be helpful for feature discovery in general.

Reviewed By: mjpieters

Differential Revision: D7392132

fbshipit-source-id: 8b4e94cc2176266652459ecca3428bd86d95bfe2
2018-04-13 21:51:48 -07:00
Jun Wu
bdbf60f28d xdiff: backport upstream changes
Summary:
I did some extra xdiff changes in upstream, namely:

  - Remove unused features
  - Replace "long" (32-bit in MSVC) with int64_t to support large files
  - Add comment on some key variables

This backports them. It also includes Matt's fixes about Windows compatibility.

Reviewed By: ryanmce

Differential Revision: D7223939

fbshipit-source-id: 9287d5be22dae4ab41b05b3a4c160d836b5714a6
2018-04-13 21:51:48 -07:00
Jun Wu
3ffa0f28e2 gitignore: avoid quadratic behavior
Summary:
The correct gitignore matcher needs O(N^2) time to check a path which is N
directory deep. For example, to check "a/b/c/d", it needs to check:

  - Whether .gitignore matches a/b/c/d
  - Whether a/.gitignore matches b/c/d
  - Whether a/b/.gitignore matches c/d
  - Whether a/b/c/.gitignore matches d

  - Whether .gitignore matches a/b/c
  - Whether a/.gitignore matches b/c
  - Whether a/b/.gitignore matches c

  - Whether .gitignore matches a/b
  - Whether a/.gitignore matches b

  - Whether .gitignore matches a

It might not look that bad because N=4 for the above example. But when N is
larger (ex. node_modules/../node_modules/../node_modules/..), things get much
worse.

This patch adds "caching" about whether a directory is ignored or not. For
example, if "a/b/" is ignored, the new code would skip checking subdirectories
(ex. "a/b/c/"). The time complexity is now roughly O(N) gitignore tests instead
of O(N^2), since we only did a gitignore check for a parent directory of a path
being tested once, and then cache the parent directory result in a boolean
value.

To be clear, for the first time checking a path which is not ignored, it still
needs O(N^2) for initializing the trees. But once it's initialized, the next
time checking a file in a same directory, will be O(N).

`LruCache` is replaced by `HashMap` since it does not support `.get` and the
code needs that to work.

The perf issue was previously documented as a "PERF" comment.
This diff removes it.

Reviewed By: DurhamG

Differential Revision: D7496058

fbshipit-source-id: f10895b8f0d7dcdde6faf9daeec5cd78a1f15a2b
2018-04-13 21:51:48 -07:00
Durham Goode
cf6bb5a80a hg: speed up hgsubversion imports
Summary:
Previously every time a directory was deleted in subversion it would
call delete_entry which contained a ctx.walk() that would iterate over the
entire manifest. When many directories were deleted, this was
O(directories_deleted * size_of_repo) and very slow.

The new algorithm uses bisect to avoid iterating over the entire manifest.

Reviewed By: quark-zju

Differential Revision: D7529670

fbshipit-source-id: 763c1ad5ad46929d878848d150542f255ad96dd4
2018-04-13 21:51:48 -07:00
Phil Cohen
1fed73ea7e rebase: fix IMM restarting with uncommited changes
Summary:
We bailifchanged() later on, but the abort does an `up -C originalwc` before that. Let's bailifchanged() immediately.

A better version: reset the transaction and clear the statefile, instead of calling `abort()`.

Reviewed By: quark-zju

Differential Revision: D7538017

fbshipit-source-id: 8c490b366e495bb269c4d8c75b6144c535c8d54f
2018-04-13 21:51:48 -07:00
Adam Simpkins
a6782ea273 minor improvements to hg journal output
Summary:
Minor fixes to how the `previous locations of %s` line is printed:
- Start the pager before printing this line, so it gets included in the pager
  output correctly.
- Avoid printing this line when using a custom output template.  Previously it
  was only skipped when using the `json` template.  This now matches the logic
  used to skip the `no recorded locations` line that was recommended in
  D7512030.

Reviewed By: ryanmce

Differential Revision: D7537661

fbshipit-source-id: eb695dd98c06149701cf96acf5ec2eb277ea9cf3
2018-04-13 21:51:48 -07:00
Jun Wu
b0b9ac188f chg: work with illformed envp
Summary:
By using low-level APIs, `environ` could contain ill-formed entries that do
not have the `NAME=VAL` form:

  #define _GNU_SOURCE
  #include <unistd.h>
  char *envp[] = { "X", 0 };
  char *argv[] = { "hg", "log", 0 };
  int main() {
      return execvpe("chg", argv, envp);
  }

Ignore them silently so they won't break chg.

Reviewed By: DurhamG

Differential Revision: D7537406

fbshipit-source-id: 3fef3d656383723d451fbfa29ba9a9fa170311d0
2018-04-13 21:51:48 -07:00
Adam Simpkins
39cd1c0389 fix hg journal to avoid printing non-JSON data with -Tjson
Summary:
Avoid printing "no recorded locations" directly to stdout when a format
template was specified.  In particular this avoids printing non-JSON data
when using `-Tjson`.

We potentially could change this to print to stderr instead.  However for now
I just followed the same pattern of checking the template as was done above for
the "previous locations" message.

Reviewed By: ryanmce

Differential Revision: D7512030

fbshipit-source-id: 2c32f07962fac4ca3d6bfd8f2ca3c4840b2a8a9b
2018-04-13 21:51:48 -07:00
Kostia Balytskyi
4a9c3c59c0 hg: support linking against external libs in setup.py
Summary:
On Windows, the `mman` and `dirent` functionality can be provided by external
libs, which we would not like to mention in the `setup.py`. This change allows
us to to call `setup.py` with the right env and link with the right libs, same
approach as with headers.

Reviewed By: quark-zju

Differential Revision: D7535358

fbshipit-source-id: d0364cb305a9114260106844f9a3575a731419e9
2018-04-13 21:51:48 -07:00
Kostia Balytskyi
14bc2a155c hg: merge common_include_dirs and include_dirs in setyp.py
Summary: We don't really need this separation.

Reviewed By: quark-zju

Differential Revision: D7535364

fbshipit-source-id: a480ddb62883e2e9044e06ff7b27201151632b71
2018-04-13 21:51:48 -07:00
Liubov Dmitrieva
d27069f7cd infinitepush: replace separate single-row DELETE statements with a single DELETE
Summary:
Run single DELETE query instead of using separate single DELETE statements because it is much faster and the common way in mysql world.

One query is better because:

* Only one plan will need to be generated
* Only one transaction will be involved
* Less overhead with ODBC calls and network traffic
*  Any indexes will need to be refreshed just once, not many times.

Reviewed By: StanislavGlebik

Differential Revision: D7526427

fbshipit-source-id: 39f1d4605adb26d8690a9b39e783c792dee6ad87
2018-04-13 21:51:48 -07:00
Liubov Dmitrieva
82169bcf89 reduce number of mysql queries
Summary:
Reduce number of queries for infinitepush

Use bulk INSERT instead of using separate single-row INSERT statements, that is many many times faster.

('executemany' builds a single query for us)
(out max_allowed_packet is about 134M)

One query is better than 'for loop' because:
* Only one plan will need to be generated
* Only one transaction will be involved
* Less overhead with ODBC calls and network traffic
* Any indexes will need to be refreshed just once, not many times.

Reviewed By: StanislavGlebik

Differential Revision: D7504452

fbshipit-source-id: 9b0beb1ff572bf6c7b28892878d91e0cf4897e1f
2018-04-13 21:51:48 -07:00
Mark Thomas
9cc2b1cc64 phabstatus: fix long line
Summary: Fix long line which breaks `test-check-code.t`.

Reviewed By: farnz

Differential Revision: D7532586

fbshipit-source-id: e5add9c9407b34bb3bd4cd701ba491e0e0ce1079
2018-04-13 21:51:48 -07:00
Liubov Dmitrieva
5db9e2748e improve handling 401
Summary:
improve handling http 401 (unauthorized)
happen if token is invalid

Reviewed By: DurhamG, StanislavGlebik

Differential Revision: D7502317

fbshipit-source-id: abc9fdbc6dfad393f2ddf050b686cb6cfce259b6
2018-04-13 21:51:47 -07:00
Liubov Dmitrieva
7e39e14368 fix phabstatus for commit cloud
Summary:
fix `hg ssl` for Commit Cloud

In Commit Cloud world, obstore can sometimes have more knowledge than the unfiltered repo.
For example, in case of many amends on one client, some stuff can not be backed up
and not fetched to another client.
But we don't need to have all obsoleted versions in both repos,
obstore helps us to provide enough information to a user of what has happened
but we need to be carefull with operator []

Reviewed By: DurhamG

Differential Revision: D7516465

fbshipit-source-id: 7e109741829b26c30f20a7528b21b5ebc9b31dde
2018-04-13 21:51:47 -07:00
Kostia Balytskyi
e1f2cac08e hg: use Windows libraries in a way that preserves GetLastError
Summary:
Using windows libs like `_kernel32 = ctypes.windll.kernel32` means that
the `GetLastError` calls are useless.

(1317 is a non-existent process)
```
In [44]: k32 = ctypes.WinDLL('kernel32', use_last_error=True)

In [52]: ctypes.windll.kernel32.OpenProcess(0x0001, False, 1317)
Out[52]: 0

In [53]: ctypes.windll.kernel32.GetLastError()
Out[53]: 0

In [54]: k32.OpenProcess(0x0001, False, 1317)
Out[54]: 0

In [55]: k32.GetLastError()
Out[55]: 5
```

This behavior can explain why we can't auto-delete the stale lock file. See the `testpid` code:
```
def testpid(pid):
    '''return True if pid is still running or unable to
    determine, False otherwise'''
    h = _kernel32.OpenProcess(_PROCESS_QUERY_INFORMATION, False, pid)
    if h:
        try:
            status = _DWORD()
            if _kernel32.GetExitCodeProcess(h, ctypes.byref(status)):
                return status.value == _STILL_ACTIVE
        finally:
            _kernel32.CloseHandle(h)
    return _kernel32.GetLastError() != _ERROR_INVALID_PARAMETER
```

The non-existent `pid` causes `h` to be `0` and `_kernel.GetLastError()` to also be `0` (see above why). This means that we think that this process exists!

(Note: this ignores all push blocking failures!)

Reviewed By: quark-zju

Differential Revision: D7519457

fbshipit-source-id: c08f727228073962359e93db13f1fdb76f3699e6
2018-04-13 21:51:47 -07:00
Chad Austin
26464349a5 improve exception message when backupfiles format is invalid
Summary:
When a .backupfiles file is invalid, hg recover gives a not very
useful stack trace.  This makes it a bit easier to debug.

Reviewed By: DurhamG

Differential Revision: D7482578

fbshipit-source-id: e8c7ad73bb14a38d2d43b636d60a3b77cd947331
2018-04-13 21:51:47 -07:00
Martijn Pieters
964bbe67d5 simplecache: correct indentation error, causing an UnboundLocal exception
Summary: When no cache has been set (`simplecache.caches=`) then there's no `name` set either. This exposed a logic error in this section of the code.

Reviewed By: ryanmce

Differential Revision: D7513976

fbshipit-source-id: ecbc7a8ac8c6eb23010d64ab8cbf9f9fb7d8f497
2018-04-13 21:51:47 -07:00
Stanislau Hlebik
84724bbd11 infinitepush: handle reply:changegroup part
Summary:
Currently hg doesn't return anything from processing infinitepush parts.
However, mononoke will treat infinitepush parts just like normal hg parts.
So let's not panic if we see reply:changegroup part

Reviewed By: markbt

Differential Revision: D7513729

fbshipit-source-id: 8417a285bd49efadf2f2ef9ed80ad2f2b6d6bc94
2018-04-13 21:51:47 -07:00
Saurabh Singh
99bff7b6fe hgbuild: write deb packages to a consistent location
Summary:
Currently, the `build_deb.py` writes the packages to the directory
from which the script was invoked. This leads to issues in integrating with our
continuous build setup. Therefore, this commit changes the script to write to a
known location.

Reviewed By: quark-zju

Differential Revision: D7511832

fbshipit-source-id: 85beaf37e92418cae932fd81c72065cf5d64c249
2018-04-13 21:51:47 -07:00
Liubov Dmitrieva
efebe7a94b add move logic to update current rev to its new location (optional)
Summary:
move logic to update current rev to its new location (optional)
we are trying to update only if it is unambiguous

Reviewed By: DurhamG

Differential Revision: D7431940

fbshipit-source-id: 72e7fea7365a231c4d98ceb4cf4872a4db02d9ca
2018-04-13 21:51:47 -07:00
Liubov Dmitrieva
de0082660b commit cloud recover state
Summary:
[commitcloud] commit cloud recover state

`hg cloudrecover` command

It might be helpful to have a command like this in cases something goes wrong
with the local state

Reviewed By: DurhamG

Differential Revision: D7417147

fbshipit-source-id: 4b236f2753b1f212ff4881a649032e53e032c66c
2018-04-13 21:51:47 -07:00
Liubov Dmitrieva
06bd6c5c91 speed up commitcloud pull many times
Summary: [commitcloud] speed up commitcloud pull many times

Reviewed By: markbt

Differential Revision: D7444195

fbshipit-source-id: 869e31ea3e6b6141c83fc28a605b788d192649be
2018-04-13 21:51:47 -07:00
Liubov Dmitrieva
ad6ffda306 join to workspace
Summary: `hg cloudjoin` command

Reviewed By: DurhamG

Differential Revision: D7414658

fbshipit-source-id: b612885bf6226b164a7efd21d9f4166fbf7efd1d
2018-04-13 21:51:47 -07:00
Liubov Dmitrieva
e3276c7e7b introduced secure token injection
Summary:
new command `hg cloudregister`

storing user token

Reviewed By: DurhamG

Differential Revision: D7367301

fbshipit-source-id: e8eb3d51cf62e9c1e91c39be45e0ad8b49a74442
2018-04-13 21:51:47 -07:00
Mark Thomas
457c8ba50c infinitepush: handle remote aborts when pushing backup bundles
Summary:
When pushing a backup bundle to the server, check if the response contains an
error, and fail the backup accordingly.

Differential Revision: D7498324

fbshipit-source-id: a08807ac54e9d3044ff1450e93d2a8ea9d6f767f
2018-04-13 21:51:46 -07:00
Mark Thomas
bf2d6f85e3 infinitepush: make max bundle size configurable
Summary:
Add a server-side config option `infinitepush.maxbundlesize` to control the
maximum bundle size (currently 100MB).

Add a test that shows bad behaviour when pushing backups that exceed this size.

Differential Revision: D7498323

fbshipit-source-id: 640478e7a58cb3c39408fe2a24d8d581f14d891c
2018-04-13 21:51:46 -07:00
Jun Wu
ac52e4a6fb indexedlog: add a test against std hashmap for multi-values
Summary: Since we now have the ability to store multiple values. Add a test.

Reviewed By: DurhamG

Differential Revision: D7472880

fbshipit-source-id: 85b1c69245ac7f0c4702daf22a02f5e5072f0924
2018-04-13 21:51:46 -07:00
Jun Wu
de74642bc7 indexedlog: implement value iterator
Summary:
The value type is a linked list of u64 integers. Add an API to expose that.

Using iterator framework has benefits about flexibility - the caller can
take the first value, or convert it to a vector, or count the values, etc.
easily.

Reviewed By: DurhamG

Differential Revision: D7472881

fbshipit-source-id: d31e81770e069734b54fa08729c0cd45a699aae2
2018-04-13 21:51:46 -07:00
Jun Wu
cc4193ba29 indexedlog: handle radix null child correctly
Summary:
This is caught by a later test. Looking up a non-existed child (jumptable
value is 0) returns InvalidData error, while it should return Offset(0).

The added if condition does not seem to have noticeable performance impact:

  index insertion                 3.840 ms
  index flush                     3.740 ms
  index lookup (memory)           1.085 ms
  index lookup (disk, no verify)  1.972 ms
  index lookup (disk, verified)   7.752 ms

Reviewed By: DurhamG

Differential Revision: D7472882

fbshipit-source-id: 1cc51e9afa248e123cca9c561d7bb2128fd898b1
2018-04-13 21:51:46 -07:00
Jun Wu
b82b0daab5 indexedlog: make LinkOffset also return next link offset
Summary:
Previously, the code was focusing on getting the hardest (index) part right,
but less about the value part. There is no way to get all values in the
linked list, as designed, yet. This diff starts the work.

Similar to `KeyOffset::key_and_link_offset`, change the internal API of
LinkOffset to return both value and the next link offset.

Reviewed By: DurhamG

Differential Revision: D7472879

fbshipit-source-id: 4a4512d7c63abbb667146de582e0f8cd04c9c04a
2018-04-13 21:51:46 -07:00
Jun Wu
b9b1f1e907 indexedlog: use OpenOptions
Summary:
`Index::open` now takes too many parameters, which is not very convenient to
use. Inspired by `fs::OpenOptions`, use a dedicated strut for specifying
open options.

Motivation: To test checksum ability more confidently, I'd like to write
something that randomly mutates 1 byte from a sane index. To make sure the
checksum coverage is "correct", checksum chunk size is another parameter.

Reviewed By: DurhamG

Differential Revision: D7464182

fbshipit-source-id: 469ce7d1cfa5de3946028418567a9f3e2bc303fa
2018-04-13 21:51:46 -07:00
Jun Wu
6cb2b1dd23 indexedlog: make OffsetMap::get have no assumption about offset
Summary:
Address DurhamG's review comment on D7422832.

Previously, `OffsetMap::get` expects a dirty offset. That's because it was
changed from `HashMap` and we don't control `HashMap::get`. It's cleaner to
let `OffsetMap` do the `is_dirty` check.

Reviewed By: DurhamG

Differential Revision: D7461707

fbshipit-source-id: 9f2abdf6c6f993d98d9443f16bafcc6154ee0dbb
2018-04-13 21:51:46 -07:00
Jun Wu
9787cfc15b indexedlog: add more tests about leaf split
Summary:
The new test covers the `else` branch inside `LeafOffset::set_link`
previously not covered.

Coverage was checked by the following script:

```
from __future__ import absolute_import

import glob
import os
import shutil

os.system('cargo rustc --lib --profile test -- -Ccodegen-units=1 -Clink-dead-code -Zno-landing-pads')
path = max((os.stat(path).st_mtime, path) for path in glob.glob('./target/debug/*-????????????????'))[1]
shutil.rmtree('target/kcov')
os.system('kcov --include-path $PWD/src --verify target/kcov %s' % path)
```

Reviewed By: DurhamG

Differential Revision: D7446902

fbshipit-source-id: 293da2ff53b83c8f11534f0f8e5e7fd102216a01
2018-04-13 21:51:46 -07:00
Jun Wu
5209e8360b indexedlog: support external keys
Summary:
Change `insert_advanced` to accept an enum that could be either a key, or an
(offset, len) that refers to the external key buffer.

Insertion becomes slower due to new flexibility overhead.  For some reason,
"index lookup (no verify)" becomes faster (restores pre-D7440248 performance):

  index insertion                 6.434 ms
  index flush                     3.757 ms
  index lookup (memory)           1.068 ms
  index lookup (disk, no verify)  1.969 ms
  index lookup (disk, verified)   7.805 ms

With 2M 20-byte keys, the non-external key version generates a 105MB index:

  seconds operation
  1.247   insert
  0.622   flush
  1.859   flush done
  0.702   lookup (without checksum)
  1.395   lookup (with checksum)

Using external keys,the index is 70MB, and time for each operation:

  seconds operation
  1.086   insert
  0.702   flush
  0.665   lookup (without checksums)
  1.602   lookup (with checksums)

The external key will have more space wins for longer keys, ex. file path.

`Index` module was made public so `InsertKey` type is usable.

Reviewed By: DurhamG

Differential Revision: D7444907

fbshipit-source-id: b89d95246845799c2c55fb73ad203a7e6724b85e
2018-04-13 21:51:46 -07:00
Jun Wu
36dfda984c indexedlog: relax leaf entry's key offset type
Summary:
Previously, a leaf entry can only have a `KeyOffset`. This diff makes it
possible to be either `KeyOffset`, or `ExtKeyOffset`. The API didn't change
much since `LeafOffset::key_and_link_offset` handles the difference
transparently.

Latest benchmark result:

  index insertion                 4.879 ms
  index flush                     3.620 ms
  index lookup (memory)           1.827 ms
  index lookup (disk, no verify)  3.508 ms
  index lookup (disk, verified)   7.861 ms

Reviewed By: DurhamG

Differential Revision: D7444909

fbshipit-source-id: 5441e1ae187d42931377d7213dcb77156b2af714
2018-04-13 21:51:46 -07:00
Jun Wu
44a0998bc6 indexedlog: let leaf entry return key content
Summary:
The leaf entry has a `key_and_link_offset` method. Previously it returns a
`KeyOffset`, since we now have `ExtKeyOffset`, it's friendly to handle the
key entry type difference at the leaf entry level, instead of requiring the
caller to handle it.

Reviewed By: DurhamG

Differential Revision: D7444905

fbshipit-source-id: 56d87641a2a5a50ddca8b1e4c74c9aaa3891b542
2018-04-13 21:51:46 -07:00
Jun Wu
1294c1b471 indexedlog: add an "external key" entry type
Summary:
Previously, I thought there is only one index that will use "commit hash" as
keys, that is the nodemap, and other indexes (like childmap) would just use
shorter integer keys (ex. revision number, or offsets). So the space overhead
of storing full keys only applies to one index and seems acceptable.

But that implies strict topo order for the source of truth data (ex. to use
integers as keys in childmap, you have to know how to translate parent
revisions from hashes to integers at the time writing the revision).

Thinking about it again, it seems the topo-order requirement would make a lot
of things less flexible. It's much easier to just use hashes as keys in the
index. Then it's worthwhile to address the space efficiency problem by
introducing an "external key buffer" concept. That's actually what `radixbuf`
does.

This is the start. It adds the type to the strcut. The feature is not completed
yet.

Reviewed By: DurhamG

Differential Revision: D7444904

fbshipit-source-id: 60a83c9e6e8b0734450f0c5827928a7c5bd111d5
2018-04-13 21:51:45 -07:00