Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 1.6 KB

tip-281.md

File metadata and controls

31 lines (25 loc) · 1.6 KB
tip: 281
title: Optimize the query of database	
author: forfreeday@163.com
discussions to: https://github.com/tronprotocol/TIPs/issues/281
status: Final
type: Standards Track
category: Core
created: 2021-06-18

Simple Summary

Optimize the performance of underlying database queries and remove query synchronization locks.

Abstract

Optimize database queries to improve query efficiency. Remove unnecessary locking operations during queries to improve query efficiency for HTTP and RPC.

Motivation

To locate important performance issues and find that it is possible to query without adding locks without affecting the correctness of the data and significantly improving the database query performance. Also, if locks exist, there is a certain probability of lock contention during HTTP or RPC queries, which affects the processing efficiency of other threads.

Specification

  1. Remove get method query lock 2.Remove has method lock

Implementation

State-based storage is ultimately operated through the Chainbase class. Lock removal is achieved by removing the synchronized keyword from the get and getUncheck methods of this class.

Rationale

  1. The main operation methods of the database, Manager#pushBlock, Manager#generateBlock, Manager#pushTransaction, are all modified by synchronized, so there is no security problem with the operations before each other.
  2. When calling the database interface to query data, there is no practical significance to add synchronized, because there is no security problem, and the methods of querying data do not use shared data, so there is no need to add synchronized.