Skip to content

Conversation

@nickgerace
Copy link
Contributor

@nickgerace nickgerace commented Jan 13, 2026

Description

This change splits out the summary generator code and provides minor improvements. The improvements include the following:

  • Not fetching all components by only listing their IDs
  • Adding instrumentation and span recordings of durations of long-running tasks to both quantify how long the code is truly taking as well as decrese and clean up the total number of spans
  • Caching "head_ctx" for fewer queries and more consistent HEAD state
  • Decrease the number of diagram assembly spans, but record the duration of inner parts

There is now an integration test for the component summary generator too.

Testing and Docs

  • Create a workspace with a non-trivial number of components and subscriptions
  • Use the Swagger UI with and without the includeAll field
  • Open Jaeger and observe that the two new spans appear and all the fields recorded are correct
  • Ensure that the agent can list components
  • Use the UI to drive the changes to also ensure that it was unaffected (should be impossible)

Future Potential Work

  • Continue to improve the performance of the summary generator code
  • Add more extensive testing to the summary generator code in dal integration tests
  • Add alerts for performance based on trends over time

Screenshots

Swagger UI query used with includeAll and 85 components:

Screenshot 2026-01-14 at 2 27 57 PM

Overview of traces in Jaeger corresponding to these calls:

Screenshot 2026-01-14 at 2 30 06 PM

The two new spans with their fields populated to help determine performance bottlenecks (note: the spans now have different names):

Screenshot 2026-01-14 at 2 32 33 PM

@github-actions
Copy link

github-actions bot commented Jan 13, 2026

Dependency Review

✅ No vulnerabilities or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions
Copy link

There are luminork endpoint changes on this branch that do not appear to have associated tests. Please ensure you add or update tests under bin/si-luminork-api-tests/tests/ to satisfy this warning.

@nickgerace nickgerace force-pushed the nick/fceb66f branch 4 times, most recently from 7831320 to 579446b Compare January 14, 2026 19:34
@nickgerace nickgerace changed the title Improve graph lab code perf and split it out Split out graph lab code with minor improvements Jan 14, 2026
@nickgerace nickgerace marked this pull request as ready for review January 14, 2026 20:20
Comment on lines +13 to +14
// TODO(nick): enable this and add docs.
// missing_docs,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not important for this PR

#[instrument(level = "info", skip(ctx))]
#[instrument(
name = "diagram.assemble",
level = "info",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chopped down all spans in this file into one: used fields instead and renamed to be more clear

Comment on lines +167 to +174
let (component_details, next_cursor) = list_components_inner(
ctx,
limit,
cursor,
include_codegen,
maybe_summary_generator_config,
)
.await?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "inner" function contains all the logic without having to content with route-relevant semantics like extractors and return types

// Get all component IDs. This ensures that we do not access CAS. Then, sort for consistent
// pagination.
let mut all_component_ids = Component::list_ids(ctx).await?;
all_component_ids.sort();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sort is functionally the same

schema_name,
codegen: None,
for paginated_component_id in paginated_component_ids.iter().copied() {
component_details_vec.push(ComponentDetailsV1 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer a mutable type

// Build graph summary for the components. Drop the HEAD context from scope as soon as we
// no longer need it.
let graph_summaries = {
let head_ctx = ctx.clone_with_head().await?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One head context for the entire lifespan of the route

Comment on lines +440 to +450
#[derive(Debug)]
struct SummaryGeneratorConfig {
include_action_functions: bool,
include_diff_status: bool,
include_execution_history: bool,
include_management_functions: bool,
include_manages: bool,
include_qualification_functions: bool,
include_resource_info: bool,
include_subscriptions: bool,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug dump the config as needed. Maybe we should record this in a span, but I wanted to keep tracing span count impact minimal (this PR reduces the total number of spans).

@nickgerace nickgerace changed the title Split out graph lab code with minor improvements Split out summary generator code with minor improvements Jan 14, 2026
This change splits out the summary generator code and provides minor
improvements. The improvements include the following:

- Not fetching all components by only listing their IDs
- Adding instrumentation and span recordings of durations of
  long-running tasks to both quantify how long the code is truly
  taking as well as decrese and clean up the total number of spans
- Caching "head_ctx" for fewer queries and more consistent HEAD state
- Decrease the number of diagram assembly spans, but record the
  duration of inner parts

There is now an integration test for the graph lab code too.

Signed-off-by: Nick Gerace <nick@systeminit.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants