Skip to content

Loading time of 2MB ML model is significantly slower in .NET Core compared to .NET Framework #5913

Closed

Description

@martintomasek

System Information (please complete the following information):

  • OS & Version: Windows 10
  • ML.NET Version: ML.NET v1.6
  • .NET Version: .NET Core 3.1, .NET 5.0

Describe the bug
We have approx 2MB trained ML model for binary classification. When we are loading model it takes to load it 2s in average on .NET 5. When we run on .NET Framework, it takes only 0,5s.

To Reproduce
Steps to reproduce the behavior:

  1. Load bigger ML model with method "mlContext.Model.Load()"

Expected behavior
Model loading time should be similar like in .NET Framework

Screenshots, Code, Sample Projects

		private static PredictionEngine<ModelInput, ModelOutput> GetPredEngine()
		{
			MLContext mlContext = new MLContext();

			// Load model & create prediction engine
			ITransformer mlModel = mlContext.Model.Load(MLNetModelPath, out var modelInputSchema);
			var predEngine = mlContext.Model.CreatePredictionEngine<ModelInput, ModelOutput>(mlModel);
			return predEngine;
		}

Additional context
When I add BufferedStream for loading from DeflateStream in BinaryLoader, it looks the issue is solved.
BinaryLoader commit
I could do a pull request.

Activity

  1. added
    bug
    on Sep 2, 2021
  2. michaelgsharp commented on Sep 2, 2021

    @michaelgsharp
    Contributor

    This is very interesting. Thanks for doing the testing and figuring out the issue. You commit looks good to me but I'll do some more testing.

    @eerhardt is this slowdown a known issue between .NET Framework and .NET Core? Or do you think something else is maybe at play here?

  3. eerhardt commented on Sep 2, 2021

    @eerhardt
    Member

    Might be related to dotnet/runtime#39233? Looks super similar.

  4. rosebyte commented on Sep 3, 2026

    @rosebyte
    Member

    This was fixed by #5924, which added a buffered stream when reading compressed model data.

  5. locked and limited conversation to collaborators on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions