Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 06/07/24 in all areas

  1. Stefan Glienke

    Parallel.ForEach is really slow

    I can absolutely repro - all my 20 logical cores (i5-13600k) go to 100% for 10 seconds. Running it through SamplingProfiler right now to check. Edit: Okay, either this has regressed at some point after the demo was originally built or it was overlooked that there is actually no real workload inside of the delegate and thus it just measures the huge overhead from RTL and interlocked operations. It's just spending a huge amount of time wrapping and unwrapping the integer from TOmniValue and sharing the counter across all threads causing a complete bus lock every time due to the usage of DSiInterlockedExchangeAdd64 (*). (*) I wrote bus lock and this is not entirely true, so before anyone chimes in quoting the Intel manual about the fact that the lock prefix does not automatically cause a bus lock - you are correct. Here we have the case that we are sharing the one variable across all the cores we have so it has to travel back and forth the CPU caches to and from RAM. This code as is would be a nice worst-case example for Primoz' book about what can potentially go wrong when doing parallel programming. However: keep in mind that we don't have any real workload which would most likely change the picture as the workload usually takes the majority of processing time and not the parallel foreach code. P.S. Among the aforementioned things it looks like the OTL code (particularly TOmniValue) is suffering from some overhead caused by inlining. For example: because TOmniValue.AsInt64 as well as TOmniValue.TryCastToInt64 is inlined it causes the temporary Variant variable it needs for the otvVariant case to be spilled into the location where the inlining happens. But in our case we never have to even deal with a Variant hence all the extra code the compiler produces is just overhead. And because the getter for AsInt64 is used twice, the compiler repeats the inlined code twice and produces two Variant variables which it finalizes using System.FinalizeArray. Also a lot of record initialization and finalization is happening which I assume (did not look closer) is being caused by TOmniValue - potentially also because of some temporary compiler generated variables. Here is the drilldown of the interesting pieces when running in SamplingProfiler:
  2. Angus Robertson

    Upgrade from delphi 6 to delphi12

    What specific new features and performance improvements are you looking for? What is the business case for the major effort a migration would involve? This is many weeks or months of work, and retesting. All your other questions have been covered in detail over the last 15 years as others have migrated from non-unicode compilers to modern Delphi. I've just released a new version of one of my products built with Delphi 2007 because of third party component problems with Delphi 11. The end users don't care. Angus
  3. In the attachment you can find a high-level interface-based encapsulation of the Direct2D SVG functionality. It allows you to parse SVG files and draw them to a GDI/GDI+ DC. Requires Windows 10 with Creators Update or later. Main form code to display SVG files: { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin fSVG := GetD2DSVGHandler.NewSvg; fSVG.LoadFromFile('..\..\browser.svg'); //fSVG.FixedColor := TAlphaColorRec.Red; //fSVG.Opacity := 0.5; fSVG.GrayScale := True; end; procedure TForm1.Paint; begin inherited; fSvg.PaintTo(Canvas.Handle, TRectF.Create(ClientRect), True); end; procedure TForm1.Resize; begin inherited; Invalidate; end; Features: Scale to any size Keep aspect ratio (optionally) Control opacity Recolor to any color Draw in gray scale Samples: The above in grayscale: Svg.zip
  4. Dave Nottage

    ffmpeg compression in android and ios

    Not sure this will help you, but I have added a function just yesterday to copy large files that have been selected using TFilesSelector. It is the class function TAndroidFileStream.Copy (in DW.Android.Helpers), which can be called like this: TAndroidFileStream.Copy(LRawPath, LFileName); Where LRawPath contains the raw URI for the selected file, and LFileName contains the destination file path Please be aware that copying a large file can take several seconds (in my test, a 2.5GB file took 7 seconds on my Pixel 6 Pro), so you may want to pass that task off to a thread. Surely you'll need to actually have the file in order to compress it anyway?
  5. Die Holländer

    DelphiLint v1.1.0 out now!

    Yes, I have divided my code in business objects, data objects, form and project directories. I've changed the "project directory" in DelphiLint to one of these directories and that worked fine ! I have to say that DelphiLint is one of the nicest Delphi tools I've seen for a long time. 👍
  6. Jasja

    Android app does not start after migration to Delphi 11

    Fixed it: If you encounter this issue open the project's .dproj file with notepad and search for the <EnabledSysJars> tag. Remove the content between the <EnabledSysJars></EnabledSysJars> tag. and save the file. Building should work now.
  7. While the above is valid for record helpers, it is indeed possible to extend class helpers. (It es even documented: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Class_and_Record_Helpers_(Delphi)#Helper_Syntax) In this example we extend the existing class helper TRESTRequestParameterHelper from REST.Client.pas (Delphi 11) with another method without hiding the ContentType member of TRESTRequestParameterHelper. type TMyRESTRequestParameterHelper = class helper (TRESTRequestParameterHelper) for TRESTRequestParameter procedure MyTest; end;
  8. I am not sure many know that since the Windows Creators update, svg parsing and painting is natively supported and is part of Direct2D. I wanted to test this Windows feature, however, the first obstacle was that the Direct2d headers that come with Delphi are very very old. There are two open tickets in https://quality.embarcadero.com/. Direct2D 1.1 support missing (open since XE7!) Direct2D 1.2 and 1.3 support missing You may want to vote for them, since lack of good Direct2D support (includes DirectWrite) it is a bit of a shame. I then looked at other Direct2D translations and found two that are regularly updated. MfPack DelphiDX12 They both had some issues but that was a good start. It turned out that parsing and painting svg files to Canvas is quite straightforward. Once you establish a renderer (Vcl.Direct2d does this, but it is easy to do it from scratch) you can do everything with two lines of code. fDeviceContext5.CreateSvgDocument(fStream, D2D1SizeF(ClientWidth, ClientHeight), fsvgDocument); fDeviceContext5.DrawSvgDocument(fsvgDocument); You can check whether Svg is supported by: if Supports( rt, ID2D1DeviceContext5, fDeviceContext5) then And it is easy to do things like scaling, opacity, rotation, recoloring etc. The quality and speed appear to be quite good, but there are some limitations, the most important of which I think is the lack of support for the text element. I am attaching the source code of my test project (no dependencies) in case anyone wants to play with it. The Svg scales automatically as you resize the form. Svg.zip
×