Skip to content

Commit 2c5f003

Browse files
dylwylieb-slim
authored andcommitted
Make lookup offheap buffer configurable (apache#5696)
* Make lookup offheap buffer configurable Fixes apache#3663 * Address comments * Update docs * Update docs
1 parent c2b5e5e commit 2c5f003

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

docs/content/development/extensions-core/lookups-cached-global.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,16 @@ setting namespaces (broker, peon, historical)
147147
|--------|-----------|-------|
148148
|`druid.lookup.namespace.cache.type`|Specifies the type of caching to be used by the namespaces. May be one of [`offHeap`, `onHeap`]. `offHeap` uses a temporary file for off-heap storage of the namespace (memory mapped files). `onHeap` stores all cache on the heap in standard java map types.|`onHeap`|
149149
|`druid.lookup.namespace.numExtractionThreads`|The number of threads in the thread pool dedicated for lookup extraction and updates. This number may need to be scaled up, if you have a lot of lookups and they take long time to extract, to avoid timeouts.|2|
150+
|`druid.lookup.namespace.numBufferedEntries`|If using offHeap caching, the number of records to be stored on an on-heap buffer.|100,000|
150151

151152
The cache is populated in different ways depending on the settings below. In general, most namespaces employ
152153
a `pollPeriod` at the end of which time they poll the remote resource of interest for updates.
153154

154155
`onHeap` uses `ConcurrentMap`s in the java heap, and thus affects garbage collection and heap sizing.
155-
`offHeap` uses a 10MB on-heap buffer and MapDB using memory-mapped files in the java temporary directory.
156-
So if total `cachedNamespace` lookup size is in excess of 10MB, the extra will be kept in memory as page cache, and paged in and out by general OS tunings.
156+
`offHeap` uses an on-heap buffer and MapDB using memory-mapped files in the java temporary directory.
157+
So if total number of entries in the `cachedNamespace` is in excess of the buffer's configured capacity, the extra will be kept in memory as page cache, and paged in and out by general OS tunings.
158+
It's highly recommended that `druid.lookup.namespace.numBufferedEntries` is set when using `offHeap`, the value should be chosen from the range between 10% and 50% of the number of entries in the lookup.
159+
157160

158161
# Supported Lookups
159162

extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/NamespaceExtractionConfig.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public class NamespaceExtractionConfig
3131
@JsonProperty
3232
private int numExtractionThreads = 2;
3333

34+
@JsonProperty
35+
private int numBufferedEntries = 100_000;
36+
3437
public int getNumExtractionThreads()
3538
{
3639
return numExtractionThreads;
@@ -40,4 +43,16 @@ public void setNumExtractionThreads(int numExtractionThreads)
4043
{
4144
this.numExtractionThreads = numExtractionThreads;
4245
}
46+
47+
public int getNumBufferedEntries()
48+
{
49+
return numBufferedEntries;
50+
}
51+
52+
public void setNumBufferedEntries(int numBufferedEntries)
53+
{
54+
this.numBufferedEntries = numBufferedEntries;
55+
}
56+
57+
4358
}

extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/cache/OffHeapNamespaceExtractionCacheManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public OffHeapNamespaceExtractionCacheManager(
156156
.asyncWriteEnable()
157157
.mmapFileEnable()
158158
.commitFileSyncDisable()
159-
.cacheSize(10_000_000)
159+
.cacheSize(config.getNumBufferedEntries())
160160
.make();
161161
try {
162162
lifecycle.addMaybeStartHandler(

0 commit comments

Comments
 (0)