-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[interp] basic_blocks list improvements #47505
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
Conversation
g_list_append has to repeatedly traverse the list using g_list_last to find the last element. Instead use g_list_prepend to add the new bb to the front of the list and then reverse at the end (g_list_reverse is inplace and doesn't allocate)
|
Tagging subscribers to this area: @BrzVlad Issue Detailsg_list_append has to repeatedly traverse the list using g_list_last to Instead use g_list_prepend to add the new bb to the front of the list
|
|
Saw this show up kind of hot in a microbenchmark profile. |
BrzVlad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An even better solution would be to not create this list at all when not generating seq points.
Still fill in offset_to_bb, but don't make a list unless needed.
|
@BrzVlad updated |
|
|
||
| td->basic_blocks = g_list_append_mempool (td->mempool, td->basic_blocks, bb); | ||
| /* Add the blocks in reverse order */ | ||
| if (make_list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason for not using td->gen_sdb_seq_points directly here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. Wasn't sure if there's other reasons why we might need a list of blocks.
use prepend instead of append
g_list_appendhas to repeatedly traverse the list usingg_list_lastto find the last element.Instead use
g_list_prependto add the new bb to the front of the list and then reverse at the end (g_list_reverseis inplace and doesn't allocate)don't make the list at all unless it's needed.
it's only needed when generating sequence points.