-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Great performance drop #836
Comments
Hi @pazicb, I don't know about this different between beta and final, but using this way is normal this large time consume. Each insert will write on disk. Try use In this example I got 123ms to insert 1000 documents. Here my full test: namespace LiteDB.Demo
{
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public string[] Phones { get; set; }
public bool IsActive { get; set; }
}
class ProgramCustomer
{
static void Main(string[] args)
{
var timer = new Stopwatch();
File.Delete(@"MyData.db");
timer.Start();
using (var db = new LiteDatabase(@"MyData.db"))
{
var customers = db.GetCollection<Customer>("customers");
customers.Insert(GetCustomers());
}
timer.Stop();
Console.WriteLine("Done in {0}ms", timer.ElapsedMilliseconds);
Console.WriteLine("End");
Console.ReadKey();
}
public static IEnumerable<Customer> GetCustomers()
{
for (int i = 0; i < 1000; i++)
{
yield return new Customer
{
Name = "John Doe",
Phones = new string[] { "8000-0000", "9000-0000" },
IsActive = true
};
}
}
}
} I'm testing in |
Thank you, I understand your example. I just do not know why the writing speed dropped 150 times. The speed of 13 records per second is very small even when I write to disk. When do you release version 4.1? |
In version litedb 4.0 my example uses 95% of disk performance for 75,000 ms. For versions 4.0 beta2 and below, the disk usage is minimal. |
Hi @pazicb, using v4 from nuget I got this times: Insert IEnumerable done in 106ms Here my example: https://gist.github.com/mbdavid/d62683b9752f7d693a13cfd00a2a2ee6 |
If disable journal file, time drop to: Insert IEnumerable done in 105ms |
Now, if I increase to 10.000 custumers: (journal=true) Insert IEnumerable done in 279ms (journal=false) I'm running in dell notebook: Windows 10 + I7 - 7500U CPU @ 2.70GHz - 2.9Ghz + 16Gb RAM + SSD disk |
Thank you so much. I have very similar times with 4.0 beta 2. When I download version 4.0 release, I get this: |
Hi @pazicb, here full project solution with dll included. I used nuget to get this 4.0.0 |
Thank you. LiteDb .NET 3.5 works correctly. NET 4.0 has the above-described problem. |
Hi @pazicb, can you upload your zip project to test here? |
I'm testing your code. |
Hi @pazicb, I'm still getting same results with your code: 660ms |
Hello, don't you see any differences between using NET 3.5 and NET 4.0.? I tested it on 5 computers and there was always a big difference. Can you use a disk other than SSD for testing? E.g. Flash disk. |
This caught my attention, just curious - I quickly tested "test1.zip" project using NET 3.5 and NET 4.5 on RAM disk (almost same performance) and standard HDD and there is 10 times difference between NET 3.5 and NET 4.5 (4.5 being ~10x slower on standard HDD than NET 3.5) (3241 vs 327) For project: TestLitePerformance.zip (Standard HDD) |
Hi @Otw-cz, I didn't test yet on standard HDD because I don't have. I will mount an Azure VM for that. There are, in code, few differences between LiteDB for NET35 e NET40. And this difference is only about serialization way (in NET35 uses Reflection and NET40 use Expression - which are faster). About disk read/write/lock, there is no changes in code. You test in RAM disk not using MemoryStrem() initializer, right? This is a complete different way to read/write access. Much more simple with no locks... |
I used RAM disk aka sotware emulated "drive" in RAM memory, sice I don't have SSD :-) (not MemoryStream) (CPU i5-3230m) (May be Framework issue? It looks like it does significantly more disk I/O under NET > 3.5 - which does matter on standard HDD, but not on SSD/RAM) |
Hello, it looks like SSD and RAM are all right. Every HDD I tested had a problem. The worst result was a 150x slowdown. |
Hello, here's a note. The problem occurred in version 4.0. Version 4.0 beta 2 is fine, just like version 3.5. |
Hi @pazicb, I was checking changes between this versions. I think here can be the problem: // v4.x
return new FileStream(path, mode, access, share,
BasePage.PAGE_SIZE,
System.IO.FileOptions.RandomAccess);
// v3.x
return new FileStream(path, mode, access, share,
BasePage.PAGE_SIZE); https://github.com/mbdavid/LiteDB/blob/master/LiteDB/Engine/Disks/FileDiskService.cs#L315 Can you remove this |
Hello, unfortunately this change did not help. Try the Flash Drive for testing. |
Hi, the error is probably causing _stream.Flush(true). public void Flush() #if HAVE_FLUSH_DISK |
hummm... that's make all sense... because in beta, there is no Did you test in HDD removing this |
I did test on HDD removing the "true" parameter and this seems to be the "issue" - at least TEST times are now on par with RAM drive. The question remains - I'm no expert but I guess without "true" it's not being written to the file at that moment (stays in disk cache)? |
@Otw-cz, using this true parameter, flush operation occurs immediately and all buffer are write into disk. I didn't know that are too much impact in HDD disks (because SSD has no difference). |
Hi, I've also tested it and it was good. Look at: https://stackoverflow.com/questions/4921498/whats-the-difference-between-filestream-flush-and-filestream-flushtrue |
Hi! With the objective of organizing our issues, we are closing old unsolved issues. Please check the latest version of LiteDB and open a new issue if your problem/question/suggestion still applies. Thanks! |
Hello,
I have a problem, see the example below. In version 4.0.0-beta2 this is done in 500 ms.
In version 4.0 this is done in 75000 ms. Why has dramatically reduced performance?
Thank you for answer.
The text was updated successfully, but these errors were encountered: