|
1 | 1 | namespace LightningDB; |
2 | 2 |
|
3 | 3 | /// <summary> |
4 | | -/// Basic environment configuration |
| 4 | +/// Represents the configuration options for a LightningEnvironment instance. |
5 | 5 | /// </summary> |
| 6 | +/// <remarks> |
| 7 | +/// This class enables customization of various environment parameters such as the size of the memory map, |
| 8 | +/// the maximum number of databases, and the maximum number of reader slots. These configurations are applied |
| 9 | +/// to a LightningEnvironment during its creation or initialization. |
| 10 | +/// </remarks> |
6 | 11 | public class EnvironmentConfiguration |
7 | 12 | { |
8 | 13 | private long? _mapSize; |
9 | 14 | private int? _maxReaders; |
10 | 15 | private int? _maxDatabases; |
11 | | - |
| 16 | + |
| 17 | + /// <summary> |
| 18 | + /// Gets or sets the size of the memory map (in bytes) for a LightningEnvironment. |
| 19 | + /// </summary> |
| 20 | + /// <remarks> |
| 21 | + /// This property specifies the maximum size of the database file that can be mapped into memory. Adjusting this value |
| 22 | + /// is critical when working with databases expected to grow over time, as it defines the capacity available for storing data. |
| 23 | + /// - Increasing the map size allows the database to accommodate more data, but it may consume more virtual memory. |
| 24 | + /// - Decreasing the map size can restrict database growth or limit memory consumption. |
| 25 | + /// Changes to the <c>MapSize</c> might require restarting the environment or re-creating it with the new configuration, |
| 26 | + /// depending on the implementation of the underlying storage environment. |
| 27 | + /// Use caution when setting this value in applications running in 32-bit processes, as the effective addressable memory |
| 28 | + /// space is limited. For such scenarios, auto-adjustments may be applied to ensure compatibility. |
| 29 | + /// </remarks> |
12 | 30 | public long MapSize |
13 | 31 | { |
14 | 32 | get => _mapSize ?? 0; |
15 | 33 | set => _mapSize = value; |
16 | 34 | } |
17 | 35 |
|
| 36 | + /// <summary> |
| 37 | + /// Gets or sets the maximum number of reader slots available for a LightningEnvironment instance. |
| 38 | + /// </summary> |
| 39 | + /// <remarks> |
| 40 | + /// This property defines the maximum number of simultaneous read transactions that can be performed on the environment. |
| 41 | + /// - Increasing the value allows for more concurrent read operations, but it may increase resource usage. |
| 42 | + /// - Decreasing the value limits the number of concurrent reads but may reduce memory consumption. |
| 43 | + /// Changes to the <c>MaxReaders</c> property must be set before the environment is opened. Attempting to modify this |
| 44 | + /// property after the environment is already initialized will result in an exception. Adjust this parameter to match |
| 45 | + /// the requirements of your application's workload and concurrency needs. |
| 46 | + /// </remarks> |
18 | 47 | public int MaxReaders |
19 | 48 | { |
20 | 49 | get => _maxReaders ?? 0; |
21 | 50 | set => _maxReaders = value; |
22 | 51 | } |
23 | 52 |
|
| 53 | + /// <summary> |
| 54 | + /// Gets or sets the maximum number of databases that can be opened within a LightningEnvironment instance. |
| 55 | + /// </summary> |
| 56 | + /// <remarks> |
| 57 | + /// This property defines the upper limit on the number of named databases that can be created or opened within the environment. |
| 58 | + /// - Increasing the maximum database count may allow complex applications to organize data across multiple logical databases. |
| 59 | + /// - Decreasing the maximum database count can help reduce overhead in environments with constrained resources or simpler use cases. |
| 60 | + /// Changes to the <c>MaxDatabases</c> property must be configured before the environment is opened. Attempting to modify this |
| 61 | + /// value after the environment has been initialized will result in an exception. This limitation ensures consistency across |
| 62 | + /// resources allocated for the environment. |
| 63 | + /// Configuring the appropriate <c>MaxDatabases</c> value is particularly relevant for applications requiring concurrency or |
| 64 | + /// multiple named databases. |
| 65 | + /// </remarks> |
24 | 66 | public int MaxDatabases |
25 | 67 | { |
26 | 68 | get => _maxDatabases ?? 0; |
27 | 69 | set => _maxDatabases = value; |
28 | 70 | } |
29 | 71 |
|
| 72 | + /// <summary> |
| 73 | + /// Gets or sets a value indicating whether the map size should be automatically reduced |
| 74 | + /// in 32-bit processes to ensure compatibility with limited addressable memory space. |
| 75 | + /// </summary> |
| 76 | + /// <remarks> |
| 77 | + /// In 32-bit processes, the addressable memory space is constrained, which may lead to issues |
| 78 | + /// when working with large map sizes. When this property is set to <c>true</c>, the environment |
| 79 | + /// will automatically adjust the map size to a suitable value (e.g., <c>int.MaxValue</c>) during |
| 80 | + /// configuration to prevent memory allocation errors or crashes. This adjustment is only applied |
| 81 | + /// on 32-bit systems and has no effect on 64-bit processes. |
| 82 | + /// This setting is critical for maintaining stability in environments with constrained memory |
| 83 | + /// while allowing applications to utilize an appropriate map size without manual intervention. |
| 84 | + /// </remarks> |
30 | 85 | public bool AutoReduceMapSizeIn32BitProcess { get; set; } |
31 | 86 |
|
32 | 87 | internal void Configure(LightningEnvironment env) |
|
0 commit comments