Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar
[simgrid.git] / doc / doxygen / community.doc
1 /**
2 @page community The SimGrid Community
3
4 @tableofcontents
5
6 SimGrid is a free software, written by a community of people. It
7 started as a little software to help ourselves in our own research,
8 and as more people put their input into the pot, it turned into
9 something that we hope to be valuable to many people. So yes. We hope
10 that SimGrid is helping you doing what you want, and that you will
11 join our community of happy simgriders.
12
13 @section community_contact Contacting the community
14
15 There are several locations where you can connect and discuss about
16 SimGrid. If you have a question, please have a look at the
17 documentation and examples first, but if some remain don't hesitate to
18 ask the community for help. If you do not have a question, just come to us
19 and say hello! We love earing about how people use SimGrid.
20
21  - For questions or remarks, drop us an email on the 
22    <a href="mailto:simgrid-user@lists.gforge.inria.fr">User Mailing list</a> (to subscribe, visit the [webinterface](http://lists.gforge.inria.fr/mailman/listinfo/simgrid-user));
23    you can also check out [our archives](http://lists.gforge.inria.fr/pipermail/simgrid-user/).
24    We prefer you to <b>not use private emails</b>. SimGrid is an open
25    framework, and you never know who have the time and knowledge to
26    answer your question, so please keep messages on the public mailing list.
27  - Join us on IRC and ask your question directly on the channel \#simgrid at
28    \b irc.debian.org. Be warned that even if many people are connected to
29    the chanel, they may not be staring at their IRC windows.
30    So don't be surprised if you don't get an answer in the 
31    second, and turn to the mailing lists if nobody seems to be there.
32  - Asking your question on [StackOverflow](http://stackoverflow.com/questions/tagged/simgrid) is also a good idea, as this
33    site is very well indexed. We answer questions there too (don't
34    forget to use the SimGrid tag in your question so that we can see
35    it), and they remain usable for the next users. 
36
37 @section community_giveback Giving back to SimGrid
38
39 We are sometimes asked by users how to give back to the project. Here
40 are some ideas, but if you have new ones, feel free to share them with us.
41
42 @subsection contributing_spread Spread the word
43
44 There are many ways to help the SimGrid project. The first and most
45 natural one is to <b>use it for your research, and say so</b>. Cite
46 the SimGrid framework in your papers and discuss of its advantages with
47 your colleagues to spread the word. When we ask for new fundings to
48 sustain the project, the amount of publications enabled by SimGrid is
49 always the first question we get. The more you use the framework,
50 the better for us. 
51
52 Make sure that your scientific publications using SimGrid actually
53 cite the <a href="http://simgrid.gforge.inria.fr/Publications.html">right paper</a>.
54 Also make sure that these citations are correctly listed on 
55 <a href="http://simgrid.gforge.inria.fr/Usages.html">our list</a>.
56
57 You can also <b>help us constituting an active and welcoming user
58 community</b>. Subscribe to the mailing lists, and answer the
59 questions that newscomers have if you can. Point them (gently ;) to
60 the relevant part of the documentation on need, and help them becoming
61 part of our community too. 
62
63 Another easy way to help the project is to add a link to the <a
64 href="http://simgrid.gforge.inria.fr">SimGrid homepage</a> on your
65 site to <b>improve SimGrid's ranking in search engines</b>.
66
67 Finally, if you organize a scientific event where you expect many
68 potential users, <b>you can invite us to give a tutorial on SimGrid</b>. We
69 found that 45 minutes to one hour is very sharp, but doable. It
70 allows us to explain the main motivations and outcomes of the project in
71 order to motivate the attendees get more information on SimGrid, and
72 eventually improve their scientific habits by using a sound simulation
73 framework.  
74 <a href="http://webloria.loria.fr/~quinson/blog/2012/1120/Simgrid_at_Louvain/">Here</a>
75 is an example of such a presentation.
76
77 @subsection contributing_bugs Reporting (and fixing) any issue you find
78
79 Because of its size and complexity, SimGrid is not perfect and
80 contains a large amount of glitches and issues. When you find one,
81 don't assume that it's here because we don't care. It survived only
82 because nobody told us. We unfortunately cannot endlessly review our
83 large code and documentation base. So please, <b>report any issue you
84 find</b>, be it a typo in the documentation, a paragraph that needs to
85 be reworded, a bug in the code, or any other problem. The best way to
86 do so is to open an issue on our GitHub's 
87 <a href="https://github.com/simgrid/simgrid/issues">Bug Tracker</a> so
88 that we don't forget about it (if you want to put some attachment, you
89 can use 
90 <a https://gforge.inria.fr/tracker/?atid=165&group_id=12&func=browse">this
91 other bugtracker</a> instead). 
92
93 The worst way to report such issues is to go through private emails.
94 These are unreliable, and we are trying to develop SimGrid openly, so
95 private discussions are to be avoided if possible. 
96
97 If you can provide a patch fixing the issue you report, that's even
98 better. If you cannot, then you need to give us a minimal working
99 example (MWE), that is a ready to use solution that reproduces the
100 problem you face. Your bug will take much more time
101 for us to reproduce and fix if you don't give us the MWE, so you want
102 to help us helping you to get things efficient.
103
104 Of course, a very good way to give back to the SimGrid community is to
105 <b>triage and fix the bugs in the Bug Tracking Systems</b>. If you
106 can come up with a patch fixing them, we will be more than happy to
107 apply your changes so that the whole community enjoys them.
108
109 @section community_extend Extending SimGrid and its Ecosystem
110
111 @subsection contributing_contrib Contributing features and associated tools
112
113 If you deeply miss a feature in the framework, you should consider
114 implementing it yourself. SimGrid is free software, meaning that you are
115 free to help yourself. Of course, we'll do our best to assist you in
116 this task, so don't hesitate to contact us with your idea.
117
118 You could write a new plugin extending SimGrid in some way, or a
119 routing model for another kind of network. But even if you write your own
120 platform file, this is probably interesting to other users too, and
121 could be included to SimGrid. Modeling accurately a given platform is
122 a difficult work, which outcome is very precious to us.
123
124 Or maybe you developed an independent tool on top of SimGrid. We'd
125 love helping you gaining visibility by listing it in our 
126 <a href="http://simgrid.gforge.inria.fr/contrib.html">Contrib
127 section</a>. 
128
129 @subsection contributing_todo Possible Enhancements
130
131 If you want to start working on the SimGrid codebase, here are a few
132 ideas of things that could be done to improve the current code (not all of them
133 are difficult, do trust yourself ;)
134
135 @subsubsection contributing_todo_cxxification Migration to C++
136
137 The code is being migrated to C++ but a large part is still C (or C++ with
138 C idioms). It would be valuable to replace C idioms with C++ ones:
139
140  - replace XBT structures and C dynamic arrays with C++ containers;
141
142  - replace `char*` strings with `std::string`;
143
144  - use exception-safe RAII (`std::unique_ptr`, etc.) instead of explicit
145    `malloc/free` or `new/delete`;
146
147  - use `std::function` (or template functionoid arguments) instead of function
148    pointers;
149
150 #### Exceptions
151
152 SimGrid used to implement exceptions in C. This has been replaced with C++
153 exceptions but some bits of the C exceptions are still remaining:
154
155  - `xbt_ex` was the type of C exceptions. It is now a standard C++ exception.
156     We might want to remove this exception and use a more idiomatic C++
157     solution with dedicated exception classes for different errors.
158     `std::system_error` might be used as well by replacing some `xbt_errcat_t`
159     with custom subclasses of `std::error_category`.
160
161  - The C API currently throws exceptions. Throwing exceptions out of a C API is
162    not very friendly. C code does not expect them, cannot catch them and cannot
163    handle resource management properly in face of exceptions. We should clearly
164    separate the C++ API and the C API and catch all exceptions before they get
165    ouf of C APIs.
166
167 #### Time and duration
168
169 Some support for C++11-style time/duration is implemented (see `chrono.hpp`)
170 but only available in some (S4U) APIs. It would be nice to add support for
171 them in the rest of the C++ code.
172
173 A related change would be to avoid using "-1" to mean "forever" at least in S4U
174 and in the internal code. For compatibility, MSG should probably keep this
175 semantic. We should probably always use separate functions
176 (`wait` vs `wait_for`).
177
178 #### Futures and Promises
179
180  - Some features are missing in the Maestro future implementation
181   (`simgrid::kernel::Future`, `simgrid::kernel::Promise`)
182   could be extended to support additional features:
183   `when_any`, `shared_future`, etc.
184
185  - The corresponding feature might then be implemented in the user process
186    futures (`simgrid::simix::Future`).
187
188  - Currently `.then()` is not available for user futures. We would need to add
189    a basic user event loop in order to queue the pending continuations.
190
191  - We might need to provide an option to cancel a pending operation. This
192    might be achieved by defining some `Action` or `Operation` class with an
193    API compatible with `Future` (and convertible to it) but with an
194    additional `.cancel()` method.
195
196 @subsubsection contributing_todo_smpi SMPI
197
198 #### Process-based privatization
199
200 Currently, all the simulated processes live in the same process as the SimGrid
201 simulator. The benefit is that we don't have to do context switches and IPC
202 between the simulator and the processes.
203
204 The fact that they share the same address space means that one memory corruption
205 in one simulated process can propagate to the other ones and to the SimGrid
206 simulator itself.
207
208 Moreover, the current design for SMPI applications is to compile the MPI code
209 normally and execute it once per simulated process in the same system process:
210 This means that all the existing simulated MPI processes share the same virtual
211 address space and share by default the same global variables. This is not
212 correct as each MPI process is expected to use its own address space and have
213 its own global variables. In order to fix, this problem we have an optional
214 SMPI privatization feature which creates an instanciation of the executable
215 data segment per MPI process and map the correct one (using `mmap`) at each
216 context switch.
217
218 This approach has many problems:
219
220  1. It is not completely safe. We only handle SMPI privatization for the global
221     variables in the execute data segment. Shared objects are ignored but some
222     may contain global variables which may need to be privatized:
223
224     - libsimgrid for example must not be privatized because it contains
225       shared state for the simulator;
226
227     - libc must not be privatized for the same reason (but some global variables
228       in the libc may not be privatized);
229
230     - if we use global variables of some shared object in the executable, this
231       global variable will be instanciated in the executable (because of copy
232       relocation) and will be privatized even if it shoud not.
233
234  2. We cannot execute the MPI processes in parallel. Only one can execute at
235     the same time because only one privatization segment can be mapped at a
236     given time.
237
238 In order to fix this, the standard solution is to move each MPI process in its
239 own system process and use IPC to communicate with the simulator. One concern would
240 be the impact on performance and memory consumption:
241
242  - It would introduce a lot of context switches and IPC communications between
243    the MPI processes and the SimGrid simulator. However, currently every context
244    switch needs a `mmap` for SMPI privatization which is costly as well
245    (TLB flush).
246
247  - Instanciating a lot of processes might consume more memory which might be a
248    problem if we want to simulate a lot of MPI processes. Compiling MPI programs
249    as static executables with a lightweight libc might help and we might want to
250    support that. The SMPI processes should probably not embed all the SimGrid
251    simulator and its dependencies, the C++ runtime, etc.
252
253 We would need to modify the model-checker as well which currently can only
254 manage on model-checked process. For the model-checker we can expect some
255 benefits from this approach: if a process did not execute, we know its state
256 did not change and we don't need to take its snapshot and compare its state.
257
258 Other solutions for this might include:
259
260  - Mapping each MPI process in the process of the simulator but in a different
261    symbol namespace (see `dlmopen`). Each process would have its own separate
262    instanciation and would not share libraries.
263
264  - Instanciate each MPI process in a separate lightweight VM (for example based
265    on WebAssembly) in the simualtor process.
266
267 @subsubsection contributing_todo_mc Model-checker
268
269 #### Overhaul the state comparison code
270
271 The state comparison code is quite complicated. It has very long functions and
272 is programmed mostly using C idioms and is difficult to understand and debug.
273 It is in need of an overhaul:
274
275   - cleanup, refactoring, usage of C++ features.
276
277   - The state comparison code works by infering types of blocks allocated on the
278     heap by following pointers from known roots (global variables, local
279     variables). Usually the first type found for a given block is used even if
280     a better one could be found later. By using a first pass of type inference,
281     on each snapshot before comparing the states, we might use a better type
282     information on the different blocks.
283
284   - We might benefit from adding logic for handling some known types. For
285     example, both `std::string` and `std::vector` have a capacity which might
286     be larger than the current size of the container. We should ignore
287     the corresponding elements when comparing the states and infering the types.
288
289   - Another difficulty in the state comparison code is the detection of
290     dangling pointers. We cannot easily know if a pointer is dangling and
291     dangling pointers might lead us to choose the wrong type when infering
292     heap blocks. We might mitigate this problem by delaying the reallocation of
293     a freed block until there is no blocks pointing to it anymore using some
294     sort of basic garbage-collector.
295
296 #### Hashing the states
297
298 In order to speed up the state comparison an idea was to create a hash of the
299 state. Only states with the same hash would need to be compared using the
300 state comparison algorithm. Some information should not be inclueded in the
301 hash in order to avoid considering different states which would otherwise
302 would have been considered equal.
303
304 The states could be indexed by their hash. Currently they are indexed
305 by the number of processes and the amount of heap currently allocated
306 (see `DerefAndCompareByNbProcessesAndUsedHeap`).
307
308 Good candidate informations for the state hashing:
309
310  - number of processes;
311
312  - their backtraces (instruction addresses);
313
314  - their current simcall numbers;
315
316  - some simcall arguments (eg. number of elements in a waitany);
317
318  - number of pending communications;
319
320  - etc.
321
322 Some basic infrastructure for this is already in the code (see `mc_hash.cpp`)
323 but it is currently disabled.
324
325 #### Separate the model-checker code from libsimgrid
326
327 #### Interface with the model-checked processes
328
329 The model-checker reads many information about the model-checked process
330 by `process_vm_readv()`-ing brutally the data structure of the model-checked
331 process leading to some horrible code such as walking a swag from another
332 process. It prevents us as well from replacing some XBT data structures with
333 standard C++ ones. We need a sane way to expose the relevant information to
334 the model-checker.
335
336 #### Generic simcalls
337
338 We have introduced some generic simcalls which can be used to execute a
339 callback in SimGrid Maestro context. It makes it a lot easier to interface
340 the simulated process with the maestro. However, the callbacks for the
341 model-checker which cannot decide how it should handle them. We would need a
342 solution for this if we want to be able to replace the simcalls the
343 model-checker cares about by generic simcalls.
344
345 #### Defining an API for writing Model-Checking algorithms
346
347 Currently, writing a new model-checking algorithms in SimGridMC is quite
348 difficult: the logic of the model-checking algorithm is mixed with a lot of
349 low-level concerns about the way the model-checker is implemented. This makes it
350 difficult to write new algorithms and difficult to understand, debug, and modify
351 the existing ones. We need a clean API to express the model-checking algorithms
352 in a form which is closer to the text-book/paper description. This API must
353 be exposed in a a language which is more adequate to this task.
354
355 Tasks:
356
357   1. Design and implement a clean API to express model-checking algorithms.
358      A `Session` class currently exists for this but is not feature complete
359      and should probably be rewritten. It should be easy to create bindings
360      for different languages on top of this API.
361
362   2. Create a binding to some better suited, dynamic, scripting language
363      (e.g., Lua).
364
365   3. Rewrite the existing model-checking algorithms in this language using the
366      new API.
367
368 */