@@ -64,15 +64,19 @@ public final class FlatStoreOptions extends Table {
64
64
*/
65
65
public long fileMode () { int o = __offset (10 ); return o != 0 ? (long )bb .getInt (o + bb_pos ) & 0xFFFFFFFFL : 0L ; }
66
66
/**
67
- * The maximum number of readers.
67
+ * The maximum number of readers (related to read transactions) .
68
68
* "Readers" are an finite resource for which we need to define a maximum number upfront.
69
69
* The default value is enough for most apps and usually you can ignore it completely.
70
70
* However, if you get the OBX_ERROR_MAX_READERS_EXCEEDED error, you should verify your
71
71
* threading. For each thread, ObjectBox uses multiple readers. Their number (per thread) depends
72
72
* on number of types, relations, and usage patterns. Thus, if you are working with many threads
73
73
* (e.g. in a server-like scenario), it can make sense to increase the maximum number of readers.
74
- * Note: The internal default is currently around 120.
75
- * So when hitting this limit, try values around 200-500.
74
+ *
75
+ * Note: The internal default is currently 126. So when hitting this limit, try value s around 200-500.
76
+ *
77
+ * Note: Each thread that performed a read transaction and is still alive holds on to a reader slot.
78
+ * These slots only get vacated when the thread ends. Thus be mindful with the number of active threads.
79
+ * Alternatively, you can opt to try the experimental noReaderThreadLocals option flag.
76
80
*/
77
81
public long maxReaders () { int o = __offset (12 ); return o != 0 ? (long )bb .getInt (o + bb_pos ) & 0xFFFFFFFFL : 0L ; }
78
82
/**
@@ -123,6 +127,14 @@ public final class FlatStoreOptions extends Table {
123
127
* For debugging purposes you may want enable specific logging.
124
128
*/
125
129
public long debugFlags () { int o = __offset (28 ); return o != 0 ? (long )bb .getInt (o + bb_pos ) & 0xFFFFFFFFL : 0L ; }
130
+ /**
131
+ * Disables the usage of thread locals for "readers" related to read transactions.
132
+ * This can make sense if you are using a lot of threads that are kept alive.
133
+ *
134
+ * Note: This is still experimental, as it comes with subtle behavior changes at a low level and may affect
135
+ * corner cases with e.g. transactions, which may not be fully tested at the moment.
136
+ */
137
+ public boolean noReaderThreadLocals () { int o = __offset (30 ); return o != 0 ? 0 !=bb .get (o + bb_pos ) : false ; }
126
138
127
139
public static int createFlatStoreOptions (FlatBufferBuilder builder ,
128
140
int directoryPathOffset ,
@@ -137,8 +149,9 @@ public static int createFlatStoreOptions(FlatBufferBuilder builder,
137
149
boolean usePreviousCommit ,
138
150
boolean usePreviousCommitOnValidationFailure ,
139
151
boolean readOnly ,
140
- long debugFlags ) {
141
- builder .startTable (13 );
152
+ long debugFlags ,
153
+ boolean noReaderThreadLocals ) {
154
+ builder .startTable (14 );
142
155
FlatStoreOptions .addValidateOnOpenPageLimit (builder , validateOnOpenPageLimit );
143
156
FlatStoreOptions .addMaxDbSizeInKByte (builder , maxDbSizeInKByte );
144
157
FlatStoreOptions .addDebugFlags (builder , debugFlags );
@@ -148,14 +161,15 @@ public static int createFlatStoreOptions(FlatBufferBuilder builder,
148
161
FlatStoreOptions .addDirectoryPath (builder , directoryPathOffset );
149
162
FlatStoreOptions .addPutPaddingMode (builder , putPaddingMode );
150
163
FlatStoreOptions .addValidateOnOpen (builder , validateOnOpen );
164
+ FlatStoreOptions .addNoReaderThreadLocals (builder , noReaderThreadLocals );
151
165
FlatStoreOptions .addReadOnly (builder , readOnly );
152
166
FlatStoreOptions .addUsePreviousCommitOnValidationFailure (builder , usePreviousCommitOnValidationFailure );
153
167
FlatStoreOptions .addUsePreviousCommit (builder , usePreviousCommit );
154
168
FlatStoreOptions .addSkipReadSchema (builder , skipReadSchema );
155
169
return FlatStoreOptions .endFlatStoreOptions (builder );
156
170
}
157
171
158
- public static void startFlatStoreOptions (FlatBufferBuilder builder ) { builder .startTable (13 ); }
172
+ public static void startFlatStoreOptions (FlatBufferBuilder builder ) { builder .startTable (14 ); }
159
173
public static void addDirectoryPath (FlatBufferBuilder builder , int directoryPathOffset ) { builder .addOffset (0 , directoryPathOffset , 0 ); }
160
174
public static void addModelBytes (FlatBufferBuilder builder , int modelBytesOffset ) { builder .addOffset (1 , modelBytesOffset , 0 ); }
161
175
public static int createModelBytesVector (FlatBufferBuilder builder , byte [] data ) { return builder .createByteVector (data ); }
@@ -172,6 +186,7 @@ public static int createFlatStoreOptions(FlatBufferBuilder builder,
172
186
public static void addUsePreviousCommitOnValidationFailure (FlatBufferBuilder builder , boolean usePreviousCommitOnValidationFailure ) { builder .addBoolean (10 , usePreviousCommitOnValidationFailure , false ); }
173
187
public static void addReadOnly (FlatBufferBuilder builder , boolean readOnly ) { builder .addBoolean (11 , readOnly , false ); }
174
188
public static void addDebugFlags (FlatBufferBuilder builder , long debugFlags ) { builder .addInt (12 , (int ) debugFlags , (int ) 0L ); }
189
+ public static void addNoReaderThreadLocals (FlatBufferBuilder builder , boolean noReaderThreadLocals ) { builder .addBoolean (13 , noReaderThreadLocals , false ); }
175
190
public static int endFlatStoreOptions (FlatBufferBuilder builder ) {
176
191
int o = builder .endTable ();
177
192
return o ;
0 commit comments