JVM tuning

This guide covers JVM configuration for Deephaven services and workers, including garbage collection, heap sizing, and performance-related flags.

Note

For adjusting heap size for individual PQs, see Memory tuning FAQ. For the Deephaven memory model, data buffer pool configuration, and understanding what drives memory usage, see Memory management.

Overview

Deephaven runs multiple Java processes with different configuration methods:

Process typeExamplesConfiguration method
ServicesDIS, merge, controller, TDCPHostconfig file
WorkersPQ workers, consolesProcessing profiles

Heap sizing

Service heap configuration

Configure service heap sizes in the hostconfig file (/etc/sysconfig/illumon) using EXTRA_ARGS:

See Java process launch configuration for details on hostconfig syntax.

Worker heap configuration

Worker -Xmx is determined by the heap size configured per Persistent Query or console. Remote processing profiles can configure -Xms (initial heap) — see Setting -Xms for workers.

Garbage collection

GC profiles

Deephaven provides built-in GC profiles via remote processing profiles:

ProfileGC typeBest forJava version
G1 GCGarbage FirstMost workloadsJava 11+ (recommended)
CMS GCConcurrent Mark SweepLegacyJava 8 only
G1 MarkStackSize 128MG1 with larger mark stackComplex queries with allocation failuresJava 11+

Set default profile:

G1 GC tuning

G1 GC is recommended for Java 11+ deployments.

Key parameters:

ParameterPurposeNotes
-XX:MaxGCPauseMillisTarget max pause timeDefault: 200ms; tune based on workload
-XX:ParallelGCThreadsThreads for STW phasesTune based on available cores
-XX:ConcGCThreadsConcurrent marking threadsTune based on GC behavior
-XX:G1HeapRegionSizeHeap region sizeAuto-selected; rarely needs tuning
-XX:InitiatingHeapOccupancyPercentWhen to start markingDefault: 45

Custom G1 profile example:

GC logging

Enable GC logging to diagnose performance issues.

Java 11+ (Unified Logging):

The -Xlog format is what:output:decorators:output-options:

  • gc* — Log all GC-related messages
  • file=...gc_%p.log — Write to file (%p = process ID)
  • time,uptime,level,tags — Include timestamps and log level
  • filecount=5,filesize=100m — Rotate across 5 files, 100 MB each

Analyze GC logs:

  • GCViewer: Open source tool for visualizing GC logs
  • GCEasy: Online GC log analyzer
  • Look for: full GC frequency, pause times, heap after GC

Common JVM flags

Memory flags

FlagPurposeExample
-XmxMaximum heap-Xmx32g
-XmsInitial heap-Xms32g
-XX:MaxDirectMemorySizeDirect memory limit-XX:MaxDirectMemorySize=16g
-XX:MaxMetaspaceSizeMetaspace limit-XX:MaxMetaspaceSize=512m

Performance flags

FlagPurposeExample
-XX:+AlwaysPreTouchPre-touch heap pagesReduces startup variance
-XX:+UseStringDeduplicationDeduplicate stringsSaves memory
-XX:CICompilerCountJIT compiler threads2-4

Diagnostic flags

FlagPurposeExample
-XX:+HeapDumpOnOutOfMemoryErrorDump heap on OOMAlways enable
-XX:HeapDumpPathHeap dump location/tmp/heapdump.hprof
-XX:+PrintFlagsFinalPrint all JVM flagsFor debugging

Example diagnostic profile:

Troubleshooting

Out of memory errors

Heap space:

Causes and solutions:

CauseCheckSolution
Heap too smallHeap usage near maxIncrease -Xmx
Memory leakHeap dump analysisFix leak, restart
Large data setsQuery analysisOptimize queries

Direct buffer memory

Solution: Increase -XX:MaxDirectMemorySize.

Long GC pauses

Symptoms:

  • UI freezes
  • Query timeouts
  • Log shows long pause times

Solutions:

CauseCheckSolution
Heap too largePause times in logsReduce heap or tune G1
Full GCsGC log analysisIncrease heap, reduce allocation rate
FragmentationG1 evacuation failuresIncrease heap regions

G1 allocation failures

Solution: Use the G1 MarkStackSize 128M profile or add:

Quick reference

JVM flags by purpose

PurposeFlags
Heap sizing-Xms, -Xmx, -XX:MaxDirectMemorySize
G1 tuning-XX:MaxGCPauseMillis, -XX:ParallelGCThreads, -XX:ConcGCThreads
Diagnostics-XX:+HeapDumpOnOutOfMemoryError, -Xlog:gc*

Profile selection guide

WorkloadProfileNotes
General purposeG1 GCDefault for Java 11+
High allocation rateG1 MarkStackSize 128MIf seeing allocation failures
Legacy Java 8CMS GCDeprecated
Custom requirementsCreate custom profileInclude base profile

Heap sizing considerations

Worker heap depends on:

  • Query complexity: Simple queries vs. complex joins/aggregations
  • Data volume: Size of tables accessed during operations
  • Concurrent operations: Number of simultaneous operations

Start with the sizing guidelines in Memory management and adjust based on monitoring.