Questions tagged [optimization]

Optimization is the process of improving an existing program to make it work more efficiently or/and using less resources.

Filter by
Sorted by
Tagged with
0 votes
3 answers
90 views

Optimize reservation system algorithm

Im am developing a logistics application and at the moment, I try to solve the following problem: In the system, there are multiple machines. Each machine has one or more skills. For example, machine ...
-2 votes
2 answers
259 views

How does Java and other managed languages achieve any performance, if everything is allocated at random places of the heap? [closed]

Prelude Recently, I helped a friend of mine in coding him a problem for his university Algorithms course, where problems are submitted in Java. I sent him code with good O notation complexity, ...
0 votes
0 answers
40 views

Designing an optimization on throughput of EF.Core application

I am looking for feedback on a design problem I encountered when processing batches of db entries. The issue at hand is efficiency and throughput of an application. The application looks like this ...
0 votes
1 answer
125 views

How can I minimize the number of captured variables in lambda expressions? [closed]

If a lambda is frequently used, it is considered to reuse the same instance instead of creating new instances repeatedly. How can I minimize the number of captured variables in lambda expressions?
0 votes
1 answer
262 views

Optimal Simplification of Transposition Products

I am looking to take a product of a large number of transpositions, and boil it down to a smaller number of products. I have the following code, and would like some input on efficient ways to boil ...
7 votes
3 answers
2k views

Optimizing code generation for expressions in a compiler

I don't know if this question has a simple answer or not, but I just have to ask. I'm reading this tutorial (I don't know if this is a well-known series, but it's name is 'Let's build a compiler!' by ...
4 votes
2 answers
669 views

Do compilers un-inline recurrent expressions?

Does a compiler look for recurrent expressions to convert it into 'function' to reduce binary size and improve performance? Of course, the obvious answer might be "some do it, some don't", so I ask ...
15 votes
4 answers
5k views

Better solutions than joining table for Many to Many?

Lets say I have students and classes which are 2 entities. A student can take many classes and a class can have many students. This would be a many to many relationship. To solve this with an RDBMS my ...
23 votes
10 answers
9k views

Shouldn't deep copy be the default, not shallow copy?

If you have an OO language, where every object always has a copy method, shouldn't that be deep copy by default? In most languages I know, such a copy method is shallow, since a shallow copy is more ...
0 votes
1 answer
200 views

How do function inlining and Tail Call Optimization affect call stack?

I've just accidentally came across this answer about inlined functions and I'd like to know how this affects call stack. But I can't add comments because I don't have enough rep so I decided to ask ...
2 votes
2 answers
203 views

Optimizing Flash Memory Writes in Embedded Systems with Unpredictable Power Loss

I'm working on an embedded C++ project that involves logging certain types of statistical data (like successful accesses, failed attempts, and other events) to the flash memory (just incrementing ...
3 votes
1 answer
290 views

Simulated Annealing

In relation to another question I had, I have been researching Simulated Annealing. The general example used with this algorithm is the traveling salesman example. I have been testing the code ...
32 votes
5 answers
31k views

Is passing arguments as const references premature optimization?

"Premature optimization is the root of all evil" I think this we can all agree upon. And I try very hard to avoid doing that. But recently I have been wondering about the practice of passing ...
0 votes
1 answer
124 views

Use PGO (profile guided optimization) to determine optimal value of variables in code

Reading this interesting paper it seems that a lot of performance loss is due to scheduling overhead in tight loops. To recap: There's a variable called "Chunksize" which determines how big ...
21 votes
6 answers
20k views

How important is memory alignment? Does it still matter?

For some time now, I have searched and read a lot about memory alignment, how it works and how to use it. The most relevant article I have found so far is this one. But even with that I still have ...
23 votes
7 answers
11k views

Inline functions in C++. What's the point?

According to what I read, the compiler is not obliged to substitute the function call of an inline function with its body, but will do so if it can. This got me thinking- why do we have the inline ...
8 votes
3 answers
222 views

Choosing one of two memory blocks to deallocate: Does age affect fragmentation?

First question here, so preemptive apologies if I've committed some faux-pas. Additionally, I am aware that this question is about possibly the micro-est of micro-optimizations ever, and "micro-...
0 votes
1 answer
270 views

Microservices Conditional API Call Design

I always think about this scenario where we need to perform a task conditionally and the task requires calling another microservice. What I am not able to understand is which microservice's ...
1 vote
2 answers
250 views

String representation in Python runtimes

Python is one of the few languages to support a string data type of code points (Unicode Scalar Values). I'm also wanting to creating a language that has this same characteristic, but I need to ...
5 votes
4 answers
1k views

Is it better to iterate over data once and do multiple complex operations, or to iterate multiple times with simpler operations?

Here I'm working in Python, but it's more of a language agnostic question, unless specific language features makes it clear that an option is better than the other. I get my raw data from a REST API, ...
4 votes
3 answers
8k views

Is it conceivable to have millions of lists of data in memory in Python?

I have over the last 30 days been developing a Python application that utilizes a MySQL database of information (specifically about Norwegian addresses) to perform address validation and correction. ...
-1 votes
1 answer
72 views

Is it practical to cache multiple instances of variable API data (updates hourly for each instance) for N users?

I'm using flask with SQLAlchemy on a postgresql database for a mobile app I'm building. My application allows a single user to save lets say up to 5 different locations which are saved in the database....
14 votes
4 answers
2k views

Maintenance cost of SIMD programming code base

Question: The software industry's consensus is that clean and simple code is fundamental to the long-term viability of the code base and the organization that owns it. These properties lead to lower ...
0 votes
1 answer
168 views

Is it premature optimisation to test a condition to skip a small loop?

I have an array of entities which have an id property: entities: {id: string|null}[] = []; All items in the array are guaranteed to have id !== null and the array will not exceed 100 items. Now I may ...
5 votes
4 answers
1k views

Designing a Database Application with OOP

I often develop SQL database applications using Linq, and my methodology is to build model classes to represent each table, and each table that needs inserting or updating gets a Save() method (which ...
0 votes
3 answers
2k views

Optimizing a string to enum converter [closed]

I have built a string to enum converter, which converts a known set of strings that it receives into enum, in order to satisfy a function pointer. Some of you may recognize some elements of this ...
0 votes
1 answer
380 views

How to optimize average rating calculation in a review system?

I'm thinking of a designing a review system (restaurant, hotel etc) where users can drop star reviews. Typically in a such a application, you can see the average rating of an entity along with all ...
2 votes
1 answer
1k views

Research topics for starting and optimizing a high-traffic website [closed]

I bury a good deal of my ideas for fear that I don't know enough about scaling web applications and high-traffic websites. That said, I'd like to know of any general topics to research in order to ...
-1 votes
1 answer
102 views

How to measure the impact of a website speed optimization

Given: You have a list of opportunities* that may improve the speed metrics of your website. For example Total Blocking Time (TBT) is one metric that heavily impacts the experience of a visitor. You'...
0 votes
3 answers
2k views

Optimal method of storing image thumbnails

I'm working on an application with a database containing many recipes. The API is written in Django (with Django REST Framework) and frontend in React.Each recipe is assigned a high-quality image. In ...
-1 votes
2 answers
208 views

Performance hit after non-functional refactoring

I was asked to refactor some C++ code recently for the purposes of increasing unit testing coverage. The problem was that the code was tightly coupled on one compilation unit, so we had the equivalent ...
0 votes
0 answers
37 views

Feasibility of Delievery App

In my town, recently a delivery company has been opened (think DoorDash but on a much smaller scale and only doing local deliveries). Now what really confuses me is that they charge pennies for each ...
0 votes
0 answers
44 views

Optimizing database lookup with No SQL MongoDB

My restraints are that I have to use: Django and MongoDB I am trying to build a website that will read some JSON input and then parse all the properties and objects in the JSON and display results. ...
0 votes
1 answer
1k views

Java: Is there a performance difference between variable assignment vs. inline usage?

Is there any performance detriment to assigning variables vs using them inline. I'm guessing this WOULD be worse if a method was returning primitive and I was 'boxing' it (e.g. method returning int, ...
0 votes
1 answer
168 views

In C and C++, can a compiler store an unamed object generated from a expression, if that same expression is reused, but the result is unchanged? [closed]

I'm mostly interested in C and C++, but I think this question can also apply to other languages. My question is, if an unamed object or value is generated from the evaluation of an expression or ...
295 votes
17 answers
106k views

Is premature optimization really the root of all evil?

A colleague of mine today committed a class called ThreadLocalFormat, which basically moved instances of Java Format classes into a thread local, since they are not thread safe and "relatively ...
2 votes
3 answers
920 views

Are lessons on tail recursion transferable to languages that don't optimize for it?

I'm currently reading through Structure and Interpretation of Computer Programs (SICP). During the course of that book, the lesson of "you can optimize recursive procedures by writing them as ...
41 votes
6 answers
17k views

How does branch prediction work, if you still have to check for the conditions?

I was reading the popular answer about Branch Prediction from https://stackoverflow.com/q/11227809/555690, and there is something confusing me: If you guessed right, it continues on. If you ...
1 vote
1 answer
2k views

How to remove unused code from a jar file? [closed]

I have a jar file, for example foo.jar. My code contains a lot of libraries (almost 75 jar dependencies). I am not using anything like maven or gradle, I'm just using pure java with pure jar files as ...
0 votes
1 answer
121 views

Worried about too many joins when fetching multiple datatypes in a single postgres query

Its not exactly my use case (would take too long too explain), but imagine a task management application where tasks for employees are displayed in a list along with some information about that task. ...
3 votes
2 answers
2k views

Does implementing more interfaces on a class decrease performance?

I had a question regarding the performance of having a class implement multiple interfaces. Is there any degradation in having a class implement 2 interfaces vs 10 interfaces? Background This ...
14 votes
1 answer
797 views

Redundant code sent down the pipe with Micro-frontends

My understanding of Micro-frontends is that the key problem they solve is in helping enterprises have multiple, possible disparate teams, work on individual components/small-apps that will be used to ...
2 votes
5 answers
746 views

How does a query execution plan affect query execution?

I have read some articles on SQL Server query optimization. The point I get is SQL Server generates a query execution plan for each stored procedure when it's executed for the first time. Those ...
-3 votes
1 answer
88 views

Choosing between network optimisation and CPU usage in clientside web development [closed]

I'm working on a CSS library that includes hundreds of selectors and rules for quick templating instead of writing regular CSS. This is used as a replacement of attr() CSS function until it works for ...
-1 votes
1 answer
504 views

How to optimize the request time for large data response?

I have created a dashboard for rendering a list of clients into a DataTable. Below shown is the data model structure: When I had a few records in the clients schema, let's say a thousand rows, the ...
-2 votes
1 answer
295 views

Recommended way of caching weather information

I'm developing an application that will show some weather information based on the user's location. Since the weather forecast is just a very small feature of the app that complements the main ones, I ...
-4 votes
1 answer
65 views

Calculate math function depend on N value [closed]

I have method with the following prototype : R[] = method(k,n) which : n = ordinal value 0 <n <10^9 k = math function depend on n value : i.e n^6 R = array of computed values For example : n = ...
-1 votes
1 answer
76 views

In a language interpreted line by line - is optimizing similar lines of code within a module into functions better in terms of efficiency? [duplicate]

While writing python code (I write python-selenium for GUI automation), I am facing situations wheer I have to deal with 5 widgets that do the same thing, just there xpath is differs by one term. # ...
-3 votes
1 answer
177 views

Techniques I can use to optimise my C++ code further? [closed]

I'm working on loading PNG files. I know there are existing libraries, but I'm doing this for learning purposes. Previously, I was using LodePNG, which is a great library that performs really well. I ...
-1 votes
1 answer
38 views

how to model this relation by linear constraints?

v = |x1-x2| with 0<=xj<=C for j=1,2, C constant I was trying to moel this relation by linear constraints. This is what I've done equality is equivalente to superior and inferior relation. ...

1
2 3 4 5
8