【问题标题】:ArangoDb .Net driver performanceArangoDb .Net 驱动程序性能
【发布时间】:2015-01-12 05:28:27
【问题描述】:

我正在尝试新的 ArangoDb-Net 重新实现驱动程序 https://github.com/yojimbo87/ArangoDB-NET/tree/reimplement。今天是我第一次尝试表演。当我使用 araongosh 执行插入时。它每秒可以插入大约 5000 条记录。但是,当我使用 .Net 驱动程序执行相同的更新时。我花了大约 2 分钟来执行相同的插入。我可以知道我做错了什么吗?谢谢。

[编辑] 完成问题with the github discussion 我已经用我的 arangosh 测试了下面的代码

count=1;
startTime=+new Date();
console.log(startTime);
while(count <= 10000)
{
db.someCollection.save({"Id":"1234567890123456789012345678901234",
            "Key":1234567,
            "Revision":1234567,
            "Name":"Mohamad Abu Bakar",
            "IC Number":"1234567-12-3444",
            "Department":"IT Department",
            "Height":1234,
            "DateOfBirth":"2015-01-27 03:33",
            "Salary":3333});
    count++;
}
endTime=+new Date();
console.log(endTime);
console.log("Total time taken:" + (endTime - startTime)/1000);

完成操作耗时 3.375 秒。

我用 .Net 驱动程序做了类似的事情,它花了将近 9.5797819。几乎是阿兰戈什的三倍。这是.Net中的代码:

public static void TestArangoDb()
{
    //ASettings.AddConnection("_system", "127.0.0.1", 8529, false, "_system");
    //var db = new ADatabase("_system");
    //db.Create("trial_sample");

    ASettings.AddConnection("trial_sample",
                           "127.0.0.1", 8529, false, "trial_sample");
    var db2 = new ADatabase("trial_sample");

    db2.Collection.Create("someCollection");

    DateTime startTime = DateTime.Now;
    Console.WriteLine("Start Time: " + startTime.ToLongTimeString());

    for(int count=1; count <= 10000; count++)
    {
        var employee = new Employee();
        employee.Id = "1234567890123456789012345678901234";
        employee.Key = "1234567";
        employee.Revision = "1234567";
        employee.Name = "Mohamad Abu Bakar";
        employee.IcNumber = "1234567-12-3444";
        employee.Department = "IT Department";
        employee.Height = 1234;
        employee.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3);
        employee.Salary = 3333;
        var result = db2.Document.Create<Employee>("someCollection", employee);

        //var updateDocument = new Dictionary<string, object>()
        //    .String("DocumentId", "SomeId");
        //db2.Document.Update(result.Value.String("_id"), updateDocument);
    }

    DateTime endTime = DateTime.Now;
    TimeSpan duration = endTime - startTime;
    Console.WriteLine("End Time: " + endTime.ToLongTimeString());
    Console.WriteLine("Total time taken: " + duration.TotalSeconds);
}

public class Employee 
{
    public string Id { get; set; }
    public string Key { get; set; }
    public string Revision { get; set; }
    public string Name { get; set; }
    public string IcNumber { get; set; }
    public string Email { get; set; }
    public string Department { get; set; }
    public double Height { get; set; }
    public DateTime DateOfBirth { get; set; }
    public decimal Salary { get; set; }
}

如果我删除以下评论:

var updateDocument = new Dictionary<string, object>()
    .String("DocumentId", "SomeId");

db2.Document.Update(result.Value.String("_id"), updateDocument);

性能几乎是 30 倍。完成耗时 99.8789133 秒。事实上,我只是执行额外的更新来添加额外的列。

您能就上面代码中的问题提出建议吗?谢谢。

【问题讨论】:

  • 您能提供您通过驱动程序插入的数据的示例吗? 2 分钟内完成了多少次插入?这可能是一个较长的讨论,所以我建议在 ArangoDB 谷歌群组上讨论它,一旦问题解决,答案将在这里发布。
  • 当然。我将在 google 群组中发布我的问题。
  • 您能否发布指向 google 小组主题的链接,以便我们在本网站上查看除了最终答案之外的讨论吗?
  • 这仍然是一个问题吗?我在 google 群组中找不到主题
  • 这可能是arangosh为此做了多少请求的问题;也许 Wireshark 可以告诉你更多信息?由于最近没有反馈,这仍然是一个问题吗?

标签: arangodb


【解决方案1】:

yojimbo87 更深入地研究了这个问题。测试不同的层发现了问题。

合并请求 #32 在从通用对象创建、更新和替换文档/边缘时将性能提高了约 57%。

在本地机器上使用给定的 Employee 示例对象创建单个文档现在在使用驱动程序的 10k 迭代循环中平均花费约 0.4 毫秒。原始 .NET HTTP 请求(没有任何 ArangoDB 驱动程序抽象)在 10k 循环中需要约 0.35 毫秒。区别在于从泛型对象转换为字典,由于属性处理(如IgnoreField、IgnoreNullValue和AliasField)需要完成。

NuGet package 已更新以反映这一改进。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-07
    • 1970-01-01
    • 2022-10-07
    • 2013-08-16
    • 1970-01-01
    • 2023-03-16
    • 2018-02-06
    • 1970-01-01
    相关资源
    最近更新 更多