Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6156657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:38:53+00:00 2026-05-23T20:38:53+00:00

If anybody has had a lot of experience timing code running on the main

  • 0

If anybody has had a lot of experience timing code running on the main VCL thread vs a background thread, I’d like to get an opinion. I have some code that does some heavy string processing running in my Delphi 6 application on the main thread. Each time I run an operation, the time for each operation hovers around 50 ms on a single thread on my i5 Quad core. What makes me really suspicious is that the same code running on an old Pentium 4 that I have, shows the same time for the operation when usually I see code running about 4 times slower on the Pentium 4 than the Quad Core. I am beginning to wonder if the code might be consuming significantly less time than 50 ms but that there’s something about the main VCL thread, perhaps Windows message handling or executing Windows API calls, that is creating an artificial “floor” for the operation. Note, an operation is triggered by an incoming request on a socket if that matters, but the time measurement does not take place until the data is fully received.

Before I undertake the work of moving all the code on to a background thread for testing, I am wondering if anyone has any general knowledge in this area? What have your experiences been with code running on and off the main VCL thread? Note, the timing measurements are being done when there is absolutely no user triggered activity going on during the tests.

I’m also wondering if raising the priority of the thread to just below real-time would do any good. I’ve never seen much improvement in my run times when experimenting with those flags.

— roschler

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:38:54+00:00Added an answer on May 23, 2026 at 8:38 pm

    Without simple source code to reproduce the issue, and how you are timing your threads, it will be difficult to understand what occurs in your software.

    Sounds definitively like either:

    • An Architecture issue – how are your threads defined?
    • A measurement issue – how are you timing your threads?
    • A typical scaling issue of both the memory manager and the RTL string-related implementation.

    About the latest point, consider this:

    • The current memory manager (FastMM4) is not scaling well on multi-core CPU; try with a per-thread memory manager, like our experimental SynScaleMM – note e.g. that the Free Pascal Compiler team has written a new scaling MM from scratch recently, to avoid such issue;
    • Try changing the string process implementation to avoid memory allocation (use static buffers), and string reference-counting (every string reference counting access produces a LOCK DEC/INC which do not scale so well on multi-code CPU – use per-thread char-level process, using e.g. PChar on static buffers instead of string).

    I’m sure that without string operations, you’ll find that all threads are equivalent.

    In short: neither the current Delphi MM, neither the current string implementation scales well on multi-core CPU. You just found out a known issue of the current RTL. Read this SO question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to hear if anybody has had luck with installing HgEclipse on
Has anybody had the experience of Local Notifications being delivered from an app that
Has anybody had any experience editing a docx template. My php admin area needs
Has anybody had issues with this? If so, how do you get around it?
Has anybody had any experience accessing the Autocad or Inventor API with Clojure?
I'm wondering if anybody has had any experience in trying to install SQL Server
Has anybody had any hands-on experience using Devexpress ASP.NET components with Delphi Prism? At
Has anybody had any experience with COM / MFC trying to implement IConnectionPointContainer on
Hi I'm wondering if anybody has had any experience querying a Team Foundation Server
Does anybody has an experience with Spring Integration project as embedded ESB? I'm highly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.