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

Reduce TimedResult objects #63

Merged
merged 2 commits into from
Feb 13, 2023
Merged

Conversation

swalkinshaw
Copy link
Contributor

Currently graphql-metrics creates a new TimedResult object for every single traced field. This can add a lot of object allocations for large documents which can put more pressure on garbage collection.

Since trace_field is a hot path, this replaces the GraphQL::Metrics.time usage with manual time calculations. The other usages are left since they only occur once per operation execution.

Currently graphql-metrics creates a new `TimedResult` object for every
single traced field. This can add a lot of object allocations for large
documents which can put more pressure on garbage collection.

Since `trace_field` is a hot path, this replaces the
`GraphQL::Metrics.time` usage with manual time calculations. The other
usages are left since they only occur once per operation execution.
@swalkinshaw swalkinshaw requested review from chrisbutcher and a team February 10, 2023 17:20
@swalkinshaw
Copy link
Contributor Author

CI was broken due to a deprecated action so I re-did the workflow 🚀

@@ -93,10 +93,7 @@ def capture_multiplex_start_time
end

def capture_lexing_time
# GraphQL::Query#result fires `lex` before the `execute_multiplex` event, so sometimes
# `pre_context.multiplex_start_time_monotonic` isn't set.
lexing_offset_time = pre_context.multiplex_start_time_monotonic || GraphQL::Metrics.current_time_monotonic
Copy link
Contributor Author

@swalkinshaw swalkinshaw Feb 10, 2023

Choose a reason for hiding this comment

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

@chrisbutcher this didn't appear to be used at all? The offset is only needed if time_since_offset is used, but it's not in either of these two places (only duration and start_time are)

Copy link
Contributor

@chrisbutcher chrisbutcher left a comment

Choose a reason for hiding this comment

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

Nice 🧹💨

fail-fast: false
matrix:
os: [ubuntu-latest]
ruby: ['2.7', '3.0', '3.1']
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you forget Ruby 3.2 or is there a reason we don't yet test or support it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just forgot, added it thanks

@swalkinshaw swalkinshaw force-pushed the reduce-timed-result-objects branch from ab549ae to a008d72 Compare February 10, 2023 18:46
@swalkinshaw swalkinshaw merged commit 26f4efe into master Feb 13, 2023
@swalkinshaw swalkinshaw deleted the reduce-timed-result-objects branch February 13, 2023 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants