-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow harmonize to return a limited number of nodes (#419)
## Description For our largest graph, running composition yields thousands of build hints and each build hint can contain hundreds of attached nodes (nodes are snippets of subgraph SDL that help with locating issues), leading to very high memory consumption (>10sGB) and can use all of the host physical memory. ## Investigation Running composition using the `harmonize` function with dhat enabled; we can see that most allocations are done when deserializing json from v8 to rust ` serde_v8::de::to_utf8_fast`. On my M1 Mac this was taken right before the process was killed by the OS and was consuming 45GB of memory. ![Screenshot 2023-10-16 at 2 17 03 PM](https://github.com/apollographql/federation-rs/assets/1523863/333fdde7-7efb-411e-87a4-102253bf777a) [dhat-heap-main.json](https://github.com/apollographql/federation-rs/files/12922166/dhat-heap-main.json) ## Fix/Proposal In the spirit of keeping the library backward compatible, I added a `harmonize_limit()` function that takes an extra parameter that will limit the number of nodes returned in each build hint and/or build error. All nodes above that limit are omitted from the result and a flag `omitted_nodes_count` is set so the caller is aware some nodes have been omitted. If no `nodes_limit` value is passed it defaults to unlimited. The `harmonize` function defaults to unlimited to preserve backward compatibility. Passing `nodes_limit=20` works for us for now, but one could argue there is limited additional insight past 20 nodes anyway and we could make it the default instead.
- Loading branch information
Showing
9 changed files
with
171 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.