Skip to content

Commit

Permalink
refactor(query): heavily reduce query wiki size (#1069)
Browse files Browse the repository at this point in the history
  • Loading branch information
EagleoutIce authored Oct 11, 2024
1 parent 3c6c2b5 commit 2fb47ff
Show file tree
Hide file tree
Showing 2 changed files with 369 additions and 1,944 deletions.
15 changes: 9 additions & 6 deletions src/documentation/print-query-wiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ registerQueryDocumentation('dataflow', {
functionName: executeDataflowQuery.name,
functionFile: '../queries/catalog/dataflow-query/dataflow-query-executor.ts',
buildExplanation: async(shell: RShell) => {
const exampleCode = 'x + 1';
return `
Maybe you want to handle only the result of the query execution, or you just need the [dataflow graph](${FlowrWikiBaseRef}/Dataflow%20Graph) again.
This query type does exactly that!
Using the example code from above, the following query returns the dataflow graph of the code:
Using the example code \`${exampleCode}\`, the following query returns the dataflow graph of the code:
${
await showQuery(shell, exampleQueryCode, [{
await showQuery(shell, exampleCode, [{
type: 'dataflow'
}], { showCode: true })
}
Expand All @@ -114,13 +115,14 @@ registerQueryDocumentation('normalized-ast', {
functionName: executeNormalizedAstQuery.name,
functionFile: '../queries/catalog/normalized-ast-query/normalized-ast-query-executor.ts',
buildExplanation: async(shell: RShell) => {
const exampleCode = 'x + 1';
return `
Maybe you want to handle only the result of the query execution, or you just need the [normalized AST](${FlowrWikiBaseRef}/Normalized%20AST) again.
This query type does exactly that!
Using the example code from above, the following query returns the normalized AST of the code:
Using the example code \`${exampleCode}\`, the following query returns the normalized AST of the code:
${
await showQuery(shell, exampleQueryCode, [{
await showQuery(shell, exampleCode, [{
type: 'normalized-ast'
}], { showCode: true })
}
Expand All @@ -135,12 +137,13 @@ registerQueryDocumentation('id-map', {
functionName: executeIdMapQuery.name,
functionFile: '../queries/catalog/id-map-query/id-map-query-executor.ts',
buildExplanation: async(shell: RShell) => {
const exampleCode = 'x + 1';
return `
This query provides access to all nodes in the [normalized AST](${FlowrWikiBaseRef}/Normalized%20AST) as a mapping from their id to the node itself.
Using the example code from above, the following query returns all nodes from the code:
Using the example code \`${exampleCode}\`, the following query returns all nodes from the code:
${
await showQuery(shell, exampleQueryCode, [{
await showQuery(shell, exampleCode, [{
type: 'id-map'
}], { showCode: true })
}
Expand Down
2,298 changes: 360 additions & 1,938 deletions wiki/Query API.md

Large diffs are not rendered by default.

2 comments on commit 2fb47ff

@github-actions
Copy link

Choose a reason for hiding this comment

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

"artificial" Benchmark Suite

Benchmark suite Current: 2fb47ff Previous: 9d8b361 Ratio
Retrieve AST from R code 236.32288922727273 ms (99.1030778795716) 238.12351204545453 ms (103.59720843756357) 0.99
Normalize R AST 18.590099 ms (32.647119963847764) 19.968034227272728 ms (34.84298543847825) 0.93
Produce dataflow information 39.909988727272726 ms (87.18894936927444) 38.310942090909094 ms (82.04448044777155) 1.04
Total per-file 816.6599315909091 ms (1445.8404786182437) 811.1703915909092 ms (1431.4404310276739) 1.01
Static slicing 2.189539775013442 ms (1.302916483061998) 2.258090287874194 ms (1.2792808105316449) 0.97
Reconstruct code 0.23383437393750717 ms (0.18455829104077853) 0.22489327849282828 ms (0.17585774592637268) 1.04
Total per-slice 2.4389832890721825 ms (1.3747313341696201) 2.4996261233332735 ms (1.3278746913052974) 0.98
failed to reconstruct/re-parse 0 # 0 # 1
times hit threshold 0 # 0 # 1
reduction (characters) 0.7869360165281424 # 0.7869360165281424 # 1
reduction (normalized tokens) 0.7639690077689504 # 0.7639690077689504 # 1
memory (df-graph) 95.46617542613636 KiB (244.77619956879823) 147.42458274147728 KiB (358.6827375397903) 0.65

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

"social-science" Benchmark Suite

Benchmark suite Current: 2fb47ff Previous: 9d8b361 Ratio
Retrieve AST from R code 255.31945666 ms (48.32086640114548) 238.40722376 ms (42.95412443307438) 1.07
Normalize R AST 21.82571778 ms (16.35843021055723) 22.0872248 ms (17.016890594916376) 0.99
Produce dataflow information 78.94048586 ms (92.62736074451318) 74.60461736 ms (88.95210983454488) 1.06
Total per-file 8045.457626560001 ms (29982.27810077936) 11091.201449639999 ms (52310.41942604725) 0.73
Static slicing 16.621343340146847 ms (45.812406334462096) 22.047137876062838 ms (78.30877993604865) 0.75
Reconstruct code 0.3199045174901708 ms (0.17200686734612472) 0.2327517832436913 ms (0.14954480815603388) 1.37
Total per-slice 16.95145655690175 ms (45.83127734637213) 22.287796325154986 ms (78.33211951742135) 0.76
failed to reconstruct/re-parse 0 # 0 # 1
times hit threshold 0 # 0 # 1
reduction (characters) 0.8712997340230448 # 0.8719618340615195 # 1.00
reduction (normalized tokens) 0.8102441553774778 # 0.810633662275233 # 1.00
memory (df-graph) 99.8990234375 KiB (113.72812769327498) 145.6434765625 KiB (153.49028997815503) 0.69

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.