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

Add Metrics Support in the CAPI #12498

Merged
merged 27 commits into from
Jul 8, 2024
Merged

Conversation

maiadegraaf
Copy link
Contributor

@maiadegraaf maiadegraaf commented Jun 12, 2024

This PR adds six new functions to the CAPI to support recursive access to the profiling tree.

  • duckdb_profiling_info duckdb_get_profiling_info(duckdb_connection connection);
    • Returns the root node from the profiling information. Returns NULL if profiling is not enabled
  • const char *duckdb_profiling_info_get_value(duckdb_profiling_info info, const char *key);
    • Returns the value of the setting key of the current profiling info node. If the setting does not exist or is not enabled, nullptr is returned. The result must be freed with duckdb_free.
  • idx_t duckdb_profiling_info_get_child_count(duckdb_profiling_info info);
    • Returns the number of children of the current profiling info node.
  • duckdb_profiling_info duckdb_profiling_info_get_child(duckdb_profiling_info info, idx_t index);
    • Returns the child node at the specified index.
  • const char *duckdb_profiling_info_get_name(duckdb_profiling_info info);
    • Returns the name of the current profiling info node, if the node is an operator node. Returns nullptr otherwise. The result must be freed with duckdb_free.
  • const char *duckdb_profiling_info_get_query(duckdb_profiling_info info);
    • Returns the query of the current profiling info node, if the node is the query root node. Returns nullptr otherwise. The result must be freed with duckdb_free.

Node Structure

The top node contains the QUERY_ROOT, which holds the query, the overall metrics for the query, as well as its children. Every subsequent node is an OPERATOR node which holds the operator name, the operator-specific metrics, and its children.

See this file for an example on how to access the profiling tree using the above functions.

Note: The current CAPI profiling does not include detailed profiling.

@maiadegraaf maiadegraaf marked this pull request as ready for review June 19, 2024 12:20
@duckdb-draftbot duckdb-draftbot marked this pull request as draft June 20, 2024 09:37
@maiadegraaf maiadegraaf marked this pull request as ready for review June 20, 2024 11:48
Copy link
Contributor

@taniabogatsch taniabogatsch left a comment

Choose a reason for hiding this comment

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

Hey! Thanks for the PR, this looks great! My comments are mostly structural and nits, I think functionality-wise this is good to go. :)

src/common/symbols.cpp Show resolved Hide resolved
src/common/tree_renderer.cpp Outdated Show resolved Hide resolved
src/common/tree_renderer.cpp Outdated Show resolved Hide resolved
src/include/duckdb.h Outdated Show resolved Hide resolved
src/include/duckdb.h Outdated Show resolved Hide resolved
src/main/capi/profiling_info-capi.cpp Outdated Show resolved Hide resolved
src/include/duckdb/main/profiling_node.hpp Show resolved Hide resolved
test/api/capi/test_capi_profiling.cpp Outdated Show resolved Hide resolved
test/api/capi/test_capi_profiling.cpp Show resolved Hide resolved
src/main/query_profiler.cpp Outdated Show resolved Hide resolved
@Mytherin Mytherin deleted the branch duckdb:main June 21, 2024 12:39
@Mytherin Mytherin closed this Jun 21, 2024
@Mytherin Mytherin reopened this Jun 21, 2024
@Mytherin Mytherin changed the base branch from feature to main June 21, 2024 14:28
@duckdb-draftbot duckdb-draftbot marked this pull request as draft June 24, 2024 11:26
@maiadegraaf maiadegraaf marked this pull request as ready for review June 25, 2024 09:36
Copy link
Contributor

@taniabogatsch taniabogatsch left a comment

Choose a reason for hiding this comment

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

Hey @maiadegraaf - this looks almost ready to go now from my side, I only had two minor comments.

src/include/duckdb.h Show resolved Hide resolved
src/include/duckdb/main/profiling_node.hpp Outdated Show resolved Hide resolved
@duckdb-draftbot duckdb-draftbot marked this pull request as draft June 27, 2024 14:07
@maiadegraaf maiadegraaf marked this pull request as ready for review June 27, 2024 14:07
@duckdb-draftbot duckdb-draftbot marked this pull request as draft June 27, 2024 14:30
@maiadegraaf maiadegraaf marked this pull request as ready for review June 27, 2024 14:30
Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

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

Looks good from my side - one minor comment

src/main/profiling_info.cpp Show resolved Hide resolved
@Mytherin Mytherin merged commit 96fb464 into duckdb:main Jul 8, 2024
42 checks passed
@Mytherin
Copy link
Collaborator

Mytherin commented Jul 8, 2024

Thanks!

github-actions bot pushed a commit to duckdb/duckdb-r that referenced this pull request Jul 8, 2024
Merge pull request duckdb/duckdb#12498 from maiadegraaf/metrics_capi
@maiadegraaf maiadegraaf deleted the metrics_capi branch July 9, 2024 13:21
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.

None yet

3 participants