optimization

What techniques to avoid conditional branching do you know?

Sometimes a loop where the CPU spends most of the time has some branch prediction miss (misprediction) very often (near .5 probability.) I've seen a few techniques on very isolated threads but never a list. The ones I know already fix situations where the condition can be turned to a bool and that 0/1 is used in some way to change. Are t...

ExtJS: Multiple JsonStores from one AJAX call?

I have an ExtJS based application. When editing an object, an ExtJS window appears with a number of tabs. Three of these tabs have Ext GridPanels, each showing a different type of data. Currently each GridPanel has it's own JsonStore, meaning four total AJAX requests to the server -- one for the javascript to create the window, and one f...

Does GCC inline C++ functions without the 'inline' keyword?

Does GCC, when compiling C++ code, ever try to optimize for speed by choosing to inline functions that are not marked with the inline keyword? ...

SQLServer Query optimization question

I have a project that was "spiked" using Linq2SQL and is now running into some major query performance issues. Go figure. Linq actually works pretty well in simple query and command scenarios, but there are a couple filter intense queries that need to be rewritten as Sprocs. I'm wondering if someone can give me some high level pointer...

MySQL update taking(too) long time ....

After some expected growth on our service all of the sudden some updates are taking extremely long time, these used to be pretty fast until the table reached about 2MM records, now they take about 40-60 seconds each. update table1 set field1=field1+1 where id=2229230; Query OK, 0 rows affected (42.31 sec) Rows matched: 1 Changed: 0 Wa...

Good way to concatenate string representations of objects?

Ok, We have a lot of where clauses in our code. We have just as many ways to generate a string to represent the in condition. I am trying to come up with a clean way as follows: public static string Join<T>(this IEnumerable<T> items, string separator) { var strings = from item in items select item.ToString(); return string.Join...

CSS Minimizer ?

Do you know of an online CSS compressor that helps remove redudant/ineffecient CSS declarations and replaces it with more optimized CSS? Meaning, I know that a lot of "compressors" exist that simply remove tabs, remove comments, etc. But what I'm looking for is something smart enough to know that: border-top: 1px solid red; border-bo...

Optimizing random-access bilinear sampling

I'm working on an old-school "image warp" filter. Essentially, I have a 2D array of pixels (ignoring for the present the question of whether they are color, grayscale, float, RGBA, etc.) and another 2D array of vectors (with floating-point components), with the image being at least as large as the vector array. In pseudo code, I want to ...

Mouse movement optimizations

I want to have a game where the view will move around as the mouse reaches the outer edge of the window (similar to many RTS games). I have read that there is significant overhead when using the MouseMotionListener. Is there perhaps a way of having a second transparent component within the game window (JPanel) that does not affect game-...

C++ optimization of reference-to-pointer argument

I'm wondering with functions like the following, whether to use a temporary variable (p): void parse_foo(const char*& p_in_out, foo& out) { const char* p = p_in_out; /* Parse, p gets incremented etc. */ p_in_out = p; } or can I just use the original argument and expect it to be optimized similarly to the...

Optimizing Mysql Query

What is the general "best practice" for this type of functionality. I have a table of users a table of polls and a table of poll responses on a website. I want to load a page that loads a poll that a user hasn't yet answer. What is the most efficient and "best" way of going about this. Things I've tried that seems slow/not optimal: ...

Why is Magento so slow?

Is Magento usually so terrible slow? This is my first experience with it and the admin panel simply takes ages to load and save changes. It is a default installation with the test data. The server it is hosted on serves other non-Magento sites super fast. What is it about the PHP code that Magento uses that makes it so slow, and what ...

Ruby: count the number of 1's in a binary number

I have a binary number (52 bits) represented as a string "01100011...." What would be the quickest way to count the number of 1's? "01100011....".count("1") obviously works but is quite time consuming if this operation needs to be done thousands of times. ok, some more info. I am trying to create bit vectors for words as follows de...

Zend Framework $table->fetchRow() is very slow

It is taking .6-.8 seconds for this line of my code to execute in my users table model: $row = $this->fetchRow("username = '$username'"); I'm caching my table metadata for all tables already. Any idea what could be causing this slowness? ...

Is there such a C++ optimisation?

E.g. vector<string> a; vector<string> b; a.push_back("first"); b=a; Would it be optimised somehow as vector<string> b; b.push_back("first"); ...

PDO constructor very slow (mysql)

This bit of code is taking almost a half second to execute. Could somebody help me with some reasons this could be happening and some possible solutions? If it matters, the DB is hosted by amazon rds $this->_connection = new PDO( $dsn, $this->_config['username'], $this->_config['password'], ...

How worth is it to assign an FK Index?

I'm a normal "would be DBA" level developer. I've been handling some databases with a few million records. A lot goes around importing data between database and its clone and then using that clone in the web-app environment. Well, I've known that keeping PK indexes automatically and so it helps speedup the data access. Now, from this di...

Can I optimize this piece of code?

Is it possible to use any loop optimization technique here to reduce the execution time ? I need the nested loop with i and j as I need those combinations of (i,j). EDIT: even if I leave the "actual" code, with this trivial assignment, this is taking up ~5s on my Dual Core box, whereas with that actual code, it takes up ~6s. I experimen...

Intel MKL vs. AMD Math Core Library

Does anybody have experience programming for both the Intel Math Kernel Library and the AMD Math Core Library? I'm building a personal computer for high performance statistical computations and am debating on the components to buy. An appeal of the AMD Math Core library is that it is free, but I am in academia so the MKL is not that ex...

CUDA: synchronizing threads

Almost anywhere I read about programming with CUDA there is a mention of the importance that all of the threads in a wrap do the same thing. In my code I have a situation where I can't avoid a certain condition. It looks like this: // some math code, calculating d1, d2 if (d1 < 0.5) { buffer[x1] += 1; // buffer is in the global mem...