Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Reduce allocations for PgBindIter

Aperta
#4,085 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
48/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
postgresql, rust

Direzione di ricerca

The suggested change is a one-line .reserve() on PgArgumentBuffer from iter.size_hint() inside encode_inner in sqlx-postgres/src/bind_iter.rs (around the linked line). Read that function and how PgBindIter feeds the buffer, then add the reserve and run the existing postgres bind/encode tests. Done means fewer reallocations with no API change; related discussion is in #3651.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement
I have found these related issues/pull requests

#3651

Description

Hello,
The new PgBindIter is awesome, but it seems that it allocates too much memory.

I would like to submit a PR to .reserve() the PgArgumentBuffer using iter.size_hint() in encode_inner https://github.com/launchbadge/sqlx/blob/e8384f2a00173c2b120eea72e99d120557fced8b/sqlx-postgres/src/bind_iter.rs#L83

in order to reduce the number of allocations performed by PgArgumentBuffer.

Prefered solution

.reserve() the PgArgumentBuffer using iter.size_hint() in encode_inner

Is this a breaking change? Why or why not?

no, just a small improvement, 1-line change

Lingua principale
Rust
Stelle
17.5k
Fork
1.7k
Merge medio
3g 17h
PR unite (30g)
11

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di transact-rs/sqlx

Tutte le issue di transact-rs/sqlx

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.