optimization

save on cost when using Amazon EBS

Seeing that Amazon has priced the usage of EBS as: $0.10 per GB-month of provisioned storage; $0.10 per 1 million I/O requests Even though the value is in millions, I/O request add up pretty quickly ... I was wondering if there are any best practices for reducing I/O requests out there. E.g. Use an instance with more than enoug...

Turn a large chunk of memory backwards, fast.

I need to rewrite about 4KB of data in reverse order, at bit level (last bit of last byte becoming first bit of first byte), as fast as possible. Are there any clever sniplets to do it? Rationale: The data is display contents of LCD screen in an embedded device that is usually positioned in a way that the screen is on your shoulders lev...

How to do multiple MySQL INSERTs in a way that scales (PHP)

We have a loop in our PHP code which inserts rows into a table. e.g.: while ($info = mysql_fetch_assoc($someQuery)) { mysql_query("INSERT INTO X (i,j) VALUES ($info['ii'],$info['jj'])"); } This was fine a few months ago because the loop would only iterate several times. However, due to our website getting more traffic this loop no...

MySql takes a long time optimizing a join-less query

We have a simple query that looks like: SELECT a,b,c,d FROM table WHERE a=1 and b IN ('aaa', 'bbb', 'ccc', ...) No joins at all, 5000 contsant values in the IN clause. Now, this query takes 1-20 seconds to run on a very strong (16 core) server. The table has an index on (a,b), and we also tried reversing the index to (b,a). The serve...

Techniques for reducing database queries in a Rails app

If you have a Rail app with many complex associated models, what techniques do you employ to reduce database queries? In fact, I'll extend that question a little further and ask, what do you consider "too many" queries for any page? I have a page that I expect will end up hitting the database about 20 times each page load. That concern...

What statistics concepts are useful for profiling?

I've been meaning to do a little bit of brushing up on my knowledge of statistics. One area where it seems like statistics would be helpful is in profiling code. I say this because it seems like profiling almost always involves me trying to pull some information from a large amount of data. Are there any subjects in statistics that I ...

Optimizing suggestions needed for a SQL UPDATE statment. Two ~5 million record tables being used.

Hello, I'm looking for any suggestions to optimize the following PROC SQL statement from a SAS program. The two tables involved contain around 5 million records each and the runtime is about 46 hours. The statement is looking to update a "new" version of the "old" table. Noting a column if the "old" table, for a "PK_ID", was listed ...

Slow C++ DirectX 2D Game

Hi, I'm new to C++ and DirectX, I come from XNA. I have developed a game like Fly The Copter. What i've done is created a class named Wall. While the game is running I draw all the walls. In XNA I stored the walls in a ArrayList and in C++ I've used vector. In XNA the game just runs fast and in C++ really slow. Here's the C++ code: void...

Java handling large amounts of data

I have a Java application that needs to display large amounts of data (on the order of 1 million data points). The data doesn't all need to be displayed at the same time but rather only when requested by a user. The app is a desktop app that is not running with an app server or hitting any centralized database. My thought was to run a d...

I'm on a 2MBPS internet connection but i want to check a website like i'm on a 256 KBPS connection on same PC?

Does anyone know how to test? I'm on Windows XP? and Firefox , IE7 installed ...

Any smarter way to extract from array of bits?

I have areas of memory that could be considered "array of bits". They are equivalent to unsigned char arr[256]; But it would be better thought of as bit arr[2048]; I'm accessing separate bits from it with #define GETBIT(x,in) ((in)[ ((x)/8) ] & 1<<(7-((x)%8))) but I do it a lot in many places of the code, often in performance-...

Optimal architecture solution

I'm building an application which (currently) consists of one web application (ASP.NET MVC) and two console applications. The web application is just the user interface. The first console application is a service that is run in a specified interval, and scrapes several web pages. The second console application is responsible for sending...

How to go about late/lazy loading resources

Hi folks, I have a fairly long page (http://tiny.cc/JrSYr) with sections such as google maps, image slider, google ads, brightcove video (optional) and images. Loads nice and quick without JS and a little slower with JS. I've seen http://www.appelsiini.net/projects/lazyload and was wondering if anyone has used a similar approach or an...

Is the C# compiler smart enough to optimize this code?

Please ignore code readability in this question. In terms of performance, should the following code be written like this: int maxResults = criteria.MaxResults; if (maxResults > 0) { while (accounts.Count > maxResults) accounts.RemoveAt(maxResults); } or like this: if (criteria.MaxResults > 0) { while (accounts.Count ...

mysql query optimization

Hello, This is the table structure: for_id from_id for_folder from_folder deleted The number 2 represents my ID and this is the query: SELECT * FROM poruke_konverzacija WHERE ( ( for_id =2 AND for_folder = "inbox" ) OR ( from_id =2 AND from_folder = "inbox" ) ) AND deleted !=2 I have near 500k records on that table and when i run...

JQuery: How to cache DOM?

I used Firefug to profile my web application and found that the following function is called, and needs to be called, literally hundreds of times per user visit. So I want to optimize it since Firebug says it uses the most resources/times. function highlightChildDiv(parentDiv) { /* find the closest (hlisting) home listing to the m...

Inserting very many rows in to SQL 2005

I have a project where I need to build a two tables in sql 2005 and fill them with data (they are look-up tables for weather a name is a male's name or a female's name) I have 7354 male names to insert and 7776 female names to insert. currently I do it CREATE TABLE #NamesMale ( [FirstName] [varchar](50) NOT NULL, [MaxRank] [smallint...

Is using a PHP Function Alias poor performance/Bad practice?

Just out of curiosity, Does the alias of a built-in PHP function take any more power than the regular function itself. AKA, does sizeof() take more time than count() to run? Note to Micro-Optimization Police: Unless there is a HUGE difference, I don't plan on trying to micro-optimize my script. Was just curious. Note to the 'Just tr...

Best way of replacing heavy exception use?

Hi, I have an old C++ project I made a while back. Well, it is a CPU emulator. Whenever a CPU fault happens(such as divide by zero, or debug breakpoint interrupt, etc) in my code it just does a throw and in my main loop I have something like this: try{ *(uint32_t*)&op_cache=ReadDword(cCS,eip); (this->*Opcodes[op_cache[0]])(); ...

Optimzing MySQL many to many query

Hi, I've having problems getting MySQL to use indexes on a many to many query, i have pasted the relative information below. EXPLAIN SELECT * FROM interviews JOIN interview_category_links ON interviews.id = interview_category_links.inter_id JOIN categories ON interview_category_links.cat_id = categories.id WHERE categories.category_sa...