Click here to Skip to main content
15,898,943 members
Home / Discussions / C#
   

C#

 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Luc Pattyn6-Jan-09 22:58
sitebuilderLuc Pattyn6-Jan-09 22:58 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Cyrilix6-Jan-09 23:28
Cyrilix6-Jan-09 23:28 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Luc Pattyn6-Jan-09 23:36
sitebuilderLuc Pattyn6-Jan-09 23:36 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Cyrilix7-Jan-09 1:18
Cyrilix7-Jan-09 1:18 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Luc Pattyn7-Jan-09 1:58
sitebuilderLuc Pattyn7-Jan-09 1:58 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Daniel Grunwald7-Jan-09 2:37
Daniel Grunwald7-Jan-09 2:37 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Cyrilix7-Jan-09 9:02
Cyrilix7-Jan-09 9:02 
GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
ben.Kloosterman2-Feb-10 19:53
ben.Kloosterman2-Feb-10 19:53 
Its not so much the fact that its lockless but the implementation is slow.. Each enqueue and dequeue here require adding a new class ( which is the node) , a new is VERY expensive and uses a lock around the GC allocator. So you have removed the lock around enqueue and dequeue but hit the worse GC lock. A per formant lock less queue would pre-create and re-use its nodes OR manage its own memory with structs and unsafe. An array based queue would not require new nodes and only needed to new when growing the array and hence would offer much better base performance but is harder to make lock less.

secondly you are making it worse with a second interlock. Interlocks are not cheap they cause the pipeline to stall and lock they are cheaper than a full lock , note however most full locks just use an interlock on a variable and block if it is in use , since an enqueue without a new is FAST the lock will not really be active long and the other lock implementations ends up just being an interlock compare.

Now adding to a queue is probably a very cheap operation maybe 10 cycles so probably no contention with only 5 threads if they do normal work. ( In a bench mark it generate contention but this is not a real scenario a program would spend very little time doing the enqueue and dequeue.

Ben

GeneralRe: Lockless Queue in C# slower than Locked Queue in C# Pin
Cyrilix3-Feb-10 7:40
Cyrilix3-Feb-10 7:40 
Questionconverting c header file in c# Pin
lawrenceinba6-Jan-09 20:31
lawrenceinba6-Jan-09 20:31 
AnswerRe: converting c header file in c# Pin
N a v a n e e t h6-Jan-09 20:48
N a v a n e e t h6-Jan-09 20:48 
AnswerRe: converting c header file in c# Pin
Guffa6-Jan-09 20:52
Guffa6-Jan-09 20:52 
GeneralRe: converting c header file in c# Pin
lawrenceinba6-Jan-09 20:59
lawrenceinba6-Jan-09 20:59 
GeneralRe: converting c header file in c# Pin
N a v a n e e t h6-Jan-09 21:14
N a v a n e e t h6-Jan-09 21:14 
GeneralRe: converting c header file in c# Pin
lawrenceinba6-Jan-09 21:19
lawrenceinba6-Jan-09 21:19 
GeneralRe: converting c header file in c# Pin
Dragonfly_Lee6-Jan-09 22:24
Dragonfly_Lee6-Jan-09 22:24 
GeneralRe: converting c header file in c# Pin
lawrenceinba6-Jan-09 22:35
lawrenceinba6-Jan-09 22:35 
GeneralRe: converting c header file in c# Pin
Dragonfly_Lee6-Jan-09 22:46
Dragonfly_Lee6-Jan-09 22:46 
AnswerRe: converting c header file in c# Pin
Rob Philpott6-Jan-09 23:00
Rob Philpott6-Jan-09 23:00 
GeneralRe: converting c header file in c# Pin
Luc Pattyn6-Jan-09 23:11
sitebuilderLuc Pattyn6-Jan-09 23:11 
GeneralRe: converting c header file in c# Pin
lawrenceinba6-Jan-09 23:27
lawrenceinba6-Jan-09 23:27 
QuestionFast string to integer conversion Pin
HosamAly6-Jan-09 19:58
HosamAly6-Jan-09 19:58 
AnswerRe: Fast string to integer conversion Pin
N a v a n e e t h6-Jan-09 21:10
N a v a n e e t h6-Jan-09 21:10 
GeneralRe: Fast string to integer conversion Pin
HosamAly6-Jan-09 22:29
HosamAly6-Jan-09 22:29 
GeneralRe: Fast string to integer conversion Pin
J4amieC6-Jan-09 23:08
J4amieC6-Jan-09 23:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.