Commit Graph

26 Commits

Author SHA1 Message Date
Durham Goode
1dec377020 sqldirstate: add _otherparentset to match upstream
Summary: Upstream has added a new attribute to dirstate. Let's add it too.

Test Plan: Tests now pass

Reviewers: mitrandir, #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4695923

Signature: t1:4695923:1489283439:c7876832af2764d2bbe9cd0f9e47199c84799609
2017-03-12 12:49:18 -07:00
Mateusz Kwapich
d85d95b667 integration tests for sqldirstate/fbhistedit and "hg amend" test for latter
Summary:
This diff was created when I was investigating hgamend exec not working
with histedit which resulted with [1].
This also brings some very small fixes for sqldirstate and fbamend that
I was too lazy to diff separately.

[1] https://patchwork.mercurial-scm.org/patch/16451/

Test Plan: ran tests

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3777784

Signature: t1:3777784:1472227075:f2f8a9cad22bf0c45d4554709846b8aafb61d9a0
2016-10-21 06:01:59 -07:00
FUJIWARA Katsunori
78163be124 sqldirstate: write fake dirstate always to detect changes correctly
Before this patch, if sqldirstate.fakedirstate configuration is false
value, (fake) dirstate isn't written out (or explicitly unlinked),

In such case, @filecache never detects change of dirstate by another
process/thread, because not-existing file never change its file stat.

To achieve checking cache validity without existence of .hg/dirstate
file, we should use another cache annotation instead of @filecache.

This patch removes code paths to avoid writing (or unlinking) fake
dirstate, and writes fake dirstate always to detect changes correctly.

Just removing these code paths seems reasonable enough, because it was
already confirmed at Mercurial 4.0 sprint that there is no concrete
usecase for sqldirstate.fakedirstate configuration.
2016-10-14 23:55:13 +09:00
FUJIWARA Katsunori
815cba9283 sqldirstate: specify checkambig=True to avoid file stat ambiguity
With sqldirstate extension, size of .hg/dirstate is always fixed: node
ID x 2 + dummy fixed text.

This increases occurrence of file stat ambiguity, and
processes/threads running parallelly might overlook change of
dirstate, because reloading @filecache-ed property repo.dirstate is
avoided in such case. See wiki page below for detail about file stat
ambiguity.

    https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan

This patch specifies checkambig=True at opening .hg/dirstate file for
writing, to avoid file stat ambiguity.

Strictly speaking, to enable sqldirstate with Mercurial earlier than
upcoming 4.0 (or ccbeace526ad), it should be examined whether
checkambig optional argument is available for opener or not, because
it has been available since 4.0 (or ccbeace526ad).

But current sqldirstate implementation depends on 2369a09e89de of
Mercurial, which has introduced dirstate._origpl after ccbeace526ad.

Therefor, changes in this patch are safe enough, unless removing
dependence on dirstate._origpl from sqldirstate.
2016-10-14 23:55:12 +09:00
Mateusz Kwapich
e60bf765eb sqldirstate: make cache treshold configurable
Summary:
That will allow us to figure out the best one (or even configure it on
per-repo basis if we want)

Test Plan: ran tests

Reviewers: #mercurial, durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3723215

Signature: t1:3723215:1471373384:e2e68369b0a1a3a5e7d630ea97b33061e24832bf
2016-08-31 06:09:50 -07:00
Mateusz Kwapich
4913062607 check-code fixes
Test Plan: check-code passing

Reviewers: #mercurial, ttung, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3771131

Signature: t1:3771131:1472139248:f8ea463552fc0d2261456050e9bf513f26eb727c
2016-08-25 09:04:43 -07:00
Mateusz Kwapich
675561c76f sqldirstate: call the registered callbacks on wd parent change
Summary:
This diff together with patches introducing the mentioned callback in upstream
will fix the journal under sqldirstate.

Test Plan: journal tests passed, the rest is currently running - will update the test plan soon

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: durham, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3690878

Signature: t1:3690878:1470800077:3fe48e03bb65eaeed3a7326b6e7d392abe7efd8d
2016-08-15 03:46:52 -07:00
Mateusz Kwapich
c46b67bc21 sqldirstate: maintain cache on resetnow
Summary:
properly updates the lookupcache and cached nonnormalset
on resetnow operation. This fixes test failures observed by durham

Test Plan:
    $ ./run-sqlitedirstate-test.py --hg ~/facebook-hg-rpms/hg-crew/ test-import-eol.t   test-commit-multiple.t test-commit-interactive-curses.t
    ...
    # Ran 3 tests, 0 skipped, 0 warned, 0 failed.

Reviewers: durham

Subscribers: mjpieters, #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D3669783
2016-08-04 11:33:23 -07:00
Durham Goode
cee701f980 tests: fix checkcode and simple test failures 2016-08-01 11:54:13 -07:00
Mateusz Kwapich
b5b42b6764 sqldirstate: sql trace facility
Summary:
to debug the sql performance we need a to trace the sql queries. This hacky module
facilitates that need.

Test Plan:
    [mitrandir@dev3277 fbsource  (92e442f)]$ xhg --config sqldirstate.tracefile=trace  st
    ? fbcode/eden/x.py
    [mitrandir@dev3277 fbsource  (92e442f)]$ cat trace |arc paste
    Reading paste from stdin...
    P56530356: https://phabricator.intern.facebook.com/P56530356

Reviewers: #mercurial, ttung, durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3626545
2016-07-28 14:44:56 -07:00
Mateusz Kwapich
6aed798eaf sqlite: keep nonnormal files in the separate table
Summary:
The low cardinality of the status column makes it basically
non-indexable (try to do a binsearch in a sorted array with
1m numbers from the range {1..5} and you will see why this approach
doesn't work).

There is a feature we could use in sqlite 3.9 called partial indexes - so
we could index only the files that have non-normal statuses.

The sqlite 3.6 that we are using on centos6 unfortunately doesn't support it.
IMO the cost of shipping and maintaining our separate version of sqlite is
too high so let's simulate it by keeping those entries in separate table.

Test Plan:
 * tests are passing
 * on fbsource/fbcode "hg st" went down from ~800ms to ~600ms.

Reviewers: #mercurial, ttung, durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3559244
2016-07-28 14:44:56 -07:00
Mateusz Kwapich
8a22e4767d sqldirstate: add very basic db schema migration support
Summary: It adds basic support for upgrading the db schema in sqldirsate.

Test Plan: tests passing

Reviewers: #mercurial, durham, ttung, rmcelroy, quark

Subscribers: quark, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3567032
2016-07-28 14:44:56 -07:00
Mateusz Kwapich
ba7472d564 sqldirstate: pragma synchronous off
Summary:
From sqlite manual:

    With synchronous OFF (0), SQLite continues without syncing as soon as it
    has handed data off to the operating system. If the application running
    SQLite crashes, the data will be safe, but the database might become
    corrupted if the operating system crashes or the computer loses power
    before that data has been written to the disk surface. On the other hand,
    commits can be orders of magnitude faster with synchronous OFF.

I believe this is a proper tradeoff for dirstate as we can regenerate it easily if db becomes corrupted.

Test Plan: tests are passing

Reviewers: #mercurial, ttung, durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3559167
2016-07-15 12:20:59 -07:00
Mateusz Kwapich
e2d96b6e44 sqldirstate: do not populate the nonnormalset when not neccesary
Summary: We can be more lazy - it's propertycache so it will populate itself when needed.

Test Plan: tests are passing

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3558232

Signature: t1:3558232:1468460942:e5e03743ec9a33cdb5da6d5f7541af28316f6c34
2016-07-15 12:20:59 -07:00
Mateusz Kwapich
194aa6eefb sqldirstate: remove dead code
Test Plan: nope

Reviewers: #mercurial, ttung

Reviewed By: ttung

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3537389

Signature: t1:3537389:1468015282:4996808ad664d4277712b4f9a662ab83225ec0a2
2016-07-11 14:49:04 -07:00
Mateusz Kwapich
b6ab06f7a2 sqldirstate: fast in-memory cache for batch operations
Summary:
To fix sqldirstate perf in case of iterating through whole
dirstate we are introducing the possibility to cache it in memory when
neccessary.

Currently we are doing it only in the case when dirstate.walk() is called.

Test Plan:
    ./run-sqlitedirstate-test.py --hg ~/clowncopter/ -j 30 -t 1200
    ~/clowncopter/tests/run-tests.py -j 30

Reviewers: #mercurial, durham, ttung, lcharignon

Reviewed By: lcharignon

Subscribers: lcharignon, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3472402

Signature: t1:3472402:1466807592:a28bc4662cc157547b8b747c6be98faae35c63b5
2016-06-24 15:48:40 -07:00
Mateusz Kwapich
cafe836e70 sqldirstate: invalidate fsmonitorstate
Summary: This allow us to work regardless of order in which extensions are loaded.

Test Plan: ran some manual smoketests - there are no real integration tests yet

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3373452

Signature: t1:3373452:1464809280:0089c28818bab3acc4695b5c5411755a4505acf8
2016-06-01 12:28:33 -07:00
Mateusz Kwapich
1df2a19bb9 sqldirstate: set cache_size to 100M
Summary:
For fbsource with sparse fbcode checkout this gets the conversion time
from 17s to 9.6s. Thanks @quark for showing me this option!

Test Plan: all tests passing

Reviewers: #mercurial, durham, ttung, quark

Reviewed By: quark

Subscribers: lcharignon, simonfar, mjpieters, quark

Differential Revision: https://phabricator.intern.facebook.com/D3365789

Signature: t1:3365789:1464712896:18ae59394b8e3591a8d55fed67f22921e1e4254f
2016-06-01 09:32:16 -07:00
Mateusz Kwapich
51960217f9 sqldirstate: use pragmas to speed up the db population.
Summary: For full fbsource population is now 1m 20s (was 3m)

Test Plan: ran tests

Reviewers: #mercurial, durham, ttung, quark

Reviewed By: quark

Subscribers: quark, simonfar, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3356661

Signature: t1:3356661:1464703660:25be61b1170c52cf4e300490ea59afc21a575619
2016-05-31 07:16:08 -07:00
Mateusz Kwapich
c64e359854 sqldirstate: populate dirs in memory, then use sql
Summary:
This dirs datascture does a lot of queries about itself during its
construction. This speeds it up by doing the construction in memory
the uploading the whole dictionary to db at once.

Time for full population on fbsource went down form 5m to 3m.

Test Plan: ran tests

Reviewers: #mercurial, durham, ttung

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3356658
2016-05-27 14:54:48 -07:00
Mateusz Kwapich
a47c065b9a sqldirstate: speed up the db population by implementing our dict.update
Summary:
This uses the executemany for bulk INSERTS in db instead od doing many single
queries. This is also refactoring the sqldirstate conversion to use it.

Test Plan: ran tests

Reviewers: #mercurial, durham, ttung

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3356654
2016-05-27 14:54:48 -07:00
Mateusz Kwapich
af78d790f7 sqldirstate: write a flat dirstate with just parents for backwards comp
Summary:
This is neccessary for scmprompt to work. I added a config knob because we
may want to disable it if we want to do paranoid mode at some point.

Test Plan: ran tests

Reviewers: #mercurial, durham

Differential Revision: https://phabricator.intern.facebook.com/D3356646
2016-05-27 14:54:48 -07:00
Mateusz Kwapich
d19764dd10 sqldirstate: extract the upgrade and downgrade logic
Summary: This is to make implementation of automatic upgrade easier.

Test Plan: Will add a test for it in one of the next diffs

Reviewers: #mercurial, durham, ttung

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3356494
2016-05-27 14:54:48 -07:00
Mateusz Kwapich
8510d18a0c sqldirstate: just close connection on invalidate
Summary:
the transaction won't be commited anyway.
The journal will be rolled back on next database open.

Test Plan: ran mercurial tests with sqldirstate

Reviewers: #mercurial, durham, ttung, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3345277

Signature: t1:3345277:1464168844:69206055d24ae0349985f0038845122e7cea0a19
2016-05-25 14:12:09 -07:00
Mateusz Kwapich
02410993ca sqldirstate: do not execute insert if metadata already exists
Summary:
This causes the read-only dirstate operations to be readonly from
db standpoint so they can run while there is a pending transaction.

Test Plan: ran mercurial tests with sqldirstate

Reviewers: simonfar, durham

Reviewed By: simonfar, durham

Subscribers: simonfar, mjpieters, #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D3345257

Signature: t1:3345257:1464168444:a98bc04c23e174d0c10ed07eb914930949a67b7d
2016-05-25 14:12:09 -07:00
Mateusz Kwapich
440d3ebb04 sqldirstate: the extension
Summary:
An extension replacing dirstate file with sqlite database so we can have incremental changes and we don't have to read the whole dirstate on every op. This makes sense only when hgwatchan/fsmonitor is on so we don't iterate through whole dirstate.
This is also using the sqlite transactions to handle dirstate transactions instead of copying db around. As a result of that "hg rollback" doesn't work anymore. You can fall back to copying things by setting sqldirstate.skipbackups to False.

Needs those to go to upstream to work: https://phabricator.intern.facebook.com/P56319612
(will send them once the freeze is over)

To use make sure that the extension is loaded *before* hgwatchman (watchman
should be outmost layer).

Test Plan:
Passing all but few mercurial tests (when running with skipbackups=False)
The failures are described in blacklist file.

Reviewers: lcharignon, wez, quark, durham

Reviewed By: durham

Subscribers: laurent, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D3242547

Signature: t1:3242547:1462577481:fdbfb5287fb8d3e58f7b4d587c01de79ce6b78df
2016-05-06 16:56:45 -07:00