performance - Delphi 7, Windows NT Service, Console App -
i have delphi 7 32bit application. windows 7 64bit.
everything runs fine. have been investigation performance issues i've noticed.
a brief overview of application -->
has command-line / console app executable, written in delphi. creates multi-threaded set of connections , database work. nt service, written in delphi (which calls command-line application), based on schedules of jobs finds. done via phone call our dll, finds , executes createprocess commandline application, , waitforsingleobject finish. effectively, service responsible finding when work needs done, , callin executable/console app it.
here's problem, cannot seem figure out.
if run command-line application, 4x faster result if nt service phone call via createprocess. identical code. 1 dos prompt issuance of exe, other nt service, loads dll, calls createprocess same executable.
i going bananas. cannot see reason this.
i can reproduce on scheme configuration far.
what i've noticed far (not scientific, relevant imo).
if monitor cpu cores cpu time , kernel time, console app has fraction of kernel time during life-time of execution. when scheduler service runs this, kernel time represents 50-70%% or more of whatever cpu % utilize getting.
some actual results (everything else irrelevant believe) - console app, run through commandline: 26 seconds - console app, run through service via createprocess: 113 seconds
what gives?
i've looked perhaps fastmm isnt beingness shared properly. believe is. remoed it. same anomalies. i've looked perhaps fastcode, fastmove stuff isnt working under service (since @ startup, trying dynamically hook/replace core rtl functions. removed them equation, same anomalies. i've looked removing our patched rtl (system.dcu/sysinit.dcu) files. no joy.
all no avail.
so, questions (and solicitation possible reasons), ...
does nt service preclude ability perform automation/hook replacement features? delphi services create cause this? there sort of inherent overhead -- (and huge amount) services? there alternatives using fastmm, fastcode, fastmove others have used because of of nature?
thanks in advance guidances/helpers here.
here's snippet of code used launch app nt service.
fillchar(si, sizeof(si), 0); si.dwflags := sw_hide; fillchar(pi, sizeof(pi), 0); scommandline := format('"%s" "%d"', [extractfilepath(paramstr(0)) + 'myapp.exe', ajobid]); if createprocess(pchar(sfilename), pchar(scommandline), nil, nil, false, 0, nil, nil, si, pi) begin waitforsingleobject(pi.hprocess, infinite); getexitcodeprocess(pi.hprocess, exitcode); result := (exitcode = 0); end else begin addeventlogmessage(syserrormessage(getlasterror)); end;
it turns out issue related utilize of connections, , sharing connection.
once took approach of destroying connection on scheduler before launching createprocess, kernel usage inline seeing when running straight console.
very surprising, given connection not shared commandline doing.
future reference: sure eliminate variables before saying 2 approaches identical. in this, not. scheduler had connection, console app did not. , difference.
performance delphi delphi-7