Summary
sync_elapsed_streams() has been updated to use persistent() storage for stream reads, but is still O(n):
while stream_id < next_id {
let maybe_stream: Option<Stream> = env.storage().persistent().get(&DataKey::Stream(stream_id));
// ...
stream_id += 1;
}
Persistent storage reads are metered the same as instance storage reads. With 1000 streams this still reads 1000 persistent storage entries per get_active_streams_count() call. The migration to persistent storage solved the size limit issue but not the CPU cost issue.
Tasks
Labels: bug, forge-stream, performance, critical
Summary
sync_elapsed_streams()has been updated to usepersistent()storage for stream reads, but is still O(n):Persistent storage reads are metered the same as instance storage reads. With 1000 streams this still reads 1000 persistent storage entries per
get_active_streams_count()call. The migration to persistent storage solved the size limit issue but not the CPU cost issue.Tasks
sync_elapsed_streams()ActiveStreamsCountpurely via increment oncreate_stream()and decrement oncancel_stream()and stream expiry duringwithdraw()withdraw(): ifnow >= stream.end_time && stream.counted_active, decrement and setcounted_active = falseget_active_streams_count()is correct without a full scanLabels:
bug,forge-stream,performance,critical