Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure Hydration/Transformation/Indexing Times #153

Merged
merged 24 commits into from
Dec 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Proof of concept index metrics tracker.
tpendragon committed Nov 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7c894f9ca0768cfb7bd992ba5beae2148c6fd202
37 changes: 37 additions & 0 deletions lib/dpul_collections/index_metrics_tracker.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
defmodule DpulCollections.IndexMetricsTracker do
use GenServer

def start_link(_) do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end

def register_fresh_index(source) do
tpendragon marked this conversation as resolved.
Show resolved Hide resolved
GenServer.cast(__MODULE__, { :fresh_index, source })
end

def register_polling_started(source) do
GenServer.cast(__MODULE__, { :poll_started, source })
end

@impl true
def init(_) do
{:ok, %{}}
end

@impl true
def handle_cast({:fresh_index, source}, state) do
new_state = put_in(state, [source], %{start_time: :erlang.monotonic_time()})
{:noreply, new_state}
end

def handle_cast({:poll_started, source}, state) do
if get_in(state, [source, :start_time]) != nil && get_in(state, [source, :end_time]) == nil do
state = put_in(state, [source, :end_time], :erlang.monotonic_time())
duration = state[source][:end_time] - state[source][:start_time]
IO.inspect("Duration (ms)(#{source}): #{System.convert_time_unit(duration, :native, :millisecond)}")
{:noreply, state}
else
{:noreply, state}
end
end
end
4 changes: 4 additions & 0 deletions lib/dpul_collections/indexing_pipeline/database_producer.ex
Original file line number Diff line number Diff line change
@@ -59,6 +59,9 @@ defmodule DpulCollections.IndexingPipeline.DatabaseProducer do
source_module: source_module
}
) do
if last_queried_marker == nil do
DpulCollections.IndexMetricsTracker.register_fresh_index(source_module)
end
total_demand = stored_demand + demand

records =
@@ -82,6 +85,7 @@ defmodule DpulCollections.IndexingPipeline.DatabaseProducer do

# Set a timer to try fulfilling demand again later
if new_state.stored_demand > 0 do
DpulCollections.IndexMetricsTracker.register_polling_started(source_module)
Process.send_after(self(), :check_for_updates, 50)
end