{
  "id": 2047,
  "title": "Reducing run time for graph creation?",
  "url": "/competitions/FacebookRecruiting/discussion/2047",
  "author_name": "",
  "post_date": "2012-06-18T04:13:50.373Z",
  "votes": null,
  "comment_count": 7,
  "views": 4201,
  "content": "<p>Any tips on reducing the run time for graph creation? It takes nearly 40 seconds on my i7 with 4 GB of RAM. If I add one more graph, it shoots up to 80 seconds. If I use pickle to save the data structure, I save 30 seconds for the 1st graph (with a 68 MB\r\n file). Not able to successfully save the second graph with pickle yet. Eventually, for submitting, I guess we have to let the graph computation happen in run-time.</p>",
  "messages": [
    {
      "id": "11698",
      "postDate": "06/18/2012 04:13:50",
      "content": "<p>Any tips on reducing the run time for graph creation? It takes nearly 40 seconds on my i7 with 4 GB of RAM. If I add one more graph, it shoots up to 80 seconds. If I use pickle to save the data structure, I save 30 seconds for the 1st graph (with a 68 MB\r\n file). Not able to successfully save the second graph with pickle yet. Eventually, for submitting, I guess we have to let the graph computation happen in run-time.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "11701",
      "postDate": "06/18/2012 08:37:09",
      "content": "<p>My tip for speeding up a python program would be to rewrite the performance critical part (or the whole program) in C / C&#43;&#43;. Obviously this isn't without downsides...</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "11706",
      "postDate": "06/18/2012 11:44:54",
      "content": "<p>I didn't see any performance requirement in the evaluation criteria. As you are only submitting predictions, you can take as long as you want (within reason) to generate the predictions. The goal here is ACCURACY.</p>\r\n<p>Depending on how this result is going to be used (if it is going to be used) in production, the need to have &quot;real-time&quot; predictions may or may not come up.</p>\r\n<p>Beyond writing C/C&#43;&#43; code for the critical part of your code, you can always consider parallel algorithms. But as roobs said, that &quot;isn't withou downsides..&quot; either.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "11711",
      "postDate": "06/18/2012 17:21:25",
      "content": "<p>I also use python and does not have such an issue. good side with python is you can use the interpreter. so that previous data is on the memory and you can play with them the way you like.\r\n<br>\r\nI use the python interpreter on linux can can generate the full graph with in 15-20 seconds on my i5 4gb machine\r\n</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "11745",
      "postDate": "06/19/2012 18:43:54",
      "content": "<p>For Python, I'm using the igraph library, it's pretty fast since it's using native code libigraph in the background.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "11779",
      "postDate": "06/21/2012 02:32:51",
      "content": "<p>I don't see too much downside, except it takes a bit longer to write the code. Well, you do lose the ability -- if you want that -- to easily explore the graph interactively. &nbsp;Anyway, it took me only a few minutes to code in c&#43;&#43;, and I can read the graph\r\n in just under 3 seconds. &nbsp;This is on a fairly new linux box with a few G of RAM.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "11781",
      "postDate": "06/21/2012 03:33:09",
      "content": "<p>Thanks for all the replies.</p>\r\n<p>Hi David,</p>\r\n<p>The more complex my algorithm is getting, the more I feel that I need to move away from Python. It's becoming extremely slow handling such a big graph. What datastructure are you using? Are you using Boost library?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "11815",
      "postDate": "06/22/2012 03:08:31",
      "content": "<p>I use STL in c&#43;&#43;. My representation of the graph: map&lt;int, set&lt;int&gt; &gt; which maps</p>\r\n<p>{person -&gt; set of people the person is following}</p>\r\n<p>I've used boost before, and know it is well thought of, but personally find their documentation --esp. for the graph library -- abysmal. &nbsp;Some day I'll have enough free time to master it (perhaps).</p>\r\n<p>I *really* like python for quick prototyping, but when performance becomes an issue I graduate the code to C&#43;&#43;. My experience with pickle is: for anything very large it's *very* slow.</p>\r\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 11701,
      "author_name": "roobs5218",
      "author_url": "",
      "post_date": "06/18/2012 08:37:09",
      "content": "<p>My tip for speeding up a python program would be to rewrite the performance critical part (or the whole program) in C / C&#43;&#43;. Obviously this isn't without downsides...</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 11706,
      "author_name": "owenzhang1",
      "author_url": "",
      "post_date": "06/18/2012 11:44:54",
      "content": "<p>I didn't see any performance requirement in the evaluation criteria. As you are only submitting predictions, you can take as long as you want (within reason) to generate the predictions. The goal here is ACCURACY.</p>\r\n<p>Depending on how this result is going to be used (if it is going to be used) in production, the need to have &quot;real-time&quot; predictions may or may not come up.</p>\r\n<p>Beyond writing C/C&#43;&#43; code for the critical part of your code, you can always consider parallel algorithms. But as roobs said, that &quot;isn't withou downsides..&quot; either.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 11711,
      "author_name": "udnisap",
      "author_url": "",
      "post_date": "06/18/2012 17:21:25",
      "content": "<p>I also use python and does not have such an issue. good side with python is you can use the interpreter. so that previous data is on the memory and you can play with them the way you like.\r\n<br>\r\nI use the python interpreter on linux can can generate the full graph with in 15-20 seconds on my i5 4gb machine\r\n</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 11745,
      "author_name": "amastilovic",
      "author_url": "",
      "post_date": "06/19/2012 18:43:54",
      "content": "<p>For Python, I'm using the igraph library, it's pretty fast since it's using native code libigraph in the background.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 11779,
      "author_name": "davidhysom",
      "author_url": "",
      "post_date": "06/21/2012 02:32:51",
      "content": "<p>I don't see too much downside, except it takes a bit longer to write the code. Well, you do lose the ability -- if you want that -- to easily explore the graph interactively. &nbsp;Anyway, it took me only a few minutes to code in c&#43;&#43;, and I can read the graph\r\n in just under 3 seconds. &nbsp;This is on a fairly new linux box with a few G of RAM.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 11781,
      "author_name": "macsdev",
      "author_url": "",
      "post_date": "06/21/2012 03:33:09",
      "content": "<p>Thanks for all the replies.</p>\r\n<p>Hi David,</p>\r\n<p>The more complex my algorithm is getting, the more I feel that I need to move away from Python. It's becoming extremely slow handling such a big graph. What datastructure are you using? Are you using Boost library?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 11815,
      "author_name": "davidhysom",
      "author_url": "",
      "post_date": "06/22/2012 03:08:31",
      "content": "<p>I use STL in c&#43;&#43;. My representation of the graph: map&lt;int, set&lt;int&gt; &gt; which maps</p>\r\n<p>{person -&gt; set of people the person is following}</p>\r\n<p>I've used boost before, and know it is well thought of, but personally find their documentation --esp. for the graph library -- abysmal. &nbsp;Some day I'll have enough free time to master it (perhaps).</p>\r\n<p>I *really* like python for quick prototyping, but when performance becomes an issue I graduate the code to C&#43;&#43;. My experience with pickle is: for anything very large it's *very* slow.</p>\r\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "11698": "",
    "11701": "",
    "11706": "",
    "11711": "",
    "11745": "",
    "11779": "",
    "11781": "",
    "11815": ""
  },
  "source": "meta"
}