bitshares / bitshares/bitshares-core
Improve `lower_bound(min_price)` performance
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 660
- Avg merge
- 8h 17m
- Merged PRs (30d)
- 26
Description
**User Story**
When calling something like `an_index::lower_bound(price.min(a,b))` as well as `upper_bound(max_price)`, step into `lower_bound()`, when the pointer is on a record with `price(a,b)`, 128-bit computations will occur, see https://github.com/bitshares/bitshares-core/blob/cb0dbb8ec5359da6a0997c92e8ae200085c48393/libraries/chain/protocol/asset.cpp#L50-L51
IMHO the 128-bit computation is unnecessary in this case since `operator<()` will always return `true` (or `false` when in another direction). If we can find a way to avoid the computation **without much overhead**, we may be able to get better performance. Need benchmark.
Related to #1094. Part of #982.
**Impacts**
Describe which portion(s) of BitShares Core may be impacted by your request. Please tick at least one box.
- [ ] API (the application programming interface)
- [ ] Build (the build process or something prior to compiled code)
- [ ] CLI (the command line wallet)
- [ ] Deployment (the deployment process after building such as Docker, Travis, etc.)
- [ ] DEX (the Decentralized EXchange, market engine, etc.)
- [ ] P2P (the peer-to-peer network for transaction/block propagation)
- [x] Performance (system or user efficiency, etc.)
- [ ] Protocol (the blockchain logic, consensus, validation, etc.)
- [ ] Security (the security of system or user data, etc.)
- [ ] UX (the User Experience)
- [ ] Other (please add below)
**Additional Context (optional)**
Add any other context about your request here.
## CORE TEAM TASK LIST
- [ ] Evaluate / Prioritize Feature Request
- [ ] Refine User Stories / Requirements
- [ ] Define Test Cases
- [ ] Design / Develop Solution
- [ ] Perform QA/Testing
- [ ] Update Documentation
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the lower_bound() and upper_bound() paths described in the issue and the referenced asset.cpp lines 50-51. Add or locate a benchmark for min_price and max_price queries, then verify whether the 128-bit computation can be avoided without meaningful overhead while preserving comparison behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100