perf(api_core): avoid full-corpus scans in list_funcs/func_query/entity_query pagination - #484
Open
lich0821 wants to merge 2 commits into
Open
perf(api_core): avoid full-corpus scans in list_funcs/func_query/entity_query pagination#484lich0821 wants to merge 2 commits into
lich0821 wants to merge 2 commits into
Conversation
…ty_query pagination
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
list_funcs,func_query, andentity_queryall built the entirefunction/global/import corpus into a Python list before filtering and
paginating it — even for a bounded page (e.g.
count=50). On binaries withhundreds of thousands of functions this dominates per-call latency, and
_collect_entities("functions", ...)always paid for a per-row segment-namelookup and a type-info probe even when the caller's requested fields never
use them.
Fix
lazy_paginate_filter(utils.py): walks the underlying iteratorlazily and stops as soon as enough matching rows are collected for the
requested page, instead of materializing every row up front. Falls back to
full materialization only when
count=0(unbounded page), since computingnext_offsetcorrectly still requires the full filtered set in that case._collect_entitiestakesneeds_segment/needs_has_typeflags soentity_querycan skip the segment-name lookup and type-info probe perfunction when neither the active filter nor the requested output
fieldsneed them.
list_funcs/func_queryswitched to the lazy path for bounded pages.Existing callers and output shape are unchanged; this only changes how many
rows get built before filtering stops.
Test plan
test_api_core.pypagination/filter assertions pass unchanged(ran via
ida-mcp-test tests/crackme03.elf/typed_fixture.elf)