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

Prevent infinite DAG growth #2892

Merged
merged 1 commit into from
Jun 3, 2024
Merged

Conversation

ferd
Copy link
Collaborator

@ferd ferd commented Jun 1, 2024

In some circumstances where files repeatedly get updated, such as when a .xrl file re-generates a .erl file on each compile run, the DAG analysis would repeatedly re-add edges for this file's dependencies (such as include files) to the DAG. Since the digraph module de-dupes vertices but not edges (duplicate edges is a valid use case), we add an explicit check for edge presence before re-adding them.

This should properly prevent unexpected growth of DAG files.

From manual testing, we get stability when going from a fresh DAG, but if it already had many dupes, the file size may jump around a bit regardless.

In some circumstances where files repeatedly get updated, such as when a
.xrl file re-generates a .erl file on each compile run, the DAG analysis
would repeatedly re-add edges for this file's dependencies (such as
include files) to the DAG. Since the digraph module de-dupes vertices
but not edges (duplicate edges is a valid use case), we add an explicit
check for edge presence before re-adding them.

This should properly prevent unexpected growth of DAG files.

From manual testing, we get stability when going from a fresh DAG, but
if it already had many dupes, the file size may jump around a bit
regardless.
@ferd ferd merged commit 63e4e1f into erlang:main Jun 3, 2024
6 checks passed
@ferd ferd deleted the prevent-DAG-edge-duplication branch June 3, 2024 11:33
RemainingEdges = [digraph:edge(G, E) || E <- digraph:out_edges(G, Source),
AbsIncls =/= []],
[digraph:add_edge(G, Source, Incl) || Incl <- AbsIncls,
not in_edges(Source, Incl, RemainingEdges)],
Copy link
Collaborator

Choose a reason for hiding this comment

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

So add it if its not already in the edges?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah. Problem was that edges can be duplicated and I assumed they weren't.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, surprised me too seeing this patch.

@heiheshang
Copy link

Hello. I'm immediately experiencing a problem with slow pull of dependencies. I use the git _subdir option, each dependency takes at least 15 minutes to pull. I installed rebar3 from the nightly build, but it didn't help me

@ferd
Copy link
Collaborator Author

ferd commented Jul 2, 2024

This seems unrelated to this issue. Please open a stand-alone issue while following the instructions in the template.

This pull request was closed.
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