Jump to content

Recommended Posts

On 4/9/2025 at 6:41 AM, RDP1974 said:

I asked the old good chatgpt :classic_blink:
 

What I posted here I also tried with ChatGPT and here we are.
 

I use the free plan and in general didnt get good answers for real world problems or context needed problems. Of course my prompt may be not good at all.

 

I mainly use to understand something or get some examples, but (at least for Delphi) the code generated generally doesnt work. Now imagine for a optimized code…

Well, its my experience till now.

 

But its not the topic subject…

Share this post


Link to post
1 minute ago, Anders Melander said:

Yes it does - but map2pdb just produces the pdb files required by the profilers.

Profilers that works with pdb files includes Intel VTune and AMD μProf.

 

I believe μProf works with both Intel and AMD processors while VTune only works with Intel processors but use the one that matches your processor to get the most precise results.   I use VTune myself.

 

Ask if you need instructions on how to get started. The process is very easy once you know how to do it but it can be challenging to get to that point 🙂

Good, I’ll try out with Intel VTune since my processor is Intel.

 

I’ll try the instructions in your post and repo, if I got doubts I ask you in PM. Really thanks!

Share this post


Link to post
1 hour ago, snowdev said:

that only works for Maintthread functions

It works very well for multithreading. You just have to change the sampling mode.

  • Like 2

Share this post


Link to post
Posted (edited)

hi, I wish to not be offtopic, and to be useful

anyway there https://github.com/RDP1974/Delphi64RTL I have added concurrent queue, thread safe, from OneApi v2022.1

also a small test there (single thread, create and dispose string, 10M push + 10M pop within 1 sec)(I have not time to do multithread test now)

kind regards

btw. this repo is a base for a mine custom server reactor+proactor done in Delphi

Edited by RDP1974

Share this post


Link to post
Posted (edited)
On 4/9/2025 at 11:14 AM, Stefan Glienke said:

I don't step into that territory because you cannot simply make general-purpose collections thread-safe. It already starts with simple things like: how do you protect a list where one thread adds/removes items and another iterates over it?

oneapi tbb concurrent hash map when call iterate() does a snapshot copy of the collection and publish it, meantime protecting keys with acc (similar to critical section)

btw. concurrent_queue test with 10 threads is 3x quicker than TOmniQueue, and unfortunately TThreadedQueue goes in deadlock

Edited by RDP1974

Share this post


Link to post

Just an update here. 

 

I refactoring the entire application into the MVC pattern for better maintability and improve the codebase, and I just forgot the use of interfaces as transport objects.

 

Just for refreshing, nowdays I use TObject descendents which need the object releasing to manage the memory, as the queue manages the object lifetime I must clone objects when transporting information between threads.

 

I never used interfaces for those kind of task (transport information between threads)... may I get into troubbles switching from TObject to interface based queue?

 

In my benchmarks the difference isn't a big deal... but the tests run transporting data over only two threads, in my application the data can be transported between two or three threads, which means more object clonning overhead.

 

I also tested the suggested ring buffer like as queue, but the differences aren't huge either, even compared with a TQueue<T> with a lock object... and this comes to my second question. I always use lock objects (generally TCriticalSection) when working with threads and I not sure if the data is thread-safe. In my threaded queue I have other threads pushing items in the TQueue, and the thread itself consuming them, in my mind make sense using lock objects to push and pop items as other threads also access the TQueue, why a ring buffer bases queue wouldn't needed?

@Anders Melander, the Intel VTune works fine with your solution. Thanks.

 

Thanks in advance.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×