GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — perf(values): depth check keeps one frame per level -- 80% less memory by dexhunter · Pull Request #318 · graphql-python/graphql-core Conversation
Contributor
TL;DR
Refs #317 What & WhyBefore, the check pushed one Now each stack frame holds one nesting level: the values, their type, the depth, and the next index. The output stays identical because the check still visits each followed value at the same depth. ValidationPeak traced memory (
The last row shows a case where the change does not help, and it shows no slowdown. Script for the first row; run it on the base commit and on this change: import tracemalloc from graphql import GraphQLInt, GraphQLList from graphql.execution.values import input_is_nested_too_deeply value = list(range(50_000)) tracemalloc.start() input_is_nested_too_deeply(value, GraphQLList(GraphQLInt)) print(tracemalloc.get_traced_memory()[1]) The complete suite also passed with Why this is safe and easy to maintainThe change is small and easy to read: 13 added lines in one private function, with no new imports. ScopeThis changes Python bookkeeping in a private helper only. AI assistanceThis PR was prepared with AI assistance from Aiden. Candidates were tracked with Weco Observe. Weco share link: https://dashboard.weco.ai/share/yE6YtGpMB4NV3RCoYfCM3tHnAk6srhv_
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsinput_is_nested_too_deeply pushed one tuple per list item onto its stack before it popped any, so its memory grew with the width of the list. Keep one frame per nesting level (values, type, depth, next index) and stop the walk of a level when its item type cannot nest. Coercing a [Int] variable of 50,000 ints has a tracemalloc peak of 818,981 bytes, down from 4,091,392 bytes. The returned bool is unchanged. Co-Authored-By: Aiden <[email protected]>
|
There was an error while loading. Please reload this page.
Merging this PR will not alter performance
Comparing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The depth check keeps one frame per nesting level. No test used a list with several nested items or an empty list, so one line and one branch were not covered and the 100% coverage gate failed on Python 3.14. Co-Authored-By: Aiden <[email protected]>
Reuse the deep list type of the existing test instead of building it again in a second test. Co-Authored-By: Aiden <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.