• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:11
CET 13:11
KST 21:11
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Team Liquid Map Contest #22 - Presented by Monster Energy4ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13
Community News
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool22Weekly Cups (March 9-15): herO, Clem, ByuN win32026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains18
StarCraft 2
General
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Serral: 24’ EWC form was hurt by military service Weekly Cups (March 9-15): herO, Clem, ByuN win Team Liquid Map Contest #22 - Presented by Monster Energy Weekly Cups (August 25-31): Clem's Last Straw?
Tourneys
KSL Week 87 [GSL CK] #2: Team Classic vs. Team Solar 2026 KungFu Cup Announcement [GSL CK] #1: Team Maru vs. Team herO RSL Season 4 announced for March-April
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ JaeDong's form before ASL Gypsy to Korea BSL Season 22
Tourneys
Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours IPSL Spring 2026 is here!
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Zealot bombing is no longer popular?
Other Games
General Games
Nintendo Switch Thread Path of Exile General RTS Discussion Thread Stormgate/Frost Giant Megathread Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Mexico's Drug War Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Tokyo Olympics 2021 Thread General nutrition recommendations Cricket [SPORT]
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 7663 users

The Big Programming Thread - Page 602

Forum Index > General Forum
Post a Reply
Prev 1 600 601 602 603 604 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
Last Edited: 2015-03-07 08:42:33
March 07 2015 07:09 GMT
#12021
Hi,

Can someone help me with some Java. I read HashMap have a race condition where if you concurrently modify their size you can end in an infinite loop. I'm trying to get a POC code that might trigger it, but so far I have no luck being able to replicate it. Obviously being a race condition I guess I can't get it 100%, I'd just like to see I'm on the right track.

Basically I create one static HashMap and then create an executor service and submit a ton of jobs that either add or update a key in the hashmap (some adds to resize map).

Any ideas?

edit: nm - used this code - http://java.dzone.com/articles/java-7-hashmap-vs, able to replicate. need to figure out why my code was wrong...

edit: hmm what I changed in my code was instead of submitting 500k tasks that all add/update a key, I submit 4 tasks each of which try to submit/update 500k items. Attempted code from the tutorial into this and it loops, thread dump shows its stuck on hashmap stuff, and replacing it with concurrent hash map makes it work.

code
+ Show Spoiler +


import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Executor {
static final int NUM_TESTS = 3;
static final int NUM_THREAD = 4;
static final int THREAD_ITERATIONS = 500000; //500k
static final Map<String, Integer> map = new HashMap<>(1);

public static void main(String[] args) throws InterruptedException {
for (int test = 0; test < NUM_TESTS; test++) {
System.out.println("Started at: " + System.currentTimeMillis());
ExecutorService es = Executors.newFixedThreadPool(NUM_THREAD);
final CountDownLatch latch = new CountDownLatch(NUM_THREAD);
for (int i = 0; i < NUM_THREAD; i++) {
es.execute(() -> {
for (int k = 0; k < THREAD_ITERATIONS; k++) {
Integer newInteger1 = (int) Math.ceil(Math.random() * 1000000);
Integer newInteger2 = (int) Math.ceil(Math.random() * 1000000);

// 1. Attempt to retrieve a random Integer element
Integer retrievedInteger = map.get(String.valueOf(newInteger1));

// 2. Attempt to insert a random Integer element
map.put(String.valueOf(newInteger2), newInteger2);
}
latch.countDown();
});
}
es.shutdown();
latch.await();
System.out.println(map.size());
System.out.println("Finished at: " + System.currentTimeMillis());
}
}
}


RIP GOMTV. RIP PROLEAGUE.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-07 09:18:52
March 07 2015 09:15 GMT
#12022
You do know that if you have multiple threads accessing the same data structure concurrently is going to have race conditions right?

ConcurrentHashMap/ConcurrentAnything have mutex locks (probably some sort of monitor) on their state-modifying member functions, so that for example, two calls to Add() at the same time don't fuck up the data structure. I'm guessing you haven't done much parallism/threading stuff? Parallelism isn't just achieved by spinning worker threads. In most cases you'll have the same performance with just one thread if you don't actually have a good reason to apply concurrency optimizations.
There is no one like you in the universe.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
March 07 2015 09:25 GMT
#12023
On March 07 2015 18:15 Blisse wrote:
You do know that if you have multiple threads accessing the same data structure concurrently is going to have race conditions right?

ConcurrentHashMap/ConcurrentAnything have mutex locks (probably some sort of monitor) on their state-modifying member functions, so that for example, two calls to Add() at the same time don't fuck up the data structure. I'm guessing you haven't done much parallism/threading stuff? Parallelism isn't just achieved by spinning worker threads. In most cases you'll have the same performance with just one thread if you don't actually have a good reason to apply concurrency optimizations.


Lol idk you read my thread at all. I know theres race condition with infinite loop, I just wanted to reliably replicate it. In practice i see it in work j2ee code basic that basically ends up with static maps wrapped in beans or cdi shit. I was debugging the issue in prod and coworkers are being annoying about understanding need to use concurrent maps so i wanted poc to show them.

I know i can use concurrent map to fix it, its what i freaking said in my post (concurrenthashmap will fix it). now i can just convince stubborn coworkers why they can just use concurrenthashmap and not complain.
RIP GOMTV. RIP PROLEAGUE.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
March 07 2015 09:32 GMT
#12024
On March 07 2015 18:25 teamamerica wrote:
Show nested quote +
On March 07 2015 18:15 Blisse wrote:
You do know that if you have multiple threads accessing the same data structure concurrently is going to have race conditions right?

ConcurrentHashMap/ConcurrentAnything have mutex locks (probably some sort of monitor) on their state-modifying member functions, so that for example, two calls to Add() at the same time don't fuck up the data structure. I'm guessing you haven't done much parallism/threading stuff? Parallelism isn't just achieved by spinning worker threads. In most cases you'll have the same performance with just one thread if you don't actually have a good reason to apply concurrency optimizations.


Lol idk you read my thread at all. I know theres race condition with infinite loop, I just wanted to reliably replicate it. In practice i see it in work j2ee code basic that basically ends up with static maps wrapped in beans or cdi shit. I was debugging the issue in prod and coworkers are being annoying about understanding need to use concurrent maps so i wanted poc to show them.

I know i can use concurrent map to fix it, its what i freaking said in my post (concurrenthashmap will fix it). now i can just convince stubborn coworkers why they can just use concurrenthashmap and not complain.


edit: besides im not just talking about generic race condition like getting the wrong data in a get - there is specific to hashmap, infinite loop race condition. which again i mentioned something specifically.

im so confused as to who youre talking to in your comment because its sure as hell not even responding to almost anything i asked...
RIP GOMTV. RIP PROLEAGUE.
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
March 07 2015 12:08 GMT
#12025
On March 07 2015 10:20 darkness wrote:

Anyway, if it's the HP field that you want to access, then make it a protected field in the base class. If this isn't what you want, you should indeed reconsider design.


What base class? The component class? No no no no no.

The main point of component based entity systems is to eliminate massive inheritance hierarchies and a bajillion different entity types that would result from doing things like you suggest.

Component based design gives you just one entity class, hides the necessary evil of type casting neatly behind its own interface, and unifies the treatment of components and systems. Using a type hiding class can mean that components don't even have to be aware of the Component base class. As long as a class implements the correct static interface, it can act as a component.

I'm not sure there's a neater way to abstract this in C++.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-07 22:52:19
March 07 2015 22:41 GMT
#12026
On March 07 2015 18:25 teamamerica wrote:
Show nested quote +
On March 07 2015 18:15 Blisse wrote:
You do know that if you have multiple threads accessing the same data structure concurrently is going to have race conditions right?

ConcurrentHashMap/ConcurrentAnything have mutex locks (probably some sort of monitor) on their state-modifying member functions, so that for example, two calls to Add() at the same time don't fuck up the data structure. I'm guessing you haven't done much parallism/threading stuff? Parallelism isn't just achieved by spinning worker threads. In most cases you'll have the same performance with just one thread if you don't actually have a good reason to apply concurrency optimizations.


Lol idk you read my thread at all. I know theres race condition with infinite loop, I just wanted to reliably replicate it. In practice i see it in work j2ee code basic that basically ends up with static maps wrapped in beans or cdi shit. I was debugging the issue in prod and coworkers are being annoying about understanding need to use concurrent maps so i wanted poc to show them.

I know i can use concurrent map to fix it, its what i freaking said in my post (concurrenthashmap will fix it). now i can just convince stubborn coworkers why they can just use concurrenthashmap and not complain.


lol wow you get angry easily. forgive me if i misinterpret a confusing post where your goal is to reproduce a race condition. remind me next time to not read your posts if this is how you talk to people who misread you. no wonder your coworkers are having a hard time if you act like this..
There is no one like you in the universe.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-07 22:51:18
March 07 2015 22:42 GMT
#12027
Doublepost
There is no one like you in the universe.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
March 07 2015 23:38 GMT
#12028
On March 08 2015 07:41 Blisse wrote:
Show nested quote +
On March 07 2015 18:25 teamamerica wrote:
On March 07 2015 18:15 Blisse wrote:
You do know that if you have multiple threads accessing the same data structure concurrently is going to have race conditions right?

ConcurrentHashMap/ConcurrentAnything have mutex locks (probably some sort of monitor) on their state-modifying member functions, so that for example, two calls to Add() at the same time don't fuck up the data structure. I'm guessing you haven't done much parallism/threading stuff? Parallelism isn't just achieved by spinning worker threads. In most cases you'll have the same performance with just one thread if you don't actually have a good reason to apply concurrency optimizations.


Lol idk you read my thread at all. I know theres race condition with infinite loop, I just wanted to reliably replicate it. In practice i see it in work j2ee code basic that basically ends up with static maps wrapped in beans or cdi shit. I was debugging the issue in prod and coworkers are being annoying about understanding need to use concurrent maps so i wanted poc to show them.

I know i can use concurrent map to fix it, its what i freaking said in my post (concurrenthashmap will fix it). now i can just convince stubborn coworkers why they can just use concurrenthashmap and not complain.


lol wow you get angry easily. forgive me if i misinterpret a confusing post where your goal is to reproduce a race condition. remind me next time to not read your posts if this is how you talk to people who misread you. no wonder your coworkers are having a hard time if you act like this..


for u blisse <3
+ Show Spoiler +

lol you give me a condescending ass answer of " I'm guessing you haven't done much parallism/threading stuff? Parallelism isn't just achieved by spinning worker threads. In most cases you'll have the same performance with just one thread if you don't actually have a good reason to apply concurrency optimizations.".


My post says in the first line:
"Can someone help me with some Java. I read HashMap have a race condition where if you concurrently modify their size you can end in an infinite loop. I'm trying to get a POC code that might trigger it, but so far I have no luck being able to replicate i"

what is confusing about this? I CLEARLY say I'm trying to replicate this race condition in the first sentence. did you just read a word in my post? What is your whole post in response to? Please tell me how you interpreted my post that you decided you'd just give me a lecture of generic programming platitudes. "lol wow you get defensive easily" - see, I can say the same thing about you.

also thx for judging me so much, that's great. my coworkers treat me with respect so I treat them with respect. you treat me like a 5 yr old in your answer, i will treat you same way if i feel like it.

anyway, sorry for the last 3 posts by me being worthless. tldr guys - use concurrenthashmap (you can synchronize it externally but concurrent probably faster) if you are concurrently modifying a hashmap. beyond this easily noticeable condition, theres tons of other stuff most likely that might go wrong. concurrency hard ^^

this condition is nice b/c at least its hard not to notice your JVM suddenly eating all your CPU and stuck threads clearly stands out in thread dumps, vs just silent corruption. the cause of condition has to do with hashmap, resizing, and chaining used to resolve hash collisions. basically when resizing hashmap it will iterate through chains to plop nodes in new bucket, but if two threads hit resize, when its iterating through a chain node => node.next => node.next might end up back at original node (i.e. now we're in infinite loop).
RIP GOMTV. RIP PROLEAGUE.
ZenithM
Profile Joined February 2011
France15952 Posts
Last Edited: 2015-03-07 23:49:44
March 07 2015 23:49 GMT
#12029
My personal experience with non-concurrent hashmaps modified concurrently is that it often crashes with an exception when you iterate on them, but I didn't imagine it could even loop like that :D
So yeah, thank you, ConcurrentHashMap...
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-08 02:42:16
March 08 2015 02:40 GMT
#12030
On March 08 2015 08:38 teamamerica wrote:
Show nested quote +
On March 08 2015 07:41 Blisse wrote:
On March 07 2015 18:25 teamamerica wrote:
On March 07 2015 18:15 Blisse wrote:
You do know that if you have multiple threads accessing the same data structure concurrently is going to have race conditions right?

ConcurrentHashMap/ConcurrentAnything have mutex locks (probably some sort of monitor) on their state-modifying member functions, so that for example, two calls to Add() at the same time don't fuck up the data structure. I'm guessing you haven't done much parallism/threading stuff? Parallelism isn't just achieved by spinning worker threads. In most cases you'll have the same performance with just one thread if you don't actually have a good reason to apply concurrency optimizations.


Lol idk you read my thread at all. I know theres race condition with infinite loop, I just wanted to reliably replicate it. In practice i see it in work j2ee code basic that basically ends up with static maps wrapped in beans or cdi shit. I was debugging the issue in prod and coworkers are being annoying about understanding need to use concurrent maps so i wanted poc to show them.

I know i can use concurrent map to fix it, its what i freaking said in my post (concurrenthashmap will fix it). now i can just convince stubborn coworkers why they can just use concurrenthashmap and not complain.


lol wow you get angry easily. forgive me if i misinterpret a confusing post where your goal is to reproduce a race condition. remind me next time to not read your posts if this is how you talk to people who misread you. no wonder your coworkers are having a hard time if you act like this..


for u blisse <3
+ Show Spoiler +

lol you give me a condescending ass answer of " I'm guessing you haven't done much parallism/threading stuff? Parallelism isn't just achieved by spinning worker threads. In most cases you'll have the same performance with just one thread if you don't actually have a good reason to apply concurrency optimizations.".


My post says in the first line:
"Can someone help me with some Java. I read HashMap have a race condition where if you concurrently modify their size you can end in an infinite loop. I'm trying to get a POC code that might trigger it, but so far I have no luck being able to replicate i"

what is confusing about this? I CLEARLY say I'm trying to replicate this race condition in the first sentence. did you just read a word in my post? What is your whole post in response to? Please tell me how you interpreted my post that you decided you'd just give me a lecture of generic programming platitudes. "lol wow you get defensive easily" - see, I can say the same thing about you.

also thx for judging me so much, that's great. my coworkers treat me with respect so I treat them with respect. you treat me like a 5 yr old in your answer, i will treat you same way if i feel like it.

anyway, sorry for the last 3 posts by me being worthless. tldr guys - use concurrenthashmap (you can synchronize it externally but concurrent probably faster) if you are concurrently modifying a hashmap. beyond this easily noticeable condition, theres tons of other stuff most likely that might go wrong. concurrency hard ^^

this condition is nice b/c at least its hard not to notice your JVM suddenly eating all your CPU and stuck threads clearly stands out in thread dumps, vs just silent corruption. the cause of condition has to do with hashmap, resizing, and chaining used to resolve hash collisions. basically when resizing hashmap it will iterate through chains to plop nodes in new bucket, but if two threads hit resize, when its iterating through a chain node => node.next => node.next might end up back at original node (i.e. now we're in infinite loop).


i treated you like a 5 year old because i misinterpreted your post and i have no clue who you are over the internet - experienced or new. i assumed new because i read (misinterpreted at this point) you having obvious threading problems. however the way you're responding now shows the type of person you are, and i'm sorry you feel that i've insulted you initially (you deserved my second comment imo for your replies there), but really you've blown this ridiculously out of proportion and i honestly hope you're capable of apologizing sincerely at this point for continuing this as far as you have thus far and stopping your nonsense.
There is no one like you in the universe.
Cyx.
Profile Joined November 2010
Canada806 Posts
March 08 2015 02:48 GMT
#12031
On March 08 2015 11:40 Blisse wrote:
i treated you like a 5 year old because i misinterpreted your post and i have no clue who you are over the internet - experienced or new. i assumed new because i read (misinterpreted at this point) you having obvious threading problems. however the way you're responding now shows the type of person you are, and i'm sorry you feel that i've insulted you initially (you deserved my second comment imo for your replies there), but really you've blown this ridiculously out of proportion and i honestly hope you're capable of apologizing sincerely at this point for continuing this as far as you have thus far and stopping your nonsense.

Not that I really want to get into the personal argument on the internet, but I don't really think you're definitively the good guy in this discussion...
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-08 03:50:21
March 08 2015 03:07 GMT
#12032
+ Show Spoiler +
I'll apologize for trying to get on his nerves by saying he doesn't get along with his teammates but not unless he apologizes for needlessly cursing at me and replying in anger. This could have ended immediately if he just replied "I know what ConcurrentHashMaps are, I'm just trying to reproduce a race condition", but he didn't, and I don't see anything wrong with my initial reply since I was asking questions and making assumptions. I'm sorry there are miscommunications on the Internet but if you feel the need to swear at people because of that, then well I'd expect an apology because there was absolutely no need for that.

edit: actually I read over his two responses and it wasn't that bad so yeah i totally went overboard too. i've started to skim over stuff once i read swearing at me.

sorry about that teamamerica, i'll really have to make sure i don't respond to posts at 3am again >_>
There is no one like you in the universe.
tofucake
Profile Blog Joined October 2009
Hyrule19196 Posts
March 08 2015 05:10 GMT
#12033
everybody shut the hell up :D
Liquipediaasante sana squash banana
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2015-03-08 06:35:52
March 08 2015 06:30 GMT
#12034
microsofts c++ compiler is a god damned idiot.
it kept crashing without telling me why, yet having
the nerve to suggest i ought to simplify code that
was completely unrelated to the crash.

what is the point of this component / entity based
design? i get a consistent handle to something for
the price of having all my types inherit from some
useless baseclass? i can get a consitent handle for
something wihtout paying that price. i'm not sure
i understand it at all.

and if you are storing stuff via pointer, sure the owners,
of the pointer are stacked up nicely in your blob of
memory but you have no guarantee that the objects they
own are. so when you iterate over the collection, you
are still jumping all over the place in memory.
conspired against by a confederacy of dunces.
ZenithM
Profile Joined February 2011
France15952 Posts
Last Edited: 2015-03-08 06:53:56
March 08 2015 06:53 GMT
#12035
Shit, I always read your posts like poetry, it's pretty priceless xD. Everything you say sounds so much deeper.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
March 08 2015 06:56 GMT
#12036
i'm shooting for nice rectangular shapes is all.
conspired against by a confederacy of dunces.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
March 08 2015 10:38 GMT
#12037
On March 08 2015 15:30 nunez wrote:
microsofts c++ compiler is a god damned idiot.
it kept crashing without telling me why, yet having
the nerve to suggest i ought to simplify code that
was completely unrelated to the crash.

what is the point of this component / entity based
design? i get a consistent handle to something for
the price of having all my types inherit from some
useless baseclass? i can get a consitent handle for
something wihtout paying that price. i'm not sure
i understand it at all.

and if you are storing stuff via pointer, sure the owners,
of the pointer are stacked up nicely in your blob of
memory but you have no guarantee that the objects they
own are. so when you iterate over the collection, you
are still jumping all over the place in memory.

I think performance wise it "should" be better because you can split most actions up so that you can make most of your program run on cache instead of ram, but im not really knowledgeable about performance.
The harder it becomes, the more you should focus on the basics.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 08 2015 10:56 GMT
#12038
On March 08 2015 19:38 sabas123 wrote:
Show nested quote +
On March 08 2015 15:30 nunez wrote:
microsofts c++ compiler is a god damned idiot.
it kept crashing without telling me why, yet having
the nerve to suggest i ought to simplify code that
was completely unrelated to the crash.

what is the point of this component / entity based
design? i get a consistent handle to something for
the price of having all my types inherit from some
useless baseclass? i can get a consitent handle for
something wihtout paying that price. i'm not sure
i understand it at all.

and if you are storing stuff via pointer, sure the owners,
of the pointer are stacked up nicely in your blob of
memory but you have no guarantee that the objects they
own are. so when you iterate over the collection, you
are still jumping all over the place in memory.

I think performance wise it "should" be better because you can split most actions up so that you can make most of your program run on cache instead of ram, but im not really knowledgeable about performance.

I don't even know what you're talking about with that splitting actions up part, but I do know that you are thinking about performance without any need to do so. Also if my understanding of entity/component design is correct and a quick google search is to be trusted, it is rather bad for performance than good because every time you are trying to do something, you have to filter a list of random stuff for the stuff that you can work on before you can do that work. But once again, that's a pointless consideration. Messing up your static typing (which you should be really glad to have) by type casting is much more problematic.
If you have a good reason to disagree with the above, please tell me. Thank you.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
March 08 2015 11:44 GMT
#12039
@sabas
be better than what?

to specify, i was commenting nerthert post and example, which i might be misunderstanding,.
he holds pointers in vectors, and not the actual objects. thus the objects are not layed out in
continguous memory, and you memory access pattern is at the mercy of your allocator.
conspired against by a confederacy of dunces.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
March 08 2015 12:00 GMT
#12040
On March 08 2015 19:56 spinesheath wrote:
Show nested quote +
On March 08 2015 19:38 sabas123 wrote:
On March 08 2015 15:30 nunez wrote:
microsofts c++ compiler is a god damned idiot.
it kept crashing without telling me why, yet having
the nerve to suggest i ought to simplify code that
was completely unrelated to the crash.

what is the point of this component / entity based
design? i get a consistent handle to something for
the price of having all my types inherit from some
useless baseclass? i can get a consitent handle for
something wihtout paying that price. i'm not sure
i understand it at all.

and if you are storing stuff via pointer, sure the owners,
of the pointer are stacked up nicely in your blob of
memory but you have no guarantee that the objects they
own are. so when you iterate over the collection, you
are still jumping all over the place in memory.

I think performance wise it "should" be better because you can split most actions up so that you can make most of your program run on cache instead of ram, but im not really knowledgeable about performance.

I don't even know what you're talking about with that splitting actions up part, but I do know that you are thinking about performance without any need to do so. Also if my understanding of entity/component design is correct and a quick google search is to be trusted, it is rather bad for performance than good because every time you are trying to do something, you have to filter a list of random stuff for the stuff that you can work on before you can do that work. But once again, that's a pointless consideration. Messing up your static typing (which you should be really glad to have) by type casting is much more problematic.

My idea was to have some kind of sorter that will do the filter and then give that to the function/system/processor (how ever you want to call it).

My intention isn't performance, but from what I read it should be possible to have faster performance with this kind of architecture then the traditional class hierarchy
The harder it becomes, the more you should focus on the basics.
Prev 1 600 601 602 603 604 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Team League
12:00
Group B
WardiTV294
3DClanTV 12
IndyStarCraft 0
TKL 0
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko320
SortOf 170
ProTech28
TKL 25
IndyStarCraft 0
StarCraft: Brood War
Britney 39945
Sea 2164
Killer 803
Jaedong 720
BeSt 463
Rush 381
Mini 283
EffOrt 268
Larva 241
Soma 225
[ Show more ]
Stork 184
Light 176
Snow 171
ZerO 106
Sharp 99
hero 78
ToSsGirL 78
Sea.KH 48
Shine 45
Mind 45
Backho 40
[sc1f]eonzerg 27
Barracks 27
soO 23
Movie 18
Bale 17
Icarus 14
Terrorterran 11
Noble 10
Dota 2
XaKoH 496
XcaliburYe334
canceldota80
BananaSlamJamma49
Counter-Strike
fl0m1967
pashabiceps1499
Fnx 1397
shoxiejesuss710
x6flipin280
Super Smash Bros
Mew2King72
Westballz17
Other Games
singsing3330
B2W.Neo906
crisheroes280
Sick167
hiko118
ToD62
QueenE38
Trikslyr21
ZerO(Twitch)8
Organizations
Dota 2
PGL Dota 2 - Main Stream179
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• musti20045 14
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 7
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota290
League of Legends
• Jankos744
Upcoming Events
Big Brain Bouts
4h 49m
LetaleX vs Babymarine
Harstem vs GgMaChine
Clem vs Serral
Korean StarCraft League
14h 49m
RSL Revival
21h 49m
Maru vs Zoun
Cure vs ByuN
uThermal 2v2 Circuit
1d 2h
BSL
1d 7h
RSL Revival
1d 21h
herO vs MaxPax
Rogue vs TriGGeR
BSL
2 days
Replay Cast
2 days
Replay Cast
2 days
Afreeca Starleague
2 days
Sharp vs Scan
Rain vs Mong
[ Show More ]
Wardi Open
2 days
Monday Night Weeklies
3 days
Sparkling Tuna Cup
3 days
Afreeca Starleague
3 days
Soulkey vs Ample
JyJ vs sSak
Replay Cast
4 days
Afreeca Starleague
4 days
hero vs YSC
Larva vs Shine
Kung Fu Cup
4 days
Replay Cast
5 days
The PondCast
5 days
WardiTV Team League
5 days
Replay Cast
6 days
WardiTV Team League
6 days
Liquipedia Results

Completed

Proleague 2026-03-18
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
CSL Elite League 2026
RSL Revival: Season 4
Nations Cup 2026
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
CSL 2026 SPRING (S20)
CSL Season 20: Qualifier 1
Acropolis #4
IPSL Spring 2026
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
NationLESS Cup
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.