sapling/tests/test-fsmonitor-bumpclock.t
Jun Wu 1145e2541b logging: migrate fsmonitor to new blackbox API
Summary:
The new log is typed and concise.

Old log:

  [fsmonitor]> clock='c:1559600325:3956709:1:34762' len(nonnormal)=0
  [fsmonitor]> setlastclock 'c:1559600325:3956709:1:36405'
  [fsmonitor]> setlastisfresh False
  [fsmonitor]> watchman returned ["x"]
  [fsmonitor]> getlastclock 'c:1559600325:3956709:1:36405'
  [fsmonitor]> set clock='c:1559600325:3956709:1:36405' notefiles=["x"]

New log:

  [fsmonitor] clock: "c:1559600325:3956709:1:34762" -> "c:1559600325:3956709:1:36405"; need check: [] + ["x"]

In JSON form:

  {"fsmonitor":{"new_clock":"c:1559600325:3956709:1:36425","new_files":{"len":1,"short_list":["x"]},"old_clock":"c:1559600325:3956709:1:34762"}

The new logging does not cover every information exposed by the old logging.
For example:

- Non-treestate events like why fsmonitor state gets invalidated.
  Assuming most clients are on treestate now. These are removed.
- "fsmonitor_state = normal | unavailable | fresh" scuba logging. This can be
  inferred, and will be added in a later diff.
- New "notefiles". The next "fsmoniotr" event will log the information.

Reviewed By: markbt

Differential Revision: D15710672

fbshipit-source-id: 5c4cad08c0072c7dc711e5c1e65aa7552940699e
2019-07-06 02:46:17 -07:00

59 lines
1.6 KiB
Perl

#require fsmonitor
$ newrepo
$ enable fsmonitor
$ touch a b c d e f
$ hg ci -m init -A a b c d e f
The fsmonitor extension should bump clock even if there are nothing changed for
treestate, but too many results returned by watchman.
$ hg status
(Run status again after 1 second to make sure mtime < fsnow)
$ sleep 1
$ hg status
In this case, treestate has 0 files marked NEED_CHECK, but fsmonitor returns
many files:
$ touch a b c d e f
$ hg debugstatus
len(dirstate) = 6
len(nonnormal) = 0
len(filtered nonnormal) = 0
clock = * (glob)
$ rm -rf .hg/blackbox*
$ hg status
$ hg blackbox --no-timestamp --no-sid --pattern '{"fsmonitor":"_"}'
[fsmonitor] clock: "c:*" -> "c:*"; need check: * + ["a", "b", "c", "d", "e"] and 1 entries (glob)
The watchman clock remains unchanged. Watchman still returns 6 files, which
means the "status" command could still be slow.
$ rm -rf .hg/blackbox*
$ hg status
$ hg blackbox --no-timestamp --no-sid --pattern '{"fsmonitor":"_"}'
[fsmonitor] clock: "c:*" -> "c:*"; need check: * + ["a", "b", "c", "d", "e"] and 1 entries (glob)
With watchman-changed-file-threshold set, clock is bumped and watchman can
return an empty list:
$ hg status
$ setconfig fsmonitor.watchman-changed-file-threshold=5
$ rm -rf .hg/blackbox*
$ hg status
$ hg blackbox --no-timestamp --no-sid --pattern '{"fsmonitor":"_"}'
[fsmonitor] clock: "c:*" -> "c:*"; need check: * + ["a", "b", "c", "d", "e"] and 1 entries (glob)
$ sleep 1
$ rm -rf .hg/blackbox*
$ hg status
$ hg blackbox --no-timestamp --no-sid --pattern '{"fsmonitor":"_"}'
[fsmonitor] clock: "c:*" -> "c:*"; need check: [] + [] (glob)