Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7d4b9ad5fc390e75e6391417c74bff8a5ba74da1
      
https://github.com/WebKit/WebKit/commit/7d4b9ad5fc390e75e6391417c74bff8a5ba74da1
  Author: Alexey Proskuryakov <[email protected]>
  Date:   2026-05-28 (Thu, 28 May 2026)

  Changed paths:
    M Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py
    M Tools/Scripts/libraries/webkitcorepy/webkitcorepy/partial_proxy.py
    M Tools/Scripts/libraries/webkitcorepy/webkitcorepy/timeout.py
    M Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py
    M Tools/Scripts/webkitpy/common/version_name_map.py
    M 
Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy.py
    M Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
    M Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
    M Tools/Scripts/webkitpy/port/base.py
    M Tools/Scripts/webkitpy/port/base_unittest.py
    M Tools/Scripts/webkitpy/port/config.py
    M Tools/Scripts/webkitpy/port/config_unittest.py
    M Tools/Scripts/webkitpy/port/darwin.py
    M Tools/Scripts/webkitpy/port/factory.py
    M Tools/Scripts/webkitpy/port/factory_unittest.py
    M Tools/Scripts/webkitpy/port/mac.py

  Log Message:
  -----------
  Reduce run-webkit-tests startup overhead for faster iteration
https://bugs.webkit.org/show_bug.cgi?id=314459
rdar://176618242

Reviewed by Sam Sneddon and Jonathan Bedard.

`run-webkit-tests fast/dom/ChildNode-replaceWith.html` wall clock drops from ~5s
to ~2.8s. WebKitTestRunner itself still takes ~1s; the rest is setup overhead
that this change trims.

Each of these improvements was independently measurable:
- LayoutTestHelper's ~440ms color-profile install now overlaps with test 
discovery
  instead of blocking _set_up_run.
- configuration_for_upload (which pulls in requests, ~80ms) runs only when
  --report is passed.
- webkit-build-directory perl calls: 4 → 1, via a class-level cache and a lazy
  --target default (~500ms).
- WebKitTestRunner warmup is skipped when child_processes == 1.
- Several production import paths no longer pull in unittest.mock,
  webkitcorepy.mocks submodules, the whole requests stack, or the embedded-port
  chain on a Mac run.
- Misc: cached inner finder, precompiled regex, lazy port-factory table.

* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py:
Load only ContextStack eagerly. Time / Subprocess / Requests / Terminal /
FileLock / Environment are exposed via PEP 562 module-level __getattr__ +
CallByNeed, so callers that only need ContextStack don't pull in their
dependencies (unittest.mock, requests, etc.). Resolved attributes are written
back into globals() so later access (and pickle/isinstance) skip the proxy.

* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/partial_proxy.py:
* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/timeout.py:
Defer importing unittest.mock to first use via CallByNeed. These modules are
imported on every webkitcorepy load but rarely call into mock at production
runtime.

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py:
Drop the eager `from webkitscmpy import mocks` import; tests that need it import
it explicitly. Cuts an unconditional load of mocks.* from production paths.

* Tools/Scripts/webkitpy/common/version_name_map.py:
Add DARWIN_CURRENT_VERSION = Version(26) as the single source of truth for the
current Darwin major; the ios/tvos/watchos/visionos PUBLIC_TABLE entries already
share Darwin's value through this constant.

* Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy.py:
(LayoutTestFinder.__init__):
(LayoutTestFinder._make_inner_finder):
(LayoutTestFinder.find_tests_by_path):
(LayoutTestFinder._is_test_file):
(LayoutTestFinder._is_w3c_resource_file):
Memoize the inner LayoutTestFinder_New per device_type with functools.cache
bound to the instance, so repeated lookups don't redo baseline_search_path()
work. Bound on the instance (not the class) so the cache doesn't outlive the
LayoutTestFinder.

* Tools/Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager.run):
Kick start_helper_async off before _collect_tests so the helper warmup overlaps
with test discovery and expectations parsing.
(Manager._set_up_run):
Join on the helper via wait_for_helper_ready instead of start_helper.
(Manager._update_worker_count):
After clamping options.child_processes, sync the value back onto the port via
set_option. Port has its own copy of options (_create_port_for_driver does
optparse.Values copy.copy), so the warmup gate and embedded-port device-count
logic see the effective worker count.
(Manager._end_test_run):
Compute configuration_for_upload only when --report is passed, avoiding an
unconditional import of requests on every run.

* Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py:
(TestExpectationParser._tokenize_line):
Collapse whitespace with `" ".join(s.split())` instead of an `re.sub`, and
precompile _BUG_TOKEN_RE.

* Tools/Scripts/webkitpy/port/base.py:
(Port._helper_process):
(Port._helper_started):
(Port._helper_ready):
Class-level state for the LayoutTestHelper. _helper_started records that the
spawn was attempted, so a None _helper_process is interpreted as a failed spawn
rather than no spawn at all.
(Port.start_helper_async):
(Port.wait_for_helper_ready):
New no-op defaults; MacPort overrides them. Splitting the old start_helper into
a kick-off + join lets the caller overlap helper warmup with other work.
(Port.stop_helper):
Reset _helper_started and _helper_ready so a later run isn't mistaken for one
whose spawn failed.

* Tools/Scripts/webkitpy/port/config.py:
(Config._build_directories):
(Config._clear_cache_for_testing):
(Config.build_directory):
Cache is class-level now (invariant within a process and shareable across
Config instances) and keyed on
(port_implementation, configuration, for_host, use_cmake).

* Tools/Scripts/webkitpy/port/base_unittest.py:
* Tools/Scripts/webkitpy/port/config_unittest.py:
(PortTest.setUp):
(ConfigTest.setUp):
Clear the class-level Config cache between tests and between phases within
test_build_directory so it doesn't leak across cases.

* Tools/Scripts/webkitpy/port/darwin.py:
(DarwinPort.CURRENT_VERSION):
Import DARWIN_CURRENT_VERSION from version_name_map instead of duplicating
Version(26).

* Tools/Scripts/webkitpy/port/factory.py:
(_load_port_class):
(PortFactory.PORT_CLASSES):
(PortFactory.get):
Replace the eager loop over all 14 port modules with a table mapping port-name
prefix to a "module.Class" path string. Only the matched port module is
imported, via importlib.import_module + getattr.
(configuration_options):
--target now defaults to None. Port.__init__ already calls
set_option_default('configuration', self.default_configuration()) after
parsing, so the old eager Config.default_configuration() call at
option-definition time (one perl invocation every run) is redundant.

* Tools/Scripts/webkitpy/port/factory_unittest.py:
(FactoryTest.test_port_classes_table_consistency):
Assert each prefix in PORT_CLASSES matches the imported class's port_name so
the duplication cannot silently drift.

* Tools/Scripts/webkitpy/port/mac.py:
(MacPort.setup_test_run):
Skip the WebKitTestRunner warmup when child_processes == 1; the warmup exists
to avoid first-run binary-verification thrash with N parallel workers
(webkit.org/b/242106), which doesn't apply to a single worker.
(MacPort.start_helper):
Now just start_helper_async + wait_for_helper_ready.
(MacPort.start_helper_async):
(MacPort.wait_for_helper_ready):
Split into non-blocking popen + blocking readline. Track helper state on
Port._helper_process / _helper_started / _helper_ready so wait returns False
for a helper that failed to spawn.

Canonical link: https://commits.webkit.org/314080@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to