Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized the work of InMemoryTransaction for lookups and empty insertion #1974

Merged
merged 4 commits into from
Jun 16, 2024

Conversation

xgreenx
Copy link
Collaborator

@xgreenx xgreenx commented Jun 15, 2024

Just was walking around this code and noticed that we can remove not needed to_vec and improve the case when we commit changes into empty InMemoryTransaction.

Before requesting review

  • I have reviewed the code myself

@xgreenx xgreenx requested review from Voxelot and a team June 15, 2024 21:41
@xgreenx xgreenx self-assigned this Jun 15, 2024
Comment on lines 310 to +312
self.changes
.get(&column.id())
.and_then(|btree| btree.get(&k))
.and_then(|btree| btree.get(key))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use property that collections work with Q generic. The ReferenceBytesKey implements Borrow<[u8]> that allows usage of &[u8] for lookups. It is very important for InMemoryTransaction since get is mostly used method=)

image

Comment on lines +269 to +272
hash_map::Entry::Vacant(vacant) => {
vacant.insert(value);
continue
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If BTreeMap is not exist, we just set it to be value because it can't have any conflicts=)

@xgreenx xgreenx enabled auto-merge (squash) June 15, 2024 21:52
@xgreenx xgreenx merged commit 1d03e14 into master Jun 16, 2024
33 checks passed
@xgreenx xgreenx deleted the feature/optimization-of-in-memory-database branch June 16, 2024 00:53
@xgreenx xgreenx mentioned this pull request Jun 16, 2024
xgreenx added a commit that referenced this pull request Jun 16, 2024
## Version v0.30.0

### Added
- [#1975](#1975): Added
`DependentCost` benchmarks for the `cfe` and `cfei` opcodes.
- [#1975](#1975): Added
`DependentCost` for the `cfe` opcode to the `GasCosts` endpoint.
- [#1974](#1974): Optimized
the work of `InMemoryTransaction` for lookups and empty insertion.

### Changed
- [#1973](#1973): Updated VM
initialization benchmark to include many inputs and outputs.

#### Breaking
- [#1975](#1975): Updated gas
prices according to new release.
- [#1975](#1975): Changed
`GasCosts` endpoint to return `DependentCost` for the `cfei` opcode via
`cfeiDependentCost`.
- [#1975](#1975): Use `fuel-vm
0.54.0`. More information in the
[release](https://github.com/FuelLabs/fuel-vm/releases/tag/v0.54.0).

## What's Changed
* Add `creation_instant` as second sort key in tx pool. by @AurelienFT
in #1964
* Updated VM initialization benchmark to include many inputs and outputs
by @xgreenx in #1973
* Fixes the error message for incorrect keypair's path by @xgreenx in
#1962
* Optimized the work of `InMemoryTransaction` for lookups and empty
insertion by @xgreenx in #1974
* Weekly `cargo update` by @github-actions in
#1976
* Use `fuel-vm 0.54.0` by @xgreenx in
#1975


**Full Changelog**:
v0.29.0...v0.30.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants