make repodata_stringify return the result string
[platform/upstream/libsolv.git] / doc / libsolv-history.txt
1 Libsolv-History(3)
2 ==================
3 :man manual: LIBSOLV
4 :man source: libsolv
5
6 Name
7 ----
8 libsolv-history - how the libsolv library came into existence
9
10 History
11 -------
12 This project was started in May 2007 when the zypp folks decided to switch
13 to a database to speed up installation. As I am not a big fan of databases,
14 I (mls) wondered if there would be really some merit of using one for solving,
15 as package dependencies of all packages have to be read in anyway.
16
17 Back in 2002, I researched that using a dictionary approach for storing
18 dependencies can reduce the packages file to 1/3 of its size. Extending
19 this idea a bit more, I decided to store all strings and relations
20 as unique 32-bit numbers. This has three big advantages:
21
22 - because of the unification, testing whether two strings are equal is the
23   same as testing the equality of two numbers, thus very fast
24 - much space is saved, as numbers do not take up as much space as strings
25   the internal memory representation does not take more space on a
26   64-bit system where a pointer is twice the size of a 32-bit number
27
28 Thus, the solv format was created, which stores a repository as a string
29 dictionary, a relation dictionary and then all packages dependencies.
30 Tests showed that reading and merging multiple solv repositories takes
31 just some milliseconds.
32
33 === Early solver experiments ===
34 Having a new repository format was one big step, but the other area
35 where libzypp needed improvement was the solver. Libzypp's solver was
36 a port from the Red Carpet solver, which was written to update packages
37 in an already installed system. Using it for the complete installation
38 progress brought it to its limits. Also, the added extensions like
39 support for weak dependencies and patches made it fragile and
40 unpredictable.
41
42 As I was not very pleased with the way the solver worked, I looked at
43 other solver algorithms. I checked smart, yum and apt, but could not
44 find a convincing algorithm. My own experiments also were not very
45 convincing, they worked fine for some problems but failed miserably
46 for other corner cases.
47
48 === Using SAT for solving ===
49 SUSE's hack week at the end of June 2007 turned out to be a turning point
50 for the solver. Googling for solver algorithms, I stumbled over some note
51 saying that some people are trying to use SAT algorithms to improve
52 solving on Debian. Looking at the SAT entry in Wikipedia, it was easy
53 to see that this indeed was the missing piece: SAT algorithms are well
54 researched and there are quite some open source implementations.
55 I decided to look at the minisat code, as it is one of the fastest
56 solvers while consisting of too many lines of code.
57
58 Of course, directly using minisat would not work, as a package solver
59 does not need to find just one correct solution, but it also has to
60 optimize some metrics, i.e. keep as many packages installed as possible.
61 Thus, I needed to write my own solver incorporation the ideas and
62 algorithms used in minisat. This wasn't very hard, and at the end of
63 the hack week the solver calculated the first right solutions.
64
65 === Selling it to libzypp ===
66 With those encouraging results, I went to Klaus Kaempf, the system
67 management architect at SUSE. We spoke about how to convince the
68 team to make libzypp switch to the new solver. Fortunately, libzypp comes
69 with a plethora of solver test cases, so we decided to make the solver pass
70 most of the test cases first. Klaus wrote a "deptestomatic" implementation
71 to check the test cases. Together with Stephan Kulow, who is responsible for the
72 openSUSE distribution, we tweaked and extended the solver until most of
73 the test cases looked good.
74
75 Duncan Mac-Vicar Prett, the team lead of the YaST team, also joined
76 development by creating Ruby bindings for the solver. Later, Klaus
77 improved the bindings and ported them to some other languages.
78
79 === The attribute store ===
80 The progress with the repository format and the solver attracted another
81 hacker to the project: Michael Matz from the compiler team. He started
82 with improving the repository parsers so that patches and content files
83 also generate solvables. After that, he concentrated on storing all
84 of the other metadata of the repositories that are not used for solving,
85 like the package summaries and descriptions. At the end of October, a first
86 version of this "attribute store" was checked in. Its design goals were:
87
88 - space efficient storage of attributes
89 - paging/on demand loading of data
90 - page compression
91
92 The first version of the attribute store used a different format for
93 storing information, we later merged this format with the solv file
94 format.
95
96 === libzypp integration ===
97 Integration of the sat-solver into libzypp also started in October 2007 by
98 Stefan Schubert and Michael Andres from the YaST team. The first
99 versions supported both the old solver and the new one by using the
100 old repository read functions and converting the old package data
101 in-memory into a sat solver pool. Solvers could be switched with
102 the environment variable ZYPP_SAT_SOLVER. The final decision to
103 move to the new solver was made in January of 2008, first just by
104 making the new solver the default one, later by completely throwing out
105 the old solver code. This had the advantage that the internal solvable
106 storage could also be done by using the solver pool, something Michael
107 Matz already played with in a proof of concept implementation showing
108 some drastic speed gains. The last traces of the old database code
109 were removed in February.
110
111 Author
112 ------
113 Michael Schroeder <mls@suse.de>