Skip to content

⚡ Bolt: Optimize file upload memory usage with TextIOWrapper#11

Draft
google-labs-jules[bot] wants to merge 1 commit intomainfrom
bolt-memory-optimization-7170063886092052422
Draft

⚡ Bolt: Optimize file upload memory usage with TextIOWrapper#11
google-labs-jules[bot] wants to merge 1 commit intomainfrom
bolt-memory-optimization-7170063886092052422

Conversation

@google-labs-jules
Copy link
Contributor

💡 What: Replaced the file loading mechanism in app.py. Instead of reading the full uploaded file content into memory, decoding it, and creating a StringIO buffer, we now use io.TextIOWrapper to wrap the underlying file stream.

🎯 Why: The previous approach required approximately 2x-3x the file size in memory (bytes + decoded string + buffer overhead). For large proteomics files (MGFs can be GBs), this causes significant memory pressure or OOM errors. TextIOWrapper processes the stream on-the-fly with minimal buffering.

📊 Impact:

  • Significantly reduced memory usage during file parsing.
  • Faster start-up time for processing (skips the initial full-file read/decode step).

🔬 Measurement:

  • Verified using repro_optimization.py (during development) that load_mgf and load_mztab produce identical results with TextIOWrapper as they did with the original method.
  • Passed all existing tests in pytest.

Other changes:

  • Added __pycache__/ to .gitignore.
  • Added entry to .jules/bolt.md.

PR created automatically by Jules for task 7170063886092052422 started by @erayfirat

Replaces `io.StringIO(file.read().decode())` with `io.TextIOWrapper(file)` for `mgf` and `mztab` file loading. This avoids loading the entire file into memory as bytes and then again as a string, significantly reducing memory footprint for large spectral files.
@google-labs-jules
Copy link
Contributor Author

👋 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.

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.

0 participants