summaryrefslogtreecommitdiff
path: root/apt-pkg
Commit message (Collapse)AuthorAgeFilesLines
* apt: push to emplace C++11 if possibleHerman Semenoff2026-04-084-17/+17
| | | | | | References: - https://www.reddit.com/r/cpp_questions/comments/pm63yx/why_clangtidy_says_use_emplace_back_instead_of/ - https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-emplace.html
* apt-pkg/acquire: use range based for loop C++17Herman Semenoff2026-04-081-14/+14
|
* apt: funcs called with a string literal consisting of a single characterHerman Semenoff2026-04-088-16/+16
| | | | | | | | Benchmark: - https://stackoverflow.com/questions/62058906/why-my-performance-benchmark-gives-me-wrong-results References: - https://clang.llvm.org/extra/clang-tidy/checks/performance/prefer-single-char-overloads.html
* hashes: Use std::span instead of std::basic_string_viewJulian Andres Klode2026-04-071-2/+2
| | | | | | | | | std::basic_string_view should not be initialized locally, only in the std library. Replace it with a simple span instead. This should fix compilation with LLVM 18+. Supersedes: https://salsa.debian.org/apt-team/apt/-/merge_requests/511
* fix apt patterns parsing bug for pre-dependsZheyu Shen2026-04-071-2/+4
|
* Fix Phased-Update-Percentage probability mistakeAnders Kaseorg2026-04-072-4/+4
| | | | | | | | | | | | | | | | | | Previously a package with Phased-Update-Percentage: n would be updated with probability (n + 1)/101 instead of n/100. For example, a package with Phased-Update-Percentage: 0 could still be updated even though it shouldn’t, and a package with Phased-Update-Percentage: 1 would be installed almost twice as much as it should be. Correct the erroneous math. Note that libstdc++ implements std::uniform_int_distribution in such a way that for a given seed, changing dist(0, 100) to dist(0, 99) has the effect of decreasing each sample by 0 or 1; therefore, this patch will not randomly trigger extra phased updates that had previously been excluded. Fixes: c5bc86d45e003905ef411146e66b414d26fb1ff8 Signed-off-by: Anders Kaseorg <andersk@mit.edu>
* Copyright changesJulian Andres Klode2026-03-021-1/+1
|
* Prevent sleep while running dpkg.Nathan Pratta Teodosio2026-02-171-2/+9
| | | | | As long as we are running dpkg, keep an inhibitor that blocks us from sleeping.
* solver3: Upgrade by source packageJulian Andres Klode2026-02-172-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | Implement the "APT::Get::Upgrade-By-Source-Package" option as the classic solver does. Here this is equally straight forward now: We enqueue optional, but eager, clauses of the form foo=2 -> foo-data=2 for each sibling in the source version, assuming they are currently installed, and the selection is not the current version. This softly enforces upgrades of already installed siblings, but in non-strict-pinning mode it will not affect the selection of new packages to be installed. A more complete solution to version selection by source package also seems feasible, where we change the "priority" of versions in the solver dynamically - currently they are statically evaluated. Such that, when you select foo=2, and something installs foo-data, foo-data would be installed in version 2 even if version 3 were its candidate.
* solver3: Use constexpr and noexcept in most placesJulian Andres Klode2026-02-102-48/+50
| | | | | | | | | | | | | | | | | | | Aside from Clause, which initializes an std::vector and an std::forward_list, which do not have constexpr constructors in C++17, we can turn our inline functions constexpr. Using `constexpr` implies `inline`, so simplify that accordingly where needed. Adding noexcept to the function allows STL components to utilize more optimized code paths. Marking SameOrGroup as constexpr significantly improves performance due to being in the hot path and it now being inlined - removing branching by 10%. iolveiolver
* pkgcache: Change inline to constexpr noexceptJulian Andres Klode2026-02-102-167/+167
| | | | | | | | | | | | | | | In particular, map_pointer and iterators are now all literal types, with most functions translated to constexpr noexcept. This allows them to be used in constexpr contexts in C++17; and the compiler to generate better code knowing they cannot throw exceptions. This transformation is safe, because the functions are inline. more constexpr
* solver3: Cache straight pointers in candidate cacheJulian Andres Klode2026-02-101-3/+3
| | | | | This reduces its memory usage by half and turns it into a fast map - no destructors needed (and 0 initialization).
* solver3: Mark DependencySolver as finalJulian Andres Klode2026-02-101-1/+1
|
* solver3: Minor style refactoringsJulian Andres Klode2026-02-101-7/+4
| | | | | | | The for loop with if(foo) continue; return false; was highly unusual as were the bunch of uses of `!` instead of `not`. Gbp-dch: ignore
* solver3: Avoid manual delete[] in favor of RAIIJulian Andres Klode2026-02-101-3/+2
|
* solver3: Fix off-by-one missing optimizationJulian Andres Klode2026-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | We were trying to compare the dependencies in the first version with the dependencies in later version, but our loop started at the first version as well due to an oversight in the use of the increment operator. Change the increment from postfix to prefix such that we start iterating with the 2nd version in the list only. This should yield minute performance optimizations: before: 12: 17.80% 0.00% apt libapt-pkg.so.7.0.0 [.] EDSP::ResolveExternal(char const*, pkgDepCache&, unsigned int, OpProgress*) 14: --17.80%--EDSP::ResolveExternal(char const*, pkgDepCache&, unsigned int, OpProgress*) 20: | | |--6.34%--APT::Solver::DependencySolver::RegisterCommonDependencies(pkgCache::PkgIterator) 44: | | --0.85%--APT::Solver::DependencySolver::RegisterCommonDependencies(pkgCache::PkgIterator) after: 12: 16.98% 0.00% apt libapt-pkg.so.7.0.0 [.] EDSP::ResolveExternal(char const*, pkgDepCache&, unsigned int, OpProgress*) 14: --16.98%--EDSP::ResolveExternal(char const*, pkgDepCache&, unsigned int, OpProgress*) 20: | | |--5.65%--APT::Solver::DependencySolver::RegisterCommonDependencies(pkgCache::PkgIterator) 42: | | --0.70%--APT::Solver::DependencySolver::RegisterCommonDependencies(pkgCache::PkgIterator)
* solver3: Refactor Propagate() using lazy head/tailJulian Andres Klode2026-02-101-24/+18
| | | | | | | | | Calculate the head and the tail of the clause in Propagate() and check based on that if the clause is conflict/unit/undecided. Special care has been taken to avoid the calculation of tail when it is not necessary by placing it inside a helper lambda; as well as skipping the calculation when the clause is inactive.
* solver3: Remove dead codeJulian Andres Klode2026-02-101-10/+1
| | | | | | | It used to be that we reached conflict clauses from the Solve() loop, however that is no longer the case, so remove the else branch, and turn the `else if (item.clause->optional)` into a new `else` with an `assert(item.clause->optional)`.
* Introduce JSONL performance counter loggingJulian Andres Klode2026-02-103-0/+157
| | | | | | | | Introduce a scoped object that starts measuring performance counters and then dumps them into a JSONL file for later analysis. Add performance contexts for APT::Solver and pkgDepCache::Init() as starting points.
* solver3: Use classical watchers for propagationJulian Andres Klode2026-01-312-55/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of tracking dependencies and reverse dependencies, install classical watchers. This vastly streamlines the propagation code and allows us to easily switch to literals in the next step. This implementation watches _all_ solutions rather than using the modern 2-watched literals scheme or the intermediate head/tail watchers. Ultimately a more effective watcher scheme would be interesting but not a significant priority seeing as most of the solver runtime is spent not in propagation but in problem translation. decision trees -------------- The new watchers produce slightly different decision trees, sometimes subtly changing solutions. Notably in various observed examples in Ubuntu 25.04, courier was installed as an MTA instead of postfix: The old decision tree was: apcupsd:amd64 -> mailutils:amd64=1:3.18-1 -> mailutils:amd64 -> postfix:amd64=3.9.1-10ubuntu1 The new decision tree is: lsb:amd64 -> lsb-core:amd64 -> courier-mta:amd64=1.3.13-1 The difference here being that lsb-core declares a mail-transport-agent dependency whereas mailutils depends on `default-mta | mail-transport-agency`; but both are effectively subject to selection at similar time. Further work is needed to optimize selection. A notable choice may also be to deal with broken packages like lsb-core that declare dependencies solely on a virtual package by reconstructing the default provider for that package utilizing default-* dependencies or similar notions. Likewise in the test suite, explanations are different in some uninstallable cases. backtracking ~~~~~~~~~~~~ The following major changes were observed in the 25.04 test suite: -tmp/regression-remove/07f0a068-36c2-11f0-b7c1-fa163e171f02:18 +tmp/regression-remove/07f0a068-36c2-11f0-b7c1-fa163e171f02:3 -tmp/regression-remove/32078f70-3734-11f0-a75a-fa163ec8ca8c:64 +tmp/regression-remove/32078f70-3734-11f0-a75a-fa163ec8ca8c:19 Other test cases showed little deviation, +/- 1, generally the same amount of backtracking. performance ~~~~~~~~~~~ Running Ubuntu's regression test suite resulted in no significant performance difference being observable. Before: 290s user time; 16.66% solver After: 299s user time; 17.36% solver Tests where run with make -j 8 and solver performance extracted perf report --symbol-filter=ResolveExternal --stdio
* Erased items do not exist anymoreJulian Andres Klode2026-01-312-11/+1
|
* solver3: Use LiftedBool for Obsolete stateJulian Andres Klode2026-01-312-7/+7
| | | | Quite a convenient way since we need exactly lifted bool semantics
* variants: Do not report unsupported variants in repositoriesJulian Andres Klode2026-01-231-2/+3
| | | | | We configure all variants the CPU supports as active, but repositories usually do not provide all of them, so let's not be noisy.
* why: Render info about all providers on virtual packagesJulian Andres Klode2026-01-201-13/+28
| | | | | | | | | | Refactor code into a doOne helper lambda, and then add loop over the providers to use it. This fixes a crash seen by Benjamin in a nice way than just failing :) Reported-by: Benjamin Drung
* solver3: Ensure rule-of-3 memory safety for ContiguousCacheMapJulian Andres Klode2026-01-051-0/+4
|
* solver3: Modernize std::find() to std::ranges::containsJulian Andres Klode2026-01-052-13/+10
| | | | Where applicable
* solver3: Add a strange assertionJulian Andres Klode2026-01-051-0/+2
| | | | I do not know why I don't hit this
* solver3: Remove Push() and refactor Solve()Julian Andres Klode2026-01-052-52/+24
| | | | | | | | | | | | | | | | | | | | | This method is no longer needed technically speaking, we should use Assume() instead. It turns out that there is a slight bug in the propagation and some clauses that are unit end up on the heap rather than having been propagated away, so we temporarily need to keep an if for that around. To accomodate the switch from Push() to Assume() we need to make sure that the work item is pushed to our trail *after* we have assumed it, such that reverting pushes it back to the work heap. Refactor the code to consistently use Assume() rather than supporting Enqueue(), this vastly simplifies things. This is not fully accurate in the current model and leads to unnecessary decision levels, since sometimes we seem to be reaching unit clauses here. This preserves traversal order by first removing the item from the heap and then adding it back if we need to solve it again.
* macros: Introduce must_succeed() macroJulian Andres Klode2026-01-051-0/+8
| | | | | This is like assert() but never compiled out so can be used with function calls that have side effects.
* solver3: Re-use existing error message code in Solve()Julian Andres Klode2026-01-051-7/+4
| | | | | We can just re-use Enqueue() here to produce our conflict message why am I being silly and duplicate this.
* solver3: Rename depth to levelJulian Andres Klode2026-01-052-23/+23
| | | | | Matches the rename of depth() to decisionLevel() at a shorter name.
* solver3: Rename decision to assignmentJulian Andres Klode2026-01-052-47/+46
| | | | | | | The previous use of decision here conflicted with the use of decision level and the general notion of having made a decision, because the assignment might have been propagated as a matter of fact.
* solver3: Reorder the source codeJulian Andres Klode2026-01-052-442/+438
| | | | | Move the DependencySolver methods and their helpers to the end of the file.
* solver3: Extract DependencySolverJulian Andres Klode2026-01-053-88/+116
| | | | Extract almost all dependency logic into a subclass
* solver3: Refactor to use a namespaceJulian Andres Klode2026-01-053-241/+239
| | | | | | | This removes the need for the forward references, thus fixing part of the libc++ issues pointed out in [merge-511]. [merge-511] https://salsa.debian.org/apt-team/apt/-/merge_requests/511/diffs
* solver3: Rename key concepts to MiniSAT namesJulian Andres Klode2026-01-052-55/+56
| | | | | This should make it easier for people with MiniSAT knowledge to onboard themselves to the solver.
* solver3: Rename Decision to LiftedBoolJulian Andres Klode2026-01-052-47/+47
| | | | | MUST becomes True, MUSTNOT becomes False, and NONE becomes Undefined.
* solver3: Implement value(Lit) and use itJulian Andres Klode2026-01-052-19/+41
|
* solver3: Refactor Assume(), Enqueue() from Var to LitJulian Andres Klode2026-01-052-25/+26
| | | | This simplifies the code _slightly_
* solver3: Introduce a Lit type to hold literalsJulian Andres Klode2026-01-051-0/+48
|
* weakptr: Simplify destructor to use range-based forJulian Andres Klode2025-11-101-3/+2
| | | | Explicit iterators considered harmful :)
* Correctly copy provided version in m-a lazy-initJulian Andres Klode2025-11-101-1/+1
| | | | | | | | When a provides was copied, we inadvertently copied the package version instead of the provided version. Copy the provided version instead. Closes: #1120463
* Revert "depcache: Allow changing multi-arch versions for removed siblings"Julian Andres Klode2025-10-261-4/+0
| | | | | | | | | | | | | | | | This reverts commit 74636b64a7ee56637a3ce4ddc1d060ca9f8b77e1. Adjust the test case accordingly, as it is no longer possible to install libgcc-s1:s390x. We need to sort this out in the ToDepCache translation layer at a later time. Sadly the depcache rejects valid solutions like this; solving this isn't trivial. Technically we need to split up the FromUser and auto-bit handling to solve this, but even then, MarkDelete() with FromUser=0 moves the auto-bit on metapackages; this doesn't happen when doing FromUser=1, so we can't always do FromUser=1. Fixes: a3fca052ca21ad222ac7f2fdd7f3fe84b44beb60
* solver3: Allow removing manually installed packagesJulian Andres Klode2025-10-251-1/+1
|
* solver3: Do not lose notion that we backtrackedJulian Andres Klode2025-10-252-1/+7
| | | | | | | | | Record a silly string if we backtracked such that we are aware of it. We need to handle this in a broader fashion, but this was at least breaking test-apt-never-markauto-sections with remove-manual LP: #2129819
* depcache: Allow changing multi-arch versions for removed siblingsJulian Andres Klode2025-10-251-0/+4
| | | | | Do not prevent us from changing the version of a foreign package because a sibling that is being removed has a different candidate.
* Implement architecture variantsJulian Andres Klode2025-10-2512-3/+242
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Architecture variants are children of an architecture that share the same ABI but are optimized for different ISA levels. They are available in Ubuntu 25.10 and newer, and not supported in Debian or other distributions. A deb built for a variant contains the Architecture-Variant field, and the Architecture field points to the baseline, for example: Architecture: amd64 Architecture-Variant: amd64v3 However, the apt-get indextargets command reports the variant in the Architecture: field, and most of the code in APT presents the variant as the architecture. There are two types of variants: 1. Standalone variants are recorded in the Architectures field of the Release file as if they were a real architecture: Architectures: amd64 amd64v3 Standalone architecture variants only fetch the standalone architecture variant's Packages file. To do this, this patch changes the code such that the variants indextargets "supplant" the base targets. This may have complicated outcomes on the apt-get indextargets command. 2. Other variants can only be identified by their files being recorded with hashes in the Release file. APT fetches both the base architecture's as well as the variant's Packages file. Variants are configured in the APT::Architecture-Variants list. Image builders may want to build specific variant images using APT::Architecture-Variants { "amd64v3"; } But this commit also implements an automatic discovery mechanism using the varianttable and /proc/cpuinfo. APT::Architecture-Variants "auto";
* Move split() to APT::String::Split()Julian Andres Klode2025-10-253-15/+14
| | | | This splits based upon contiguous whitespace as separators
* solver3: Eagerly satisfy previously satisfied RecommendsJulian Andres Klode2025-10-252-3/+9
| | | | | | | | | | | | | | | | | | When a user ran `apt install gpg`, the solver decided to remove `gnupg` and `seahorse` because `seahorse` was only pulled in as a Recommends of ubuntu-desktop and Recommends were resolved after all other dependencies. Solve this to most extent by introducing eager optionality: These dependencies, while they do not take part in classic unit propagation, are otherwise treated like hard dependencies and resolved as soon as possible rather than after any hard dependencies. This ensures that the Recommends of ubuntu-desktop on seahorse is retained correctly, and as a result, gnupg is updated to the latest version. Oops: 6c8e32eb-665d-11f0-a985-fa163ec8ca8c
* configuration: Add MoveSubTree with overwrite=falseJulian Andres Klode2025-10-252-3/+13
|