TantivyEx.Performance (TantivyEx v0.4.1)

View Source

Performance optimization and background operations for TantivyEx.

This module provides functionality for:

  • Merge policy configuration and management
  • Thread pool management for search, indexing, and merge operations
  • Index optimization and compaction
  • Background merge operations
  • Performance monitoring and profiling
  • Auto-optimization with configurable triggers
  • Concurrency controls and permit management

Summary

Functions

Acquires a permit for an operation type.

Applies optimization recommendations to an index.

Returns a specification to start this module under a supervisor.

Compacts an index by removing deleted documents.

Configures the size of a specific thread pool.

Disables auto optimization for an index.

Enables auto optimization for an index.

Forces merge of index segments with options.

Gets current concurrency limits.

Gets the current merge policy configuration.

Gets optimization recommendations for an index.

Gets scheduled operations for an index.

Gets current performance statistics.

Gets the configuration of a specific thread pool.

Checks if auto optimization is enabled for an index.

Checks if background merging is active for an index.

Monitors an operation with timeout.

Optimizes an index by merging segments and removing deleted documents.

Profiles an operation and returns result with performance metrics.

Releases a previously acquired permit.

Schedules optimization for an index.

Sets concurrency limits for different operation types.

Sets the merge policy with default options.

Sets the merge policy with custom options.

Starts background merging for an index.

Starts the Performance GenServer.

Stops background merging for an index.

Types

merge_policy()

@type merge_policy() :: :no_merge | :log_merge | :temporal_merge

operation_type()

@type operation_type() :: :search | :write | :merge

thread_pool_type()

@type thread_pool_type() :: :search | :indexing | :merge

Functions

acquire_permit(operation_type)

@spec acquire_permit(operation_type()) :: {:ok, reference()} | {:error, term()}

Acquires a permit for an operation type.

apply_recommendations(index_ref, recommendations)

@spec apply_recommendations(reference(), [map()]) :: [map()]

Applies optimization recommendations to an index.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

compact_index(index_ref)

@spec compact_index(reference()) :: {:ok, map()} | {:error, term()}

Compacts an index by removing deleted documents.

configure_thread_pool(pool_type, size)

@spec configure_thread_pool(thread_pool_type(), pos_integer()) ::
  :ok | {:error, term()}

Configures the size of a specific thread pool.

disable_auto_optimization(index_ref)

@spec disable_auto_optimization(reference()) :: :ok | {:error, term()}

Disables auto optimization for an index.

enable_auto_optimization(index_ref, options \\ [])

@spec enable_auto_optimization(
  reference(),
  keyword()
) :: :ok | {:error, term()}

Enables auto optimization for an index.

force_merge(index_ref, options \\ [])

@spec force_merge(
  reference(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Forces merge of index segments with options.

get_concurrency_limits()

@spec get_concurrency_limits() :: map()

Gets current concurrency limits.

get_merge_policy()

@spec get_merge_policy() ::
  merge_policy() | %{type: merge_policy(), options: keyword()}

Gets the current merge policy configuration.

get_optimization_recommendations(index_ref)

@spec get_optimization_recommendations(reference()) :: [map()]

Gets optimization recommendations for an index.

get_scheduled_operations(index_ref)

@spec get_scheduled_operations(reference()) :: [map()]

Gets scheduled operations for an index.

get_statistics()

@spec get_statistics() :: map()

Gets current performance statistics.

get_thread_pool_config(pool_type)

@spec get_thread_pool_config(thread_pool_type()) ::
  %{size: pos_integer()} | {:error, term()}

Gets the configuration of a specific thread pool.

is_auto_optimization_enabled?(index_ref)

@spec is_auto_optimization_enabled?(reference()) :: boolean()

Checks if auto optimization is enabled for an index.

is_background_merge_active?(index_ref)

@spec is_background_merge_active?(reference()) :: boolean()

Checks if background merging is active for an index.

monitor_operation(operation, options \\ [])

@spec monitor_operation(
  function(),
  keyword()
) :: {:ok, term(), map()} | {:error, term()}

Monitors an operation with timeout.

optimize_index(index_ref)

@spec optimize_index(reference()) :: {:ok, map()} | {:error, term()}

Optimizes an index by merging segments and removing deleted documents.

profile_operation(operation, operation_name)

@spec profile_operation(function(), String.t()) ::
  {:ok, term(), map()} | {:error, term()}

Profiles an operation and returns result with performance metrics.

release_permit(permit_ref)

@spec release_permit(reference()) :: :ok | {:error, term()}

Releases a previously acquired permit.

schedule_optimization(index_ref, options \\ [])

@spec schedule_optimization(
  reference(),
  keyword()
) :: :ok | {:error, term()}

Schedules optimization for an index.

set_concurrency_limits(limits)

@spec set_concurrency_limits(map()) :: :ok | {:error, term()}

Sets concurrency limits for different operation types.

set_merge_policy(policy)

@spec set_merge_policy(merge_policy()) :: :ok | {:error, term()}

Sets the merge policy with default options.

set_merge_policy(policy, options)

@spec set_merge_policy(
  merge_policy(),
  keyword()
) :: :ok | {:error, term()}

Sets the merge policy with custom options.

start_background_merge(index_ref)

@spec start_background_merge(reference()) :: :ok | {:error, term()}

Starts background merging for an index.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the Performance GenServer.

stop_background_merge(index_ref)

@spec stop_background_merge(reference()) :: :ok | {:error, term()}

Stops background merging for an index.