{"action":"opened","issue":{"url":"https://api.github.com/repos/nodegit/nodegit/issues/919","repository_url":"https://api.github.com/repos/nodegit/nodegit","labels_url":"https://api.github.com/repos/nodegit/nodegit/issues/919/labels{/name}","comments_url":"https://api.github.com/repos/nodegit/nodegit/issues/919/comments","events_url":"https://api.github.com/repos/nodegit/nodegit/issues/919/events","html_url":"https://github.com/nodegit/nodegit/issues/919","id":136177369,"number":919,"title":"Transfer progress notifications are prohibitively slow","user":{"login":"bpeabody","id":720785,"avatar_url":"https://avatars.githubusercontent.com/u/720785?v=3","gravatar_id":"","url":"https://api.github.com/users/bpeabody","html_url":"https://github.com/bpeabody","followers_url":"https://api.github.com/users/bpeabody/followers","following_url":"https://api.github.com/users/bpeabody/following{/other_user}","gists_url":"https://api.github.com/users/bpeabody/gists{/gist_id}","starred_url":"https://api.github.com/users/bpeabody/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpeabody/subscriptions","organizations_url":"https://api.github.com/users/bpeabody/orgs","repos_url":"https://api.github.com/users/bpeabody/repos","events_url":"https://api.github.com/users/bpeabody/events{/privacy}","received_events_url":"https://api.github.com/users/bpeabody/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-24T20:26:32Z","updated_at":"2016-02-24T20:26:32Z","closed_at":null,"body":"Having even an empty transfer progress function for fetches adds a large amount of overhead. In the code below, for example, on the nodegit repo itself, specifying a transfer progress function adds about 38s for me.\r\n\r\nThe progress function is called once for each object fetched from the repository: about 25,000 times for the nodegit repo as of today. That would indicate an overhead of about 1.5ms for calling from C++ into JavaScript (running on a 3.1ghz i7). This amount of overhead feels a little high; I wonder if there might be some room for optimizing the JS/C++ binding/bridge code.\r\n\r\nEven if significantly optimized (e.g., by a factor of 10), the overhead of calling from C++ into JS is probably high enough to be prohibitive; it might be good to be able to provide some conflation so that the progress function is called no more than a specified frequency (e.g., no more than once every 100ms).\r\n\r\nIf no one has an easy answer for this, I would be more than happy to lend a hand (I have a lot of experience with v8).\r\n\r\nSample code:\r\n\r\n    const NodeGit = require(\"nodegit\");\r\n\r\n    console.time(\"no-progress\");\r\n\r\n    NodeGit.Clone(\"https://github.com/nodegit/nodegit.git\", \"no-progress\")\r\n    .then(function () {\r\n        console.timeEnd(\"no-progress\");\r\n        console.time(\"progress\");\r\n        var options = new NodeGit.CloneOptions();\r\n        var fetchOpts = new NodeGit.FetchOptions();\r\n        options.fetchOpts = fetchOpts;\r\n        var callbacks = new NodeGit.RemoteCallbacks();\r\n        fetchOpts.callbacks = callbacks;\r\n        callbacks.transferProgress = function () {\r\n        };\r\n        return NodeGit.Clone(\"https://github.com/nodegit/nodegit.git\",\r\n                             \"progress\",\r\n                             options);\r\n    }).done(function () {\r\n        console.timeEnd(\"progress\");\r\n        process.exit(0);\r\n    });\r\n"}}