##// END OF EJS Templates
dirstate-tree: Avoid BTreeMap double-lookup when inserting a dirstate entry...
dirstate-tree: Avoid BTreeMap double-lookup when inserting a dirstate entry The child nodes of a given node in the tree-shaped dirstate are kept in a `BTreeMap` where keys are file names as strings. Finding or inserting a value in the map takes `O(log(n))` string comparisons, which adds up when constructing the tree. The `entry` API allows finding a "spot" in the map that may or may not be occupied and then access that value or insert a new one without doing map lookup again. However the current API is limited in that calling `entry` requires an owned key (and so a memory allocation), even if it ends up not being used in the case where the map already has a value with an equal key. This is still a win, with 4% better end-to-end time for `hg status` measured here with hyperfine: ``` Benchmark #1: ../hg2/hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1 Time (mean ± σ): 1.337 s ± 0.018 s [User: 892.9 ms, System: 437.5 ms] Range (min … max): 1.316 s … 1.373 s 10 runs Benchmark #2: ./hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1 Time (mean ± σ): 1.291 s ± 0.008 s [User: 853.4 ms, System: 431.1 ms] Range (min … max): 1.283 s … 1.309 s 10 runs Summary './hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1' ran 1.04 ± 0.02 times faster than '../hg2/hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1' ``` * ./hg is this revision * ../hg2/hg is its parent * $REPO is an old snapshot of mozilla-central Differential Revision: https://phab.mercurial-scm.org/D10550

File last commit:

r46644:2cf61e66 merge default
r47886:04bcba53 default
Show More
pyoxidizer.bzl
116 lines | 3.7 KiB | text/x-python | PythonLexer
ROOT = CWD + "/../.."
IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE
# Code to run in Python interpreter.
RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()"
set_build_path(ROOT + "/build/pyoxidizer")
def make_distribution():
return default_python_distribution()
def make_distribution_windows():
return default_python_distribution(flavor = "standalone_dynamic")
def resource_callback(policy, resource):
if not IS_WINDOWS:
resource.add_location = "in-memory"
return
# We use a custom resource routing policy to influence where things are loaded
# from.
#
# For Python modules and resources, we load from memory if they are in
# the standard library and from the filesystem if not. This is because
# parts of Mercurial and some 3rd party packages aren't yet compatible
# with memory loading.
#
# For Python extension modules, we load from the filesystem because
# this yields greatest compatibility.
if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"):
if resource.is_stdlib:
resource.add_location = "in-memory"
else:
resource.add_location = "filesystem-relative:lib"
elif type(resource) == "PythonExtensionModule":
resource.add_location = "filesystem-relative:lib"
def make_exe(dist):
"""Builds a Rust-wrapped Mercurial binary."""
packaging_policy = dist.make_python_packaging_policy()
# Extension may depend on any Python functionality. Include all
# extensions.
packaging_policy.extension_module_filter = "all"
packaging_policy.resources_location = "in-memory"
if IS_WINDOWS:
packaging_policy.resources_location_fallback = "filesystem-relative:lib"
packaging_policy.register_resource_callback(resource_callback)
config = dist.make_python_interpreter_config()
config.raw_allocator = "system"
config.run_command = RUN_CODE
# We want to let the user load extensions from the file system
config.filesystem_importer = True
# We need this to make resourceutil happy, since it looks for sys.frozen.
config.sys_frozen = True
config.legacy_windows_stdio = True
exe = dist.to_python_executable(
name = "hg",
packaging_policy = packaging_policy,
config = config,
)
# Add Mercurial to resources.
exe.add_python_resources(exe.pip_install(["--verbose", ROOT]))
# On Windows, we install extra packages for convenience.
if IS_WINDOWS:
exe.add_python_resources(
exe.pip_install(["-r", ROOT + "/contrib/packaging/requirements-windows-py3.txt"]),
)
return exe
def make_manifest(dist, exe):
m = FileManifest()
m.add_python_resource(".", exe)
return m
def make_embedded_resources(exe):
return exe.to_embedded_resources()
register_target("distribution_posix", make_distribution)
register_target("distribution_windows", make_distribution_windows)
register_target("exe_posix", make_exe, depends = ["distribution_posix"])
register_target("exe_windows", make_exe, depends = ["distribution_windows"])
register_target(
"app_posix",
make_manifest,
depends = ["distribution_posix", "exe_posix"],
default = "windows" not in BUILD_TARGET_TRIPLE,
)
register_target(
"app_windows",
make_manifest,
depends = ["distribution_windows", "exe_windows"],
default = "windows" in BUILD_TARGET_TRIPLE,
)
resolve_targets()
# END OF COMMON USER-ADJUSTED SETTINGS.
#
# Everything below this is typically managed by PyOxidizer and doesn't need
# to be updated by people.
PYOXIDIZER_VERSION = "0.9.0"
PYOXIDIZER_COMMIT = "1fbc264cc004226cd76ee452e0a386ffca6ccfb1"