Skip to content

Commit

Permalink
Remove watchman. (pantsbuild#10114)
Browse files Browse the repository at this point in the history
[ci skip-jvm-tests]
  • Loading branch information
stuhood authored and benjyw committed Apr 5, 2021
1 parent 4b02fd8 commit bbcd6cc
Show file tree
Hide file tree
Showing 21 changed files with 8 additions and 1,028 deletions.
1 change: 0 additions & 1 deletion 3rdparty/python/requirements.txt
Expand Up @@ -26,7 +26,6 @@ psutil==5.7.0
Pygments==2.6.1
pystache==0.5.4
python-Levenshtein==0.12.1
pywatchman==1.4.1
PyYAML>=5.3.1,<5.4
py_zipkin==0.20.0
requests[security]>=2.20.1
Expand Down
2 changes: 1 addition & 1 deletion src/docs/architecture_pantsd.md
Expand Up @@ -38,7 +38,7 @@ Services

A Pants Daemon process has several services that it polls in order. Every service runs in a separate thread, and can be paused, resumed or terminated. Services can communicate with each other.

Examples of services are [`FSEventService`](https://github.com/pantsbuild/pants/blob/master/src/python/pants/pantsd/service/fs_event_service.py#14), which takes care of listening for watchman events, [`SchedulerService`](https://github.com/pantsbuild/pants/blob/master/src/python/pants/pantsd/service/scheduler_service.py#21), which takes care of listening responding to those events to keep a warm `Graph`, and [`PailgunService`](https://github.com/pantsbuild/pants/blob/master/src/python/pants/pantsd/service/pailgun_service.py#15), which listens to `SchedulerService` and manages the lifetime of a `PailgunServer` responsible for spawning pants runs when requested by clients, it takes a `DaemonPantsRunner` as one of its arguments, to use as a template to spawn pants runs when requested by the clients.
Examples of services are [`SchedulerService`](https://github.com/pantsbuild/pants/blob/master/src/python/pants/pantsd/service/scheduler_service.py#21), which takes care of listening responding to those events to keep a warm `Graph`, and [`PailgunService`](https://github.com/pantsbuild/pants/blob/master/src/python/pants/pantsd/service/pailgun_service.py#15), which listens to `SchedulerService` and manages the lifetime of a `PailgunServer` responsible for spawning pants runs when requested by clients, it takes a `DaemonPantsRunner` as one of its arguments, to use as a template to spawn pants runs when requested by the clients.

### PailgunService

Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/core_tasks/register.py
Expand Up @@ -58,8 +58,7 @@ def register_goals():
# Pantsd.
kill_pantsd = task(name="kill-pantsd", action=PantsDaemonKill)
kill_pantsd.install()
# Kill pantsd/watchman first, so that they're not using any files
# in .pants.d at the time of removal.
# Kill pantsd first so that it's not using any files in .pants.d at the time of removal.
kill_pantsd.install("clean-all", first=True)

# Reporting server.
Expand Down
77 changes: 0 additions & 77 deletions src/python/pants/option/global_options.py
Expand Up @@ -666,83 +666,6 @@ def register_bootstrap_options(cls, register):
"Pants' own code, plugins, and `--pants-config-files` are inherently invalidated.",
)

# Watchman options.
register(
"--watchman-enable",
type=bool,
advanced=True,
default=False,
removal_version="1.31.0.dev0",
removal_hint=(
"The native watcher is now sufficient to monitor for filesystem "
"changes, so watchman is being removed."
),
help="Use the watchman daemon filesystem event watcher to watch for changes "
"in the buildroot in addition to the built in watcher.",
)
register(
"--watchman-version",
advanced=True,
default="4.9.0-pants1",
removal_version="1.31.0.dev0",
removal_hint=(
"The native watcher is now sufficient to monitor for filesystem "
"changes, so watchman is being removed."
),
help="Watchman version.",
)
register(
"--watchman-supportdir",
advanced=True,
default="bin/watchman",
removal_version="1.31.0.dev0",
removal_hint=(
"The native watcher is now sufficient to monitor for filesystem "
"changes, so watchman is being removed."
),
help="Find watchman binaries under this dir. Used as part of the path to lookup "
"the binary with --binaries-baseurls and --pants-bootstrapdir.",
)
register(
"--watchman-startup-timeout",
type=float,
advanced=True,
default=60.0,
removal_version="1.31.0.dev0",
removal_hint=(
"The native watcher is now sufficient to monitor for filesystem "
"changes, so watchman is being removed."
),
help="The watchman socket timeout (in seconds) for the initial `watch-project` command. "
"This may need to be set higher for larger repos due to watchman startup cost.",
)
register(
"--watchman-socket-timeout",
type=float,
advanced=True,
default=0.1,
removal_version="1.31.0.dev0",
removal_hint=(
"The native watcher is now sufficient to monitor for filesystem "
"changes, so watchman is being removed."
),
help="The watchman client socket timeout in seconds. Setting this to too high a "
"value can negatively impact the latency of runs forked by pantsd.",
)
register(
"--watchman-socket-path",
type=str,
advanced=True,
default=None,
removal_version="1.31.0.dev0",
removal_hint=(
"The native watcher is now sufficient to monitor for filesystem "
"changes, so watchman is being removed."
),
help="The path to the watchman UNIX socket. This can be overridden if the default "
"absolute path length exceeds the maximum allowed by the OS.",
)

register(
"--build-file-prelude-globs",
advanced=True,
Expand Down
35 changes: 0 additions & 35 deletions src/python/pants/pantsd/BUILD
Expand Up @@ -29,7 +29,6 @@ python_library(
'3rdparty/python:setproctitle',
':pants_daemon_core',
':process_manager',
':watchman_launcher',
'src/python/pants/base:build_environment',
'src/python/pants/base:exception_sink',
'src/python/pants/base:exiter',
Expand All @@ -40,7 +39,6 @@ python_library(
'src/python/pants/init',
'src/python/pants/option',
'src/python/pants/option:options_bootstrapper',
'src/python/pants/pantsd/service:fs_event_service',
'src/python/pants/pantsd/service:scheduler_service',
'src/python/pants/pantsd/service:store_gc_service',
'src/python/pants/util:contextutil',
Expand All @@ -61,36 +59,3 @@ python_library(
],
tags = {"partially_type_checked"},
)

python_library(
name = 'watchman',
sources = ['watchman.py'],
dependencies = [
'src/python/pants/util:dirutil',
'src/python/pants/util:retry',
':process_manager',
':watchman_client'
],
tags = {"partially_type_checked"},
)

python_library(
name = 'watchman_client',
sources = ['watchman_client.py'],
dependencies = [
'3rdparty/python:pywatchman'
],
tags = {"partially_type_checked"},
)

python_library(
name = 'watchman_launcher',
sources = ['watchman_launcher.py'],
dependencies = [
':watchman',
'src/python/pants/binaries',
'src/python/pants/util:logging',
'src/python/pants/util:memo',
],
tags = {"partially_type_checked"},
)
24 changes: 1 addition & 23 deletions src/python/pants/pantsd/pants_daemon.py
Expand Up @@ -22,11 +22,9 @@
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.pantsd.pants_daemon_core import PantsDaemonCore
from pants.pantsd.process_manager import PantsDaemonProcessManager
from pants.pantsd.service.fs_event_service import FSEventService
from pants.pantsd.service.pants_service import PantsServices
from pants.pantsd.service.scheduler_service import SchedulerService
from pants.pantsd.service.store_gc_service import StoreGCService
from pants.pantsd.watchman_launcher import WatchmanLauncher
from pants.util.contextutil import stdio_as
from pants.util.logging import LogLevel
from pants.util.strutil import ensure_text
Expand Down Expand Up @@ -129,24 +127,11 @@ def _setup_services(
"""
build_root = get_buildroot()

# TODO: https://github.com/pantsbuild/pants/issues/3479
watchman_launcher = WatchmanLauncher.create(bootstrap_options)
watchman_launcher.maybe_launch()
watchman = watchman_launcher.watchman
fs_event_service = (
FSEventService(
watchman, scheduler=legacy_graph_scheduler.scheduler, build_root=build_root
)
if bootstrap_options.watchman_enable
else None
)

invalidation_globs = OptionsInitializer.compute_pantsd_invalidation_globs(
build_root, bootstrap_options,
)

scheduler_service = SchedulerService(
fs_event_service=fs_event_service,
legacy_graph_scheduler=legacy_graph_scheduler,
build_root=build_root,
invalidation_globs=invalidation_globs,
Expand All @@ -158,14 +143,7 @@ def _setup_services(
)

store_gc_service = StoreGCService(legacy_graph_scheduler.scheduler)

return PantsServices(
services=tuple(
service
for service in (fs_event_service, scheduler_service, store_gc_service,)
if service is not None
),
)
return PantsServices(services=(scheduler_service, store_gc_service))

def __init__(
self,
Expand Down
10 changes: 0 additions & 10 deletions src/python/pants/pantsd/service/BUILD
Expand Up @@ -11,16 +11,6 @@ python_library(
tags = {"partially_type_checked"},
)

python_library(
name = 'fs_event_service',
sources = ['fs_event_service.py'],
dependencies = [
':pants_service',
'src/python/pants/pantsd:watchman'
],
tags = {"partially_type_checked"},
)

python_library(
name = 'scheduler_service',
sources = ['scheduler_service.py'],
Expand Down
112 changes: 0 additions & 112 deletions src/python/pants/pantsd/service/fs_event_service.py

This file was deleted.

7 changes: 2 additions & 5 deletions src/python/pants/pantsd/service/scheduler_service.py
Expand Up @@ -10,14 +10,14 @@
from pants.engine.fs import PathGlobs, Snapshot
from pants.engine.internals.scheduler import ExecutionTimeoutError
from pants.init.engine_initializer import LegacyGraphScheduler
from pants.pantsd.service.fs_event_service import FSEventService
from pants.pantsd.service.pants_service import PantsService


class SchedulerService(PantsService):
"""The pantsd scheduler service.
This service holds an online Scheduler instance that is primed via watchman filesystem events.
This service uses the scheduler to watch the filesystem and determine whether pantsd needs to
restart in order to reload its state.
"""

# The interval on which we will long-poll the invalidation globs. If a glob changes, the poll
Expand All @@ -30,7 +30,6 @@ class SchedulerService(PantsService):
def __init__(
self,
*,
fs_event_service: Optional[FSEventService],
legacy_graph_scheduler: LegacyGraphScheduler,
build_root: str,
invalidation_globs: List[str],
Expand All @@ -39,7 +38,6 @@ def __init__(
max_memory_usage_in_bytes: int,
) -> None:
"""
:param fs_event_service: An unstarted FSEventService instance for setting up filesystem event handlers.
:param legacy_graph_scheduler: The LegacyGraphScheduler instance for graph construction.
:param build_root: The current build root.
:param invalidation_globs: A list of `globs` that when encountered in filesystem event
Expand All @@ -51,7 +49,6 @@ def __init__(
shut down if it observes more than this amount in use.
"""
super().__init__()
self._fs_event_service = fs_event_service
self._graph_helper = legacy_graph_scheduler
self._build_root = build_root

Expand Down

0 comments on commit bbcd6cc

Please sign in to comment.