fix: prevent RDBM cached_value memory leak during each()#29
Conversation
|
@toddr-bot but doesn't this defeat the point of caching? |
|
but doesn't pull request effectively this defeat the point of caching? |
|
@toddr-bot rebase |
|
but doesn't pull request effectively this defeat the point of caching? |
|
@toddr-bot rebase |
…ch() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FETCH consumed cached values via read but never deleted the hash entry. During each() loops, every visited row accumulated in cached_value for the entire iteration — O(n) memory for a table with n rows. Using `delete` instead of read-only access ensures constant memory usage during iteration while preserving the single-query optimization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
b9a2b58 to
95f577d
Compare
|
The way it is now only one value ever gets cached and the way tie works we're always walking the ENTIRE hash when we for instance do keys or values. So unless you cache the entire table, how is caching valuable. Is it possible the intention was ALWAYS to cache the entire table? what's wrong with that? |
|
@toddr-bot rebase |
Rebase with requested adjustmentsBranch Changes applied
Actions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
What
Fix O(n) memory leak in Tie::RDBM during
each()iteration.Why
NEXTKEY caches each row's value in
cached_valueso FETCH can skip a redundant SQL query. But FETCH only read the cached entry without deleting it, so every row visited during aneach()loop accumulated in memory. For large tables, this meant the entire dataset was held in RAM.How
Changed
return $self->{'cached_value'}->{$key}toreturn delete $self->{'cached_value'}->{$key}in FETCH. The value is consumed exactly once per iteration step, so deleting after use keeps memory constant while preserving the single-query optimization.Testing
🤖 Generated with Claude Code