Files
swift-mirror/stdlib/public/runtime/EnvironmentVariables.def
Mike Ash f35b110cf7 [Runtime] Support precomputed protocol conformances in the shared cache.
When available, take advantage of precomputed protocol conformances in the shared cache on Darwin platforms to accelerate conformance lookups and cut down on memory usage.

We consult the precomputed conformances before doing the runtime's standard conformance lookup. When a conformance is precomputed, this avoids the slow linear scan of all loaded conformances for the first access, and it avoids the memory cost of storing the conformance in the cache.

When the shared cache has no images overridden (the normal case), then we can also skip scanning conformances in the shared cache in all circumstances, because the precomputed conformances will always cover those results. This greatly speeds up the slow linear scan for the initial lookup of anything that doesn't have a conformance in the shared cache, including lookups with conformances in apps or app frameworks, and negative lookups.

A validation mode is available by setting the SWIFT_DEBUG_VALIDATE_SHARED_CACHE_PROTOCOL_CONFORMANCES environment variable. When enabled, results from the precomputed conformances are compared with the results from a slow scan of the conformances in the shared cache. This extremely slow, but good at catching bugs in the system.

When the calls for precomputed conformances are unavailable, the new code is omitted and we remain in the same situation as before, with the runtime performing all lookups by scanning conformance sections in all loaded Swift images.

rdar://71128983
2021-02-11 12:34:23 -05:00

59 lines
2.3 KiB
C++

//===--- EnvironmentVariables.def - Debug variables. ------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines x-macros used for metaprogramming with the set of
// environment variables used for configuring or enabling debug features in the
// runtime.
//
//===----------------------------------------------------------------------===//
// #define VARIABLE(name, type, defaultValue, help)
#ifndef VARIABLE
#error "Must define VARIABLE to include EnvironmentVariables.def"
#endif
VARIABLE(SWIFT_DEBUG_ENABLE_METADATA_ALLOCATION_ITERATION, bool, false,
"Enable additional metadata allocation tracking for swift-inspect to "
"use.")
VARIABLE(SWIFT_DEBUG_ENABLE_METADATA_BACKTRACE_LOGGING, bool, false,
"Enable logging of backtraces for each metadata allocation. Requires "
"SWIFT_DEBUG_ENABLE_METADATA_ALLOCATION_ITERATION to be enabled.")
VARIABLE(SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT, uint8_t, 2,
"Print warnings when using implicit @objc entrypoints. Set to "
"desired reporting level, 0-3.")
VARIABLE(SWIFT_DETERMINISTIC_HASHING, bool, false,
"Disable randomized hash seeding.")
VARIABLE(SWIFT_ENABLE_MANGLED_NAME_VERIFICATION, bool, false,
"Enable verification that metadata can roundtrip through a mangled "
"name each time metadata is instantiated.")
VARIABLE(SWIFT_DEBUG_ENABLE_MALLOC_SCRIBBLE, bool, false,
"Scribble on runtime allocations such as metadata allocations.")
VARIABLE(SWIFT_DEBUG_ENABLE_COW_CHECKS, bool, false,
"Enable internal checks for copy-on-write operations.")
#if defined(__APPLE__) && defined(__MACH__)
VARIABLE(SWIFT_DEBUG_VALIDATE_SHARED_CACHE_PROTOCOL_CONFORMANCES, bool, false,
"Validate shared cache protocol conformance results against the "
"lists of conformances in the shared cache images.")
#endif
#undef VARIABLE