tech:notes_ipc
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| tech:notes_ipc [2025/03/24 15:06] – créée - modification externe 127.0.0.1 | tech:notes_ipc [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Notes IPC shared memory | ||
| + | |||
| + | Voir : | ||
| + | * http:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * `ipcrm` / `ipcmk` | ||
| + | |||
| + | |||
| + | Voir aussi : | ||
| + | * https:// | ||
| + | |||
| + | ~~~bash | ||
| + | #Total de la RAM | ||
| + | total=$(cat / | ||
| + | |||
| + | # 90% de la mémoire physique max | ||
| + | ratio=0.9 | ||
| + | |||
| + | # On applique le ratio et on converti en pages de 4096 | ||
| + | shmall=$(echo $total/ | ||
| + | shmmax=$(echo $total*$ratio | bc) | ||
| + | |||
| + | # On arrondi la valeur | ||
| + | shmall=$(echo $shmall | sed -e ' | ||
| + | shmmax=$(echo $shmmax | sed -e ' | ||
| + | |||
| + | echo $shmall > / | ||
| + | echo $shmmax > / | ||
| + | |||
| + | # ipcs -lm | ||
| + | ################# | ||
| + | |||
| + | |||
| + | ################# | ||
| + | # Overcommit memory ? | ||
| + | # sysctl -w vm.overcommit_memory=2 | ||
| + | |||
| + | # Page size ? | ||
| + | # getconf PAGE_SIZE | ||
| + | # cat / | ||
| + | ################# | ||
| + | |||
| + | #### SEMAPHORES | ||
| + | # http:// | ||
| + | # SEMMNS is the second parameter in output of cat / | ||
| + | # SEMMNI is the last parameter there, default value 128 - this is the limiting factor - SEMMNI must be at least at least ceil(max_connections / 16) | ||
| + | |||
| + | # http:// | ||
| + | # http:// | ||
| + | #### | ||
| + | ~~~ | ||
| + | |||
| + | Connaître la PAGE_SIZE \\ | ||
| + | Voir https:// | ||
| + | ~~~bash | ||
| + | getconf PAGE_SIZE | ||
| + | cat / | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | $ ipcs | ||
| + | |||
| + | ------ Message Queues -------- | ||
| + | key msqid owner perms used-bytes | ||
| + | |||
| + | ------ Shared Memory Segments -------- | ||
| + | key shmid owner perms bytes nattch | ||
| + | 0x0052e2c1 32768 postgres | ||
| + | 0x00000000 17924097 | ||
| + | 0x00000000 49446914 | ||
| + | [...] | ||
| + | |||
| + | $ ipcs -i 17924097 -m -p | ||
| + | |||
| + | Shared memory Segment shmid=17924097 | ||
| + | uid=1000 | ||
| + | mode=01600 | ||
| + | bytes=33554432 | ||
| + | att_time=Fri Jul 3 10:43:28 2015 | ||
| + | det_time=Fri Jul 3 10:43:28 2015 | ||
| + | change_time=Fri Jul 3 10:03:00 2015 | ||
| + | ~~~ | ||
| + | ## Debug | ||
| + | |||
| + | Source : http:// | ||
| + | |||
| + | The ipcs command provides information on interprocess communication facilities, including shared segments. Use the -m flag to obtain information about shared memory. For example, this code illustrates that one shared memory segment, numbered 1627649, is in use: | ||
| + | |||
| + | |||
| + | ~~~ | ||
| + | % ipcs -m | ||
| + | |||
| + | |||
| + | |||
| + | ------ Shared Memory Segments ------- | ||
| + | |||
| + | key | ||
| + | |||
| + | 0x00000000 1627649 | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | If this memory segment was erroneously left behind by a program, you can use the ipcrm command to remove it. | ||
| + | |||
| + | ~~~ | ||
| + | % ipcrm shm 1627649 | ||
| + | ~~~ | ||
| + | |||
| + | Periodically remove allocated semaphores which belong to the user running the plugin. This can be achieved like this (example for the user " | ||
| + | Source : http:// | ||
| + | ~~~bash | ||
| + | ipcrm $(ipcs -s | awk '/ | ||
| + | ~~~ | ||
| + | |||
