Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are the memory and speed of a program related in a web browser like chrome?

Lately, I've been playing around with Ramsey's theorem for R(5,5). You can see some examples of previous attempts here: http://zacharymaril.com/thoughts/constructionGraph.html Essence: find all the k4's in a graph/its complement and then connect another point in such a way that no k5's are formed (I know with one type of choice, mathematically it becomes improbable that you would get past 14. But there are ways around that choice and I've gotten it to run as far as 22-23 without bricking my browser.)

With new ideas, I started playing around with storing information from batch to batch. The current construction graph goes through and searches for all the k4's in a graph every time it sees the graph. I thought this was overkill, since the k4's will stay the same in the previous graph and only new k4's could show up in the connections produced by the addition of the new point. If you store the previous k4's each time you find them and then only search in the frontier boundaries that were newly created, then you reduce the number of comparisons you have to do from (n 4) to (n-1 3).

I took a shot at implementing this last night and got it to work without obvious errors. While I am going to go back after this and comb through it for any problems, the new method makes the program much much slower. Before, the program was only ~doubling in terms of time it took to do all the comparisons. Now, it is going up in what looks to be factorial time. I've gone back through and tried to ferret out any obvious errors, but I am wondering whether the new dependence on memory could have created the whole slow down.

So, with that long intro, my main question is how are the memory and speed of a program related in a web browser like chrome? Am I slowing down the program by keeping a bunch of little graphs around as JSON objects? Should it not matter in theory how much memory I take up in terms of speed? Where can I learn more about the connection between the two? Is there a book that could explain this sort of thing better?

Thank you for any advice or answers. Sorry about the length of this: I am still buried pretty deep in the idea and its hard to explain it shortly.

Edit: Here are the two webpages that show each algorithm, With storage of previous finds: http://zacharymaril.com/thoughts/constructionGraph.html

Without storage of previous find: http://zacharymaril.com/thoughts/Expanding%20Frontier/expandingFrontier.html

They are both best viewed with Chrome. It is the browser I have been using to make this, and if you open up the dev panel with ctrl shift i and type "times", you can see a collection of all the times so far.

like image 391
zmaril Avatar asked May 19 '11 16:05

zmaril


People also ask

Why Does browser use so much memory?

Look out for tabs and extensions that have ballooned in size. Sometimes, a single Chrome tab can use lots of memory due to a bug or poor configuration. Sometimes, a Chrome memory leak will cause your browser to freeze (or even your whole system).

Does more RAM make Chrome faster?

While RAM will help the Web browser run, it won't have a direct impact on Internet speed. Whether or not an upgrade in RAM will make the browser work better depends on how much memory is already in the system. If you already have more than enough memory to run the browser, an upgrade will have little to no effect.

How much RAM do I need for chrome?

On the final test, with 40 tabs open across two instances (20 tabs apiece), Edge required 2.5 GB RAM altogether, while Chrome needed 2.8 GB and Firefox needed 3.0 GB.


1 Answers

Memory and speed of a program are not closely interrelated.

Simple examples:

  • Computer with almost no ram but lots of hard drive space is going to be thrashing the hard drive for virtual memory. This will slow things down as hard drives are significantly slower than ram.
  • A computer built out of all ram is not going to do the same thing. It won't have to go to the hard drive so will stay quicker.
  • Caching usually takes up a lot of ram. It also significantly increases the speed of an application. This is how memcache works.
  • An algorithm may take a long time but use very little ram. Think of a program that attempts calculating PI. It will never finish, but needs very little ram.

In general, the less ram you use (minus caching) the better for speed because there's less chance you're going to run into constraints imposed by other processes.

If you have a program that takes considerable time to calculate items that are going to be referenced again. It makes sense to cache them memory so you don't need to recalculate them.

You can mix the two by adding timeouts to the cached items. Every time you add another item to the cache, you check the items there and remove any that haven't been accessed in a while. "A while" is determined by your need.

like image 84
evan Avatar answered Oct 13 '22 23:10

evan