[interp] basic_blocks list improvements#47505
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.
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.
any reason for not using td->gen_sdb_seq_points directly here ?
There was a problem hiding this comment.
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.