Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Reading the Form data goes to disk every time #343

Closed
rynowak opened this issue Jul 8, 2015 · 4 comments
Closed

Reading the Form data goes to disk every time #343

rynowak opened this issue Jul 8, 2015 · 4 comments

Comments

@rynowak
Copy link
Member

rynowak commented Jul 8, 2015

Found while profiling simple model binding scenarios in MVC

BufferingHelper.EnableRewind will do a check for the existence of the temp directly on each request, even when there isn't enough data to force a write to disk.
https://github.com/aspnet/HttpAbstractions/blob/dev/src/Microsoft.AspNet.Http/BufferingHelper.cs#L40

Discussed with @Tratcher - we can have this wait until a write is actually needed to do the write, or even ask forgiveness instead of asking permission.

@rynowak
Copy link
Member Author

rynowak commented Jul 8, 2015

image

In the context of this profile - 100% means the time inside Middleware (includes Files, Routing, MVC). Fully 20% of the app's time is spent enabling buffering for about 50 char of text.

@davidfowl davidfowl added the Perf label Jul 10, 2015
@davidfowl
Copy link
Member

The CreateTempFile() in FileBufferingReadStream should do this work.

@Tratcher
Copy link
Member

Or change BufferingHelper.TempDirectory to cache. It's not like this is going to change much. It's the Directory.Exists check that's showing up in the profiles.

@davidfowl
Copy link
Member

I still think it should be lazy. Do both things. I'm not sure why it would even throw unless you actually needed to write to that directory.

@glennc glennc added this to the 1.0.0 backlog milestone Aug 11, 2015
@rynowak rynowak self-assigned this Aug 28, 2015
rynowak added a commit that referenced this issue Aug 28, 2015
This change tries to avoid looking up the TEMP directory for most reads of
the form data. We'll now only hit the disk when necessary.
@davidfowl davidfowl modified the milestones: 1.0.0-beta8, 1.0.0 backlog Aug 30, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants