Fast dB has been used in recent projects. To improve access efficiency, fast dB adopts the diskless mode for compilation.
The maximum size of shared memory is limited by system parameters,
The following data is the default value in Linux im_monitor 2.6.9-42. elsmp:
CAT/proc/sys/kernel/shmmax
33554432
The default size is 32 MB;
In fastdbCode32 m is also used as the capacity limit. Once the capacity exceeds the threshold, expansion will not be performed; the process will exit;
The specific code line is in the INC/database. h file.
# Ifdef diskless_configuration
// In diskless confiuration database can not be reallocated
Const size_t dbdefaultinitdatabasesize = 32*1024*1024;
# Else
Const size_t dbdefaultinitdatabasesize = 1024*1024;
# Endif
To support fastdb to work in larger shared memory, you need to make two changes:
1. Modify system parameters
Modify/etc/sysctl. cfg and add the following content:
Kernel. shmmni = 4096
Kernel. Shmall = 2097152
Kernel. shmmax = 1073741824
Run sysctl-P;
Or echo 1073741824>/proc/sys/kernel/shmmax. Be sure to add it to the startup script;
2. Modify fastdbSource code
Const size_t dbdefaultinitdatabasesize = 32*1024*1024; change to an appropriate value, for example, 32-> 1024
In view of the size limit of shared memory and the inability to dynamically scale up: when the capacity limit is exceeded, the process cannot be reassigned and exited directly. For large-capacity systems, fastdb data exceeds 2 GB, or the Total virtual memory usage may be close to 3 GB. Therefore, we do not recommend using the shared memory fastdb in a 32-bit operating system. You can use the File mode instead, it is also implemented through MMAP. Writing Io is basically equivalent to memory efficiency and can be expanded based on pre-allocation.