Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <arand> Yeah, I was thinking I coulf set a bunch of globabl variables using a loop
- * Rygar has quit (Quit: Red Eclipse, www.redeclipse.net)
- <thedardanius> hey, Im a C++ dev, are there any red eclipse devs here?
- <thedardanius> I have a suggestion for you
- <Hirato> do [ local bob; bob = "not sally" ] <-- bob's stack is popepd afterwards and it's not udnefined
- <Hirato> do [bob = 2]; echo $bob will give you two
- <quin> oh, must have changed, i used to have issues with it
- <thedardanius> any redeclipse devs here?
- <arand> What I'm kind-of trying to do is http://paste.debian.net/175649/
- <Hirato> no devs, jsut cowboys, yeeeeeehaw!
- <thedardanius> dafuq
- <Hirato> quin: same as always, the local keyword is new though
- <thedardanius> what langauge are you talking about
- <thedardanius> C++?
- <thedardanius> C?
- <arand> thedardanius: Yes there are
- <pk1001100011> o.o
- <Hirato> let's say it's C+-
- <thedardanius> are you a dev?
- <Hirato> :|
- <thedardanius> hirato, u clearly have no understanding of C++
- <arand> thedardanius: We're talking about cubescript the cube2 engine scripting lang
- <thedardanius> oh
- <thedardanius> like that
- <quin> Hirato is being facetious
- <pk1001100011> hey, Im a C++ dev; what langauge are you talking about; C++? O.O
- <thedardanius> yeah
- <thedardanius> nornak qestiob
- <thedardanius> *question
- <Hirato> I'm surprised he could say that after the code samples
- <thedardanius> but I have a sggestion for the engine
- <thedardanius> if there are any devs online now...
- <quin> you'd probably want the cube engine forums then
- <quin> we're just a game
- <Hirato> let's hear him out anyway
- <thedardanius> anyway
- <thedardanius> ok
- <Hirato> might be something that's not.. appropriate for sauer
- <thedardanius> well I think some parts of the engine could be converted into more C-ish code
- <quin> i suppose
- <thedardanius> since using some C++ feautures slow down the performance
- <thedardanius> but its just for some small parts
- <thedardanius> I mean
- <thedardanius> C++ is powerful, but when using certain attributes it might be a small nuisance. THen I prefer C
- <quin> i'd caution you not to make generalisations without making specific examples
- <thedardanius> ok
- <FallenWarlock> thedardanius: http://cubeengine.com/ <-- Cube engine website
- <thedardanius> so like that the cube engine sometimes uses virtual functions
- <thedardanius> or templates
- <thedardanius> nothing wrong about that
- <thedardanius> but with virtual fuctions
- <quin> in the struct abstractions, yes
- <thedardanius> I would recommend not to use these
- <thedardanius> but its up to the des finally ;p
- <thedardanius> *devs
- <quin> i don't think he would have used it if he thought it was going to be a major problem
- <thedardanius> Im not sayin its a major problem
- <arand> So is it possible to do some (pseudocode) "for i in list set list[i]_var = i" and get word_var:s to be available globally?
- <Hirato> the only ones I know of are used with the stream structure, the functions that are overridden are pure abstract and optimised quite efficiently by the compiler
- <thedardanius> did you read what i said before
- <Hirato> I think...
- * Kastra117 (~kastra@2.30.190.202) has joined #redeclipse
- <thedardanius> its that tese C++ are powerful
- * Patrik (~Patrik@p4FE574E1.dip.t-dialin.net) has joined #redeclipse
- <thedardanius> but since optimal optimization is right to do now
- <thedardanius> we can go a step down to C
- <thedardanius> since the main code is finished
- * Patrik is now known as Guest55277
- <thedardanius> we can do some precise optimizations
- * Guest55277 has quit (Client Quit)
- <quin> it's never finished really, heh
- <thedardanius> well the main code is
- <quin> there is no stable API in cube
- <thedardanius> not finished
- <thedardanius> WTF
- <thedardanius> im not talking about the API
- <Hirato> you'd probably want to talk to eihrul about that stuff too, I doubt he'd approve though
- <thedardanius> cube doenst even have a API
- <thedardanius> its an engine
- <thedardanius> never mind
- * quin scratches his head
- <thedardanius> Hirato, no offence, but gtfo you dont even know exaclty what Im talking about
- <thedardanius> stop interupting me and the others
- <thedardanius> youre almost a nuisance
- * quin looks at Hirato
- <quin> go for it man
- <pk1001100011> 3
- <Hirato> I am well aware that the compiler inlines the template stuff, a more "C like" adaptation of them will not net us any speed boosts
- <pk1001100011> 2
- <pk1001100011> ;)
- <pk1001100011> Be… I was thinking about kick, not answer. :(
- <thedardanius> true for some parts
- <thedardanius> but it is true that inlining generated larger but faster code, which is good
- <Hirato> also with virtual functions, pure abstract prototypes can also be significantly optimised by the compiler, graphitemaster can explain taht black magic to you
- <thedardanius> of course, this depends
- <thedardanius> the compiler never inlines everything you tell it to
- <thedardanius> it can decide on its own if it should
- <quin> as i said, if it that much of a problem eihrul would have fixed it
- <quin> he understands this stuff far more than anyone
- <thedardanius> IM NOT TALKING ABOUT THE PROBS
- <graphitemaster> two interesting tricks to doing free virtual function calls
- <thedardanius> IM TALKING ABOUT POSSILE OPTIMIZATIONS
- <thedardanius> SRSLY
- <thedardanius> FACK
- <thedardanius> THIS
- <thedardanius> im off
- <Hirato> I'm well aware of that, but in the few instances templates are used in our code, the functions are very small and won't gain us anything
- <thedardanius> true
- <thedardanius> i agree with you
- <thedardanius> but templates used in alrger engines are usually quite large in size
- <graphitemaster> this is a very interesting trick:
- <graphitemaster> sometype localobject;
- <graphitemaster> sometype* localptr = &localobject;
- <thedardanius> yeah
- <graphitemaster> since that object is allocated on the heap and has a known type to the compiler, it can optimize away the entire vtable
- <thedardanius> yes
- <quin> can someone just ban him already? i can't do it easily with the webchat
- <thedardanius> this is quite smart yes
- <graphitemaster> ban who?
- <thedardanius> but graphmaster, the local object itself is created on the stack
- <thedardanius> since the pointer points to this adress space in the stack
- <quin> i'm not going to be yelled at in my own channel
- <graphitemaster> Anyways thedardanius gcc and clang and MSVC are getting realy good at inlining things, infact they're inline machines
- <thedardanius> I know
- <graphitemaster> There are some things that are hard to actually inline for the compile if its context cannot be evaluated at compile-time
- <thedardanius> I also dont contend the cube engine is wrong or sth
- <Hirato> I'll let graphitemaster do it when he's done \o/
- <thedardanius> the cube engine ie VERY efficient and well coded
- <graphitemaster> The cube engine is one of those things that does inline well, and if you don't belive me just look at scale.h
- <thedardanius> but I just had a suggestion, a subtle change
- <graphitemaster> thedardanius, what was the change?
- <thedardanius> I just had a optimization suggestion
- <graphitemaster> Regarding?
- <thedardanius> but the cube engine is efficient
- <thedardanius> dont get me wrong
- <thedardanius> regarding overal performance
- <graphitemaster> are you talking about the virtual functions?
- <thedardanius> yeah
- <thedardanius> theydo slow down certain thins
- <quin> i think i need to work on that next article sooner rather than later
- <graphitemaster> a virtual function is about as slow as a function pointer
- <thedardanius> since you need 2 adress pointers
- <thedardanius> basically
- <thedardanius> to the vtable
- <thedardanius> and to the function itself
- <graphitemaster> right, and those lookups can easily cause a cache miss
- <thedardanius> true
- <thedardanius> but of course
- <graphitemaster> except the way sauer implements them this isn't the case
- <thedardanius> it are the devs who decide this
- <graphitemaster> s/sauer/cube2/
- <thedardanius> how does sauer implement them?
- <thedardanius> how ?
- <graphitemaster> you only suffer performance wise an additional dereference through the vtable
- <graphitemaster> this _used_ to be slow, but modern CPUs have BTBs and it's literally costless
- <thedardanius> yeah of course, the performance depens on the architecture of CPU i know
- <thedardanius> well like this, we can go on to higher languages
- <graphitemaster> and if the compiler is smart enough to evaluate the context at compile-time (which I assume it is) it's likely costless
- <thedardanius> true
- <thedardanius> some things are indeeed "costless"
- <thedardanius> well im going
- <thedardanius> cy
- <graphitemaster> in anycase the only thing you're paying for is the indirect call
- <thedardanius> what are you actually graphmaster>
- <thedardanius> a dev?
- <graphitemaster> so if it was a function pointer, a functor, or a virtual function all three of them suffer the same indirect call issue
- <thedardanius> that depens
- <Hirato> sort of, but he's very knowledgeable on CPUs and compielr stuff
- <graphitemaster> actually never mind the functor could be inlined right down if it was templated
- <graphitemaster> i.e class calling T::functor
- <quin> is that because of function overloading?
- <thedardanius> yeah go on grpahmaster
- <graphitemaster> anyways here's the cool thing, branch target buffers would notice the indirect calls over time and they'd get cheaper and cheaper each call untill the CPU simply knows the address in advance
- <thedardanius> but this requires a pointer of course
- <thedardanius> this pointer is the actual pointer youre using
- <graphitemaster> but yes I agree the whole thing could be inlined if functors were used
- <thedardanius> well
- <thedardanius> I cant change the engine
- <graphitemaster> since 1) they can be inline
- <thedardanius> eihrul should do that
- <graphitemaster> since 2) even if they can't be inlined, theyre DIRECT calls
- <thedardanius> true
- <thedardanius> but I would inline them
- <graphitemaster> but again I think the virtual function stuff is just simpler to write
- <thedardanius> that the whole POINT of C++
- <thedardanius> its easier, it covers the dark conrer of C
- <thedardanius> well not easier
- <thedardanius> but better readible
- <graphitemaster> I mean shit, do you think eihrul cares about supporting old CPUs where loading TWO pointers is going to be so detrimental to the speed of the game?
- <graphitemaster> I bet you the game wouldn't even run on systems like those to begin with :P
- <thedardanius> well never mind
- <thedardanius> Im talking about precise optimizations
- <thedardanius> this would be that necessary
- <graphitemaster> premature optimization, root of all evil
- <thedardanius> this aint
- <thedardanius> since the cube engine is quite complete
- <thedardanius> some FIne optimization is acceptable
- <graphitemaster> well optimize it, send a patch and see what the lead devs say
- <thedardanius> never mind
- <thedardanius> just wanted to get the idea across
- <quin> no, he'd rather tell other people what to do
- <thedardanius> its just a suggetsion quin
- <thedardanius> srsly
- <quin> because his point of view is the only thing that matters here
- <thedardanius> yeah hes the creator hes the head I know
- <graphitemaster> quin, you're not helping the situation
- <thedardanius> no
- <thedardanius> please
- <thedardanius> would you be so kind not to interfere
- <quin> excuse me
- <quin> you're in MY channel
- <thedardanius> so
- <thedardanius> its a channel
- <quin> go annoy the cube community
- <graphitemaster> thedardanius, anyways if it's that much of a concern and you want it to get headway you can make a patch
- <thedardanius> for chatting
- <thedardanius> ill try to
- <thedardanius> but
- <thedardanius> first
- <thedardanius> I havet to finished my own C++ engine
- <graphitemaster> thats why we're opensource, if you have an idea make it then tell us about it
- <thedardanius> yeah exaclty
- <thedardanius> what I wanted to do
- <graphitemaster> everything sounds fine when it comes out of your mouth, doesn't mean it's true
- <thedardanius> together we can improve the situation
- <thedardanius> well
- <graphitemaster> I can talk a pile of shit too, and I do, I need to stop doing that :P
- <thedardanius> ;p
- <thedardanius> lets quit this
- * quin sets ban on *!*@80.60.172.127
- <thedardanius> f
- * quin has kicked thedardanius from #redeclipse (Bye)
- <graphitemaster> quin, >_>
- * quin sets ban on *!*@*/80.60.172.127
- <Hirato> awh, wanted to kick him with "dong dong bannu"
- <Hirato> "costless", like his mom, amirite? :D
- * quin sets ban on *!*@*/ip.80.60.172.127
- * quin removes ban on *!*@*/80.60.172.127
- <graphitemaster> I don't think he even warrented a ban
- <quin> people like that are worthless
- <Hirato> he yeleld at me and disrespected quin's authority
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement