Logo AND Algorithmique Numérique Distribuée

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