Home
Options

LPRun7 startup performance

edited September 2023

Hello, I'm using LPRun package to run driver unit tests, (it basically executes something like LPRun7.exe "path\to\file.linq"), I can see that compilation of each of the scripts takes about ~3-4 seconds before actually running it, while in LINQPad they execute instantaneously (<0.1 sec). Is it possible to somehow NGen/Crossgen assemblies that are used by LPRun to speed up the compilation or are there any other steps I can take to make it faster?

Comments

  • Options

    It sounds like the queries are being modified/touched between executions, which would prevent LPRun from caching the compilations.

    Given that you're executing multiple scripts, you can improve performance significantly by using Util.Run instead of LPRun. You can call Util.Run from another LINQPad script (which you can call via LPRun), or from a Visual Studio project that references LINQPad.Runtime.dll (or the LINQPad.Runtime NuGet package).

    The advantage of Util.Run is that the Roslyn assemblies remain loaded to execute subsequent scripts. Another benefit is that you can get a typed return value back from the query.

  • Options
    edited September 2023

    Thanks! I switched to Util.Run. One more question, how can I get typed result from Util.Run when my query is async? I tried Util.Run(filePath, QueryResultFormat.Csv).ReturnValue but for async query it returns

    Cannot deserialize ReturnValue: Type 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[UserQuery+<Main>d__5, LINQPadQuery, Version=1.0.0.2, Culture=neutral, PublicKeyToken=null]]' is not marked as [Serializable]. 
    

    for script like

    async Task<object> Main (string[] args)
    {
        return 1;
    }
    

    For sync query return works as expected.

    Also for some reason when I run await Util.Run(filePath, QueryResultFormat.Csv).ReturnValueAsync the driver's GetSchemaAndBuildAssembly is called two times, but when I call only Util.Run(filePath, QueryResultFormat.Csv) it is called just once, is it by design? Can I somehow only call driver method once and get a result?

  • Options

    The task serialization issue is a bug that will be fixed in the next build.

    I cannot reproduce GetSchemaAndBuildAssembly being called twice. Which driver is it?

  • Options

    https://github.com/romfir/OpenApiLINQPadDriver/tree/tests
    On this branch GetSchemaAndBuildAssembly will write logs to log.txt on user desktop, while running a single test I can see that logs are doubled. I've noticed that it only happens when I use QueryExecuter.ReturnValueAsync or QueryExecuter.ExceptionAsync on object returned from QueryCompilation.Run (https://github.com/romfir/OpenApiLINQPadDriver/blob/b27552bd62e558512f704f548b600ddb0f0d44fa/Tests/OpenApiLINQPadDriverTests/Utils/QueryExecutor.cs#L45C11-L48C68). Is there other way to run a script and get return value or an exception?

Sign In or Register to comment.