CN106055646A - Lock-free operation method of concurrent hash tables - Google Patents

Lock-free operation method of concurrent hash tables Download PDF

Info

Publication number
CN106055646A
CN106055646A CN201610377615.5A CN201610377615A CN106055646A CN 106055646 A CN106055646 A CN 106055646A CN 201610377615 A CN201610377615 A CN 201610377615A CN 106055646 A CN106055646 A CN 106055646A
Authority
CN
China
Prior art keywords
perform
hash
chained list
update
pointer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610377615.5A
Other languages
Chinese (zh)
Inventor
卫冰洁
王啸
熊刚
贺欣
石俊峥
刘培朋
李镇
周立
王秀文
贺龙涛
李晓倩
袁媛
朱佳伟
李城龙
张慧
曹首峰
于贺威
王大伟
刘阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
National Computer Network and Information Security Management Center
Original Assignee
National Computer Network and Information Security Management Center
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by National Computer Network and Information Security Management Center filed Critical National Computer Network and Information Security Management Center
Priority to CN201610377615.5A priority Critical patent/CN106055646A/en
Publication of CN106055646A publication Critical patent/CN106055646A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

In order to enhance the high efficiency of operation carried out on Hash tables by multiple threads, the invention provides a lock-free operation method of concurrent hash tables. The method comprises the following steps: when insertion operation needs to be carried out on a hash table, firstly constructing a newly added value object, pointing a next pointer in the object to an object pointed by a pointer in a hash slot corresponding to a key value, and pointing the pointer in the corresponding hash slot to the newly added object by utilizing atomic operation; when deletion operation needs to be carried out on the hash table, removing the corresponding object from a chain table by utilizing atomic operation; when updating operation needs to be carried out on the hash table, firstly constructing a copy of a to-be-updated object, carrying out updating, and atomically inserting the updated object into the chain table; and realizing the recovery of the deleted object by utilizing a Hazard pointer.

Description

A kind of concurrent Hash table without lock operation method
Technical field
The present invention relates to computerized algorithm field, relate to grasping without lock of a kind of concurrent Hash table that can dynamically expand and reduce Make method.
Background technology
Along with improving constantly of Network Information level, the quantity that information system processes is according to exponential growth, with reality Time be calculated as in the network data processing framework of core, up-to-date data just possess maximum value, the most inevitably use Concurrent Hash table, makes a look up and inserts the operations such as renewal deletion, it is therefore desirable to a kind of quick in multiple threads to Hash table Concurrent Hash table without lock operation method.
Hash table is the data structure directly conducted interviews according to key value.It is to say, it is by key Value is mapped in table a position to access record, to accelerate the speed searched.Traditional concurrent Hash table can use the side of lock Formula realizes synchronizing, and when needing to operate Hash table every time, the most first obtains lock, discharges lock after having operated again.Add lock side Formula has two kinds of spin lock and block type lock etc..Wherein, first kind of way completes with Infinite Cyclic inquiry waiting mode, too much takies Cpu resource, and the second way, easily produce thread or process context switching, reduce processing speed.
Summary of the invention
In order to promote the high efficiency that Hash table is operated by multithreading, solving above-mentioned technical problem, the present invention provides one also Send out Hash table without lock operation method.
The present invention solves above-mentioned technical problem by the following technical programs.
A kind of concurrent Hash table without lock operation method, including update, update operation, deletion action;Wherein:
Update specifically includes following steps:
1.1 obtain the Hash groove that newly inserted element key-value pair is answered, and perform 1.2;
1.2 obtain the gauge outfit of the chained list of storage in Hash groove, perform 1.3;
The value object that 1.3 structures are new, points to the gauge outfit object obtained in 1.2 by the next pointer of object, performs 1.4;
1.4 utilize CAS operation that the pointer in Hash groove is pointed to newly-built object;
Update operation and specifically include following steps:
2.1 key assignments obtaining the element needing renewal, perform 2.2;
2.2 obtain the chained list gauge outfit of storage in the Hash groove that key-value pair is answered, and perform 2.3;
2.3 search the corresponding object needing to update in chained list, perform 2.4;
The copy of 2.4 structure objects, and be updated, perform 2.5;
2.5 will update after object next pointer point to former object next pointer point to object, perform 2.6;
2.6 utilize atomic operation to be inserted in chained list by new object;
Deletion action specifically includes following steps:
3.1 key assignments obtaining the element needing deletion, perform 3.2;
3.2 obtain the chained list gauge outfit of storage in the Hash groove that key-value pair is answered, and perform 3.3;
3.3 search the corresponding object needing to delete in chained list, perform 3.4;
3.4 utilize atomic operation that the next pointer sensing needing to delete the previous object of object is deleted next of object Individual object.
Beneficial effects of the present invention:
The compare_and_swap primitive that the present invention provides based on CPU or operating system, it is achieved inserting of concurrent Hash table Enter, inquire about, the operation such as deletion, it is provided that efficient read-write operation, it is to avoid take excess CPU resources or context switching brings opens Pin.
Detailed description of the invention
For a more detailed description to the present invention below:
When needs carry out update to Hash table, first construct newly-increased value object, and the next in object is referred to Pin points to the object that the pointer in the Hash groove that key-value pair is answered points to, and utilizes atomic operation by the pointer in corresponding Hash groove simultaneously Point to newly-increased object;When needs carry out deletion action to Hash table, utilize atomic operation by corresponding object from chained list Remove;When needs are updated operation to Hash table, first structure needs the copy of the object updated, and is updated, with Time atomically will update after object be inserted in chained list.For deleting the recovery of object, Hazard pointer is utilized to realize.
Compare_and_swap in computer (specifying position, old value, newly value) primitive is used to realize without latching operation, by CPU manufacturer or operating system provide, and when specifying the value shown in position equal to old value, newly value are placed into appointment position, and Return new value, otherwise return old value.
Underneath with specific embodiment to the insertion of Hash table, delete, update operation and be described.
Update is as follows:
(1) obtain the Hash groove that newly inserted element key-value pair is answered, perform (2);
(2) obtain the gauge outfit of the chained list of storage in Hash groove, perform (3);
(3) construct new value object, the next pointer of object is pointed to the gauge outfit object obtained in (2), perform (4);
(4) utilize CAS operation that the pointer in Hash groove is pointed to newly-built object;
Update operation as follows:
(1) obtain the key assignments of the element needing renewal, perform (2);
(2) obtain the chained list gauge outfit of storage in the Hash groove that key-value pair is answered, perform (3);
(3) in chained list, search the corresponding object needing to update, perform (4);
(4) construct the copy of object, and be updated, perform (5);
(5) the next pointer of the object after updating points to the object that the next pointer of former object points to, and performs (6);
(6) atomic operation is utilized to be inserted in chained list by new object.
Deletion action is as follows:
(1) obtain the key assignments of the element needing deletion, perform (2);
(2) obtain the chained list gauge outfit of storage in the Hash groove that key-value pair is answered, perform (3);
(3) in chained list, search the corresponding object needing to delete, perform (4);
(4) utilize atomic operation that the next pointer sensing needing to delete the previous object of object is deleted next of object Individual object.

Claims (1)

1. concurrent Hash table without a lock operation method, including update, update operation, deletion action;It is characterized in that, Wherein:
Update specifically includes following steps:
1.1 obtain the Hash groove that newly inserted element key-value pair is answered, and perform 1.2;
1.2 obtain the gauge outfit of the chained list of storage in Hash groove, perform 1.3;
The value object that 1.3 structures are new, points to the gauge outfit object obtained in 1.2 by the next pointer of object, performs 1.4;
1.4 utilize CAS operation that the pointer in Hash groove is pointed to newly-built object;
Update operation and specifically include following steps:
2.1 key assignments obtaining the element needing renewal, perform 2.2;
2.2 obtain the chained list gauge outfit of storage in the Hash groove that key-value pair is answered, and perform 2.3;
2.3 search the corresponding object needing to update in chained list, perform 2.4;
The copy of 2.4 structure objects, and be updated, perform 2.5;
2.5 will update after object next pointer point to former object next pointer point to object, perform 2.6;
2.6 utilize atomic operation to be inserted in chained list by new object;
Deletion action specifically includes following steps:
3.1 key assignments obtaining the element needing deletion, perform 3.2;
3.2 obtain the chained list gauge outfit of storage in the Hash groove that key-value pair is answered, and perform 3.3;
3.3 search the corresponding object needing to delete in chained list, perform 3.4;
3.4 next ones utilizing atomic operation that the next pointer sensing needing to delete the previous object of object is deleted object are right As.
CN201610377615.5A 2016-05-31 2016-05-31 Lock-free operation method of concurrent hash tables Pending CN106055646A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610377615.5A CN106055646A (en) 2016-05-31 2016-05-31 Lock-free operation method of concurrent hash tables

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610377615.5A CN106055646A (en) 2016-05-31 2016-05-31 Lock-free operation method of concurrent hash tables

Publications (1)

Publication Number Publication Date
CN106055646A true CN106055646A (en) 2016-10-26

Family

ID=57173138

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610377615.5A Pending CN106055646A (en) 2016-05-31 2016-05-31 Lock-free operation method of concurrent hash tables

Country Status (1)

Country Link
CN (1) CN106055646A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019064135A1 (en) * 2017-09-26 2019-04-04 International Business Machines Corporation Open-addressing probing barrier
CN112612803A (en) * 2020-12-22 2021-04-06 浙江大学 Key value pair storage system based on persistent memory and data concurrent insertion method
CN113641871A (en) * 2021-10-18 2021-11-12 北京医百科技有限公司 Lock-free hashing method, device, equipment and medium
CN114553448A (en) * 2020-11-18 2022-05-27 上海汽车集团股份有限公司 Vehicle-mounted network information safety system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101582082A (en) * 2009-06-16 2009-11-18 深圳市茁壮网络股份有限公司 Method and device for dynamically adapting for data by Hash table
CN103886109A (en) * 2014-04-18 2014-06-25 北京搜狐新媒体信息技术有限公司 Method and device for realizing row lock of database
CN104462549A (en) * 2014-12-25 2015-03-25 瑞斯康达科技发展股份有限公司 Data processing method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101582082A (en) * 2009-06-16 2009-11-18 深圳市茁壮网络股份有限公司 Method and device for dynamically adapting for data by Hash table
CN103886109A (en) * 2014-04-18 2014-06-25 北京搜狐新媒体信息技术有限公司 Method and device for realizing row lock of database
CN104462549A (en) * 2014-12-25 2015-03-25 瑞斯康达科技发展股份有限公司 Data processing method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
MICHAEL M M: "High Performance Dynamic Lock-Free Hash Tables and List-Based Sets", 《PROCEEDINGS OF THE 14TH ANNUAL ACM SYMPOSIUM ON PARALLEL ALGORITHMS AND ARCHITECTURES WINNIPEG》 *
SEFLER: "一种基于CAS的无锁并发HashTable设计及C代码实现", 《 HTTPS://BLOG.CSDN.NET/SEFLER/ARTICLE/DETAILS/8779559》 *

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019064135A1 (en) * 2017-09-26 2019-04-04 International Business Machines Corporation Open-addressing probing barrier
US10339066B2 (en) 2017-09-26 2019-07-02 International Business Machines Corporation Open-addressing probing barrier
CN111133424A (en) * 2017-09-26 2020-05-08 国际商业机器公司 Open-addressed probe barrier
GB2579335A (en) * 2017-09-26 2020-06-17 Ibm Open-addressing probing barrier
CN111133424B (en) * 2017-09-26 2023-08-08 国际商业机器公司 Open addressed probe barrier
CN114553448A (en) * 2020-11-18 2022-05-27 上海汽车集团股份有限公司 Vehicle-mounted network information safety system
CN114553448B (en) * 2020-11-18 2024-05-17 上海汽车集团股份有限公司 Vehicle-mounted network information security system
CN112612803A (en) * 2020-12-22 2021-04-06 浙江大学 Key value pair storage system based on persistent memory and data concurrent insertion method
CN112612803B (en) * 2020-12-22 2022-07-12 浙江大学 Key value pair storage system based on persistent memory and data concurrent insertion method
CN113641871A (en) * 2021-10-18 2021-11-12 北京医百科技有限公司 Lock-free hashing method, device, equipment and medium

Similar Documents

Publication Publication Date Title
JP6998928B2 (en) Methods, appliances, equipment, and media for storing and querying data
CN105630863B (en) Transaction control block for multi-version concurrent commit status
CN103955486B (en) Distribution service and its data update, the method for data query
US9047330B2 (en) Index compression in databases
CN102110121B (en) A kind of data processing method and system thereof
CN106021267B (en) To the method and system for concurrently reading and being inserted into of data structure
EP3519986B1 (en) Direct table association in in-memory databases
US9734223B2 (en) Difference determination in a database environment
US8620924B2 (en) Refreshing a full-text search index in a partitioned database
CN106055646A (en) Lock-free operation method of concurrent hash tables
US20150269215A1 (en) Dependency-aware transaction batching for data replication
CN105630864A (en) Forced ordering of a dictionary storing row identifier values
CN105630860A (en) Database system with transaction control block index
CN104598519B (en) A kind of database index system and processing method based on contiguous memory
US20150278268A1 (en) Data encoding and corresponding data structure
EP3365803A1 (en) Parallel execution of queries with a recursive clause
US20150370838A1 (en) Index structure to accelerate graph traversal
CN105117417A (en) Read-optimized memory database Trie tree index method
US8386445B2 (en) Reorganizing database tables
US11269954B2 (en) Data searching method of database, apparatus and computer program for the same
CN104871153B (en) Method and system for distributed MPP database
CN104750720A (en) Method for achieving high-performance data processing under multithread concurrent access environment
CN104111936A (en) Method and system for querying data
CN105095425A (en) Cross-database transfer method and device for databases
CN109815240A (en) For managing method, apparatus, equipment and the storage medium of index

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20161026