refactor: speed up ColumnBuilder::repeat(Scalar::Null).
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
Problem Description
The original implementation calls push_default n times, which is slow because each call is recursive and includes pattern matching.
Impact
The repeat method is used when flattening Value::Scalar to Value::Column. This approach significantly affects or even dominates overall performance when there are many null columns.
related issue: https://github.com/datafuselabs/databend/issues/15908 https://github.com/datafuselabs/databend/pull/15880 will be faster after this
Improvement
This change introduces an ColumnBuilder::repeat_null that create the whole builder at once;
Tests
- [ ] Unit Test
- [ ] Logic Test
- [ ] Benchmark Test
- [x] No Test - Explain why
Type of change
- [ ] Bug Fix (non-breaking change which fixes an issue)
- [ ] New Feature (non-breaking change which adds functionality)
- [ ] Breaking Change (fix or feature that could cause existing functionality not to work as expected)
- [ ] Documentation Update
- [x] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):
PR: https://github.com/longhorn/longhorn-manager/pull/2824
cc @ChanYiLin
Hi @derekbit The PR is ready for review here: https://github.com/longhorn/longhorn-manager/pull/2824
Oh I already put it in previous comment
Pre Ready-For-Testing Checklist
- [ ] Where is the reproduce steps/test steps documented?
The reproduce steps/test steps are at:
- Create a BackingImage and a volume/PV/PVC using it
- Create a system-backup
kubectl get lhbbi, lhb -n longhorn-systemwill see the backup of the Volume and the Backingimage- Delete the Volume and the BackingImage
- Restore the system-backup
- The BackingImage and the Volume will be restored. The BackingImage source type will be
restoredand the checksum will be verified.
PRs:
- https://github.com/longhorn/longhorn-manager/pull/2824
@ChanYiLin This is a new feature. I suggest we don't need to backport it to v1.6.x and just add a note in v1.6.x doc.
cc @innobead
Agreed with @derekbit , even though we regarded this as an improvement initially.
we are not going to backport this feature to v1.6.x
The limitation is already in the doc https://longhorn.io/docs/1.6.2/advanced-resources/system-backup-restore/backup-longhorn-system/ Warning: Longhorn does not backup BackingImages. We will improve this part in the future. See Restore Longhorn System - Prerequisite for restoring volumes created with the backing image.