optimization

Keeping a file in the OS block buffer

I need to keep as much as I can of large file in the operating system block cache even though it's bigger than I can fit in ram, and I'm continously reading another very very large file. ATM I'll remove large chunk of large important file from system cache when I stream read form another file. ...

What standard techniques are there for using cpu specific features in DLLs?

Short version: I'm wondering if it's possible, and how best, to utilise CPU specific instructions within a DLL? Slightly longer version: When downloading (32bit) DLLs from, say, Microsoft it seems that one size fits all processors. Does this mean that they are strictly built for the lowest common denominator (ie. the minimum platform s...

What does "Cannot evaluate expression because the code of the current method is optimized." mean?

I wrote some code with a lot of recursion, that takes quite a bit of time to complete. Whenever I "pause" the run to look at what's going on I get: Cannot evaluate expression because the code of the current method is optimized. I think I understand what that means. However, what puzzles me is that after I hit step, the cod...

image archive VS image strip

Hi, i've noticed that plenty of games / applications (very common on mobile builds) pack numerous images into an image strip. I figured that the advantages in this are making the program more tidy (file system - wise) and reducing (un)installation time. During the runtime of the application, the entire image strip is allocated and copi...

How to read file content into istringstream?

In order to improve performance reading from a file, I'm trying to read the entire content of a big (several MB) file into memory and then use a istringstream to access the information. My question is, which is the best way to read this information and "import it" into the string stream? A problem with this approach (see bellow) is that...

Why should I ever use inline code?

I'm a C/C++ developer, and here are a couple of questions that always baffled me. Is there a big difference between "regular" code and inline code? Which is the main difference? Is inline code simply a "form" of macros? What kind of tradeoff must be done when choosing to inline your code? Thanks ...

What is Big O notation? Do you use it?

What is Big O notation? Do you use it? I missed this university class I guess :D Does anyone use it and give some real life examples of where they used it? See also: Big-O for Eight Year Olds? Big O, how do you calculate/approximate it? Did you apply computational complexity theory in real life? ...

What makes this the fastest JavaScript for printing 1 to 1,000,000 (separated by spaces) in a web browser?

I was reading about output buffering in JavaScript here, and was trying to get my head around the script the author says was the fastest at printing 1 to 1,000,000 to a web page. (Scroll down to the header "The winning one million number script".) After studying it a bit, I have a few questions: What makes this script so efficient com...

Should Local Variable Initialisation Be Mandatory?

The maintenance problems that uninitialised locals cause (particularly pointers) will be obvious to anyone who has done a bit of c/c++ maintenance or enhancement, but I still see them and occasionally hear performance implications given as their justification. It's easy to demonstrate in c that redundant initialisation is optimised out:...

How to most efficently handle large numbers of file descriptors?

There appear to be several options available to programs that handle large numbers of socket connections (such as web services, p2p systems, etc). Spawn a separate thread to handle I/O for each socket. Use the select system call to multiplex the I/O into a single thread. Use the poll system call to multiplex the I/O (replacing the sele...

Unobtrusive javascript : <script> at the top or the bottom of the html code ?

I've recently read the Yahoo manifesto Best Practices for Speeding Up Your Web Site. They recommend to put the javascript inclusion at the bottom of the HTML code when we can. But where exactly and when ? Should we put it before closing </html> or after ? And above all, when should we still put it in the <head> section ? ...

Is there a need to use assembly these days?

Many claim that, when performance is at a premium, it's sufficient to write and compile C code to get near-optimal code that is additionally quite portable. I don't see much of a assembly/assembler discussion on stackoverflow (about 0,3% of the questions right now are tagged any of those tags, many of which refer to .NET Assemblies). H...

Where would you use C# Runtime Compilation?

I happened upon a brief discussion recently on another site about C# runtime compilation recently while searching for something else and thought the idea was interesting. Have you ever used this? I'm trying to determine how/when one might use this and what problem it solves. I'd be very interested in hearing how you've used it or in w...

SQL Server normalization tactic: varchar vs int Identity

I'm just wondering what the optimal solution is here. Say I have a normalized database. The primary key of the whole system is a varchar. What I'm wondering is should I relate this varchar to an int for normalization or leave it? It's simpler to leave as a varchar, but it might be more optimal For instance I can have People =========...

Speed of DataSet row/column lookups?

Recently I had to do some very processing heavy stuff with data stored in a DataSet. It was heavy enough that I ended up using a tool to help identify some bottlenecks in my code. When I was analyzing the bottlenecks, I noticed that although DataSet lookups were not terribly slow (they weren't the bottleneck), it was slower than I expect...

Any experience with compiling VBScript?

I have a home-spun 2000 lines VBScript script, that has become progressively slow with each additional code I add. It was created as a private debugging aid and now that it has become really useful. I want to polish it and ship it along with our product. I thought I could speed it up by compiling it and making it an EXE. Furthermore I w...

I'm using Python regexes in a criminally inefficient manner

My goal here is to create a very simple template language. At the moment, I'm working on replacing a variable with a value, like this: This input: <%"TITLE"="This Is A Test Variable"%>The Web <%"TITLE"%> Should produce this output: The Web This Is A Test Variable I've got it working. But looking at my code, I'm running multi...

Performance challenge: NAL Unit Wrapping

From what I've seen in the past, StackOverflow seems to like programming challenges, such as the fast char to string exercise problem which got dozens of responses. This is an optimization challenge: take a very simple function and see if you can come up with a smarter way of doing it. I've had a function that I've wanted to further op...

Can Multiple Indexes Work Together?

Suppose I have a database table with two fields, "foo" and "bar". Neither of them are unique, but each of them are indexed. However, rather than being indexed together, they each have a separate index. Now suppose I perform a query such as SELECT * FROM sometable WHERE foo='hello' AND bar='world'; My table a huge number of rows for w...

Manipulate Results in GridView RowDataBound or Directly in SQL?

Hello to everybody that is smarter than me! I have a curious question about efficiency. Say I have a field on a database that is just a numeric digit that represents something else. Like, a value of 1 means the term is 30 days. Would it be better (more efficient) to code a SELECT statement like this... SELECT CASE TermId ...