tursodatabase/turso

Improve OwnedValue Register in vdbe allocations

Open

#1,236 创建于 2025年4月2日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Rust (1,001 fork)github user discovery
good first issueperformance

仓库指标

Star
 (19,103 star)
PR 合并指标
 (PR 指标待抓取)

描述

The idea is to make OwnedRecord register an enum that has a buffer to store all values. For example right now if you replace OwnedValue::Integer with OwnedValue::Float it will deallocate OwnedValue::Integer which is unnecessary.

This can help with stuff with affinity for example, let's say you update a OnwedValue::Text to a OwnedValue::intenger, then you would have to allocate a new OwnedValue and dispose of the buffer in Text.

So in pseudo code:

enum OwnedValueType {
  Integer,
  Float,
  Text,
  Blob,
  Null
}

struct OwnedValue {
  buffer: Vec<u8>,
  type: OwnedValueType,
}

impl OwnedValue {
   pub fn set_text(&[u8]) {
     // 1. increase self.buffer if necessary
     // 2. clear buffer
    // 3. set buffer with data
   }
}

贡献者指南