Skip to content

udict_inline: resume iterations instead of looking up attributes - #1275

Open
JDarnley wants to merge 1 commit into
Upipe:masterfrom
JDarnley:udict-inline-iterate
Open

JDarnley wants to merge 1 commit into
Upipe:masterfrom
JDarnley:udict-inline-iterate

Conversation

@JDarnley

Copy link
Copy Markdown
Contributor

udict_inline_iterate() looked up the attribute it was given from the start of the udict at every step, so a whole iteration was quadratic in the number of attributes. This becomes pathological for udicts with thousands of attributes, all the more when code iterates over them repeatedly or restarts an iteration after each deletion: in one case, splitting a udict of about 3,300 attributes into its parts took over 30 seconds, and ten minutes under valgrind.

Remember the attribute returned last and resume from it when it is given back, forgetting it whenever the udict changes, which makes a whole iteration linear.


My proposed uref-mux code created this pathologic case for one of its tests.

udict_inline_iterate() looked up the attribute it was given from the
start of the udict at every step, so a whole iteration was quadratic in
the number of attributes. This becomes pathological for udicts with
thousands of attributes, all the more when code iterates over them
repeatedly or restarts an iteration after each deletion: in one case,
splitting a udict of about 3,300 attributes into its parts took over
30 seconds, and ten minutes under valgrind.

Remember the attribute returned last and resume from it when it is
given back, forgetting it whenever the udict changes, which makes a
whole iteration linear.
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.

1 participant