Skip to content

⚡ Optimize Search Filter Caching#1

Merged
void0x14 merged 1 commit into
mainfrom
performance-cache-search-query-13879329919190732531
Mar 29, 2026
Merged

⚡ Optimize Search Filter Caching#1
void0x14 merged 1 commit into
mainfrom
performance-cache-search-query-13879329919190732531

Conversation

@void0x14

Copy link
Copy Markdown
Owner

💡 What:

The optimization implemented involves caching the search query and search mode settings from GSettings (shared.schema.get_string) into local variables within the _set_filter_function method in src/views/content_view.py. These cached values are then used inside the lambda functions passed to self._flow_box.set_filter_func.

🎯 Why:

The original code was calling shared.schema.get_string('search-query') and shared.schema.get_string('search-mode') repeatedly inside the filter lambdas. Since the filter function is executed for every single item in the FlowBox whenever the filter is invalidated (e.g., on every keystroke in the search bar), this resulted in a large number of redundant lookups to the GSettings system, which is significantly slower than accessing local variables.

📊 Measured Improvement:

Using a benchmark script with mocked GSettings (simulating a 0.1ms overhead per lookup) and a list of 1000 items:

  • Baseline (Unoptimized): 2.13s for 10 filter runs.
  • Improved (Optimized): 0.004s for 10 filter runs.
  • Change over Baseline: ~99.8% reduction in overhead for the filter logic.

In a real application, the overhead per lookup might vary, but for large datasets, this change ensures that the UI remains responsive and the CPU is not wasted on redundant system calls during active searching.


PR created automatically by Jules for task 13879329919190732531 started by @ulac000000

This commit improves the performance of the content filter by caching
the search query and mode into local variables before setting the
filter function on the FlowBox. This avoids redundant calls to
shared.schema.get_string() for every item in the view, which could
be hundreds or thousands of calls per filter invalidation.

Baseline benchmark (1000 items):
- Unoptimized: 2.13s (simulated overhead)
- Optimized: 0.004s
- Improvement: ~99.8%

Co-authored-by: ulac000000 <132948319+ulac000000@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@void0x14 void0x14 merged commit f1d607e into main Mar 29, 2026
1 check passed
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