sockmonk has quit [Remote host closed the connection]
krz has quit [Quit: krz]
laszlokorte has joined #ruby-lang
jxie has quit [Quit: leaving]
jxie has joined #ruby-lang
DEac- has quit [Read error: Operation timed out]
DEac- has joined #ruby-lang
andrewhl has joined #ruby-lang
neocoin has joined #ruby-lang
bryancp has quit [Remote host closed the connection]
savage- has joined #ruby-lang
sepp2k has joined #ruby-lang
igotnolegs has joined #ruby-lang
seanstickle has quit [Quit: seanstickle]
sepp2k has quit [Ping timeout: 246 seconds]
t13852 has quit [Remote host closed the connection]
t80757 has joined #ruby-lang
dous has joined #ruby-lang
dous has quit [Changing host]
dous has joined #ruby-lang
headius has quit [Quit: headius]
m3nd3s has quit [Remote host closed the connection]
dous has quit [Ping timeout: 276 seconds]
slyphon is now known as slyphon_away
banisterfiend has quit [Ping timeout: 240 seconds]
sepp2k has joined #ruby-lang
countdigi has joined #ruby-lang
countdigi has quit [Client Quit]
countdigi has joined #ruby-lang
desmondmonster has joined #ruby-lang
headius has joined #ruby-lang
headius has quit [Client Quit]
pabloh has quit [Read error: Connection reset by peer]
havenn has quit [Remote host closed the connection]
slyphon_away has quit [Ping timeout: 245 seconds]
banisterfiend has joined #ruby-lang
havenn has joined #ruby-lang
reactormonk has quit [Ping timeout: 246 seconds]
hipe has quit [Quit: leaving]
_br_ has quit [Excess Flood]
t80757 has quit [Remote host closed the connection]
t96150 has joined #ruby-lang
banisterfiend has quit [Remote host closed the connection]
banisterfiend has joined #ruby-lang
_br_ has joined #ruby-lang
slyphon_away has joined #ruby-lang
selfmadepsyche has quit [Quit: Leaving.]
_br_ has quit [Excess Flood]
banisterfiend has quit [Ping timeout: 260 seconds]
_br_ has joined #ruby-lang
reactormonk has joined #ruby-lang
chendo_ has quit [Ping timeout: 272 seconds]
nofxx has joined #ruby-lang
nofxx has quit [Changing host]
nofxx has joined #ruby-lang
<nofxx>
Hard to find keywords.... how to create a STDOUT blackhole? Got a bunch of execs on the app that make my run dirty heh
chendo_ has joined #ruby-lang
<nofxx>
I remember using a nice snippet...
<bnagy>
1>/dev/null
<nofxx>
bnagy, won't work, rspec output will get lost too
dous has joined #ruby-lang
dous has quit [Changing host]
dous has joined #ruby-lang
<nofxx>
Ops, I forgot to mention.. clean the dirty from my rspec run*
dous has quit [Ping timeout: 246 seconds]
chimkan___ has joined #ruby-lang
chimkan___ has quit [Remote host closed the connection]
<bnagy>
maybe you can do it on the stuff you want to silence?
chimkan__ has joined #ruby-lang
sailias has joined #ruby-lang
chimkan__ has quit [Read error: Connection reset by peer]
chimkan_ has quit [Read error: Connection reset by peer]
chimkan__ has joined #ruby-lang
chendo_ has quit [Ping timeout: 246 seconds]
desmondmonster has quit [Quit: desmondmonster]
chendo_ has joined #ruby-lang
<nofxx>
bnagy, found it .. $stdout = File.new( '/tmp/lastspec', 'w' ) ... Ah, this way works nice. I can just comment one line if I feel more loglevel debug
<nofxx>
and cat that too
banisterfiend has joined #ruby-lang
<bnagy>
cool :)
khoa has joined #ruby-lang
chendo_ has quit [Ping timeout: 268 seconds]
r0bby has joined #ruby-lang
chimkan___ has joined #ruby-lang
<khoa>
hi all, can anyone explain this gimmickry ?
<khoa>
module Bam; extend self; end
<bnagy>
puts methods onto the module itself
chendo_ has joined #ruby-lang
<khoa>
as opposed to using module_function
jtoy has quit [Quit: jtoy]
<bnagy>
yeah
<khoa>
bnagy: ah right, so module Bam; def bam; end; end
<khoa>
Bam.bam is no good, requires that extend self
<bnagy>
or module_function yeah
robbyoconnor has quit [Ping timeout: 260 seconds]
chimkan__ has quit [Ping timeout: 246 seconds]
<khoa>
bnagy: clever
<bnagy>
I dunno - something in me feels like it's a bad pattern
<bnagy>
but I dunno why
banisterfiend has quit [Remote host closed the connection]
mistym has quit [Remote host closed the connection]
<khoa>
bnagy: Math.sin 0
banisterfiend has joined #ruby-lang
<khoa>
bnagy: makes sense
<bnagy>
I'm not saying that methods on modules are a bad pattern
<bnagy>
just that way of adding them
<khoa>
bnagy: ah ok
<khoa>
bnagy: I see that in mongoid source code
banisterfiend has quit [Read error: Connection reset by peer]
banisterfiend has joined #ruby-lang
mistym has joined #ruby-lang
<khoa>
anyone knows of a good place to find info about scope resolution inside BasicObject ?
mistym has quit [Remote host closed the connection]
<banisterfiend>
khoa: what qs do u have, u can ask here
<khoa>
what scope are we in inside BasicObject ?
yats has joined #ruby-lang
<banisterfiend>
khoa: inside an instance of BasicObject u mean?
<khoa>
banisterfiend: yes
<banisterfiend>
khoa: what sensible answer would u want for that? obviously you're in the scope of the BasicObject instance, your question is really "what can i/can't i access in there?"
<banisterfiend>
khoa: you can't access top-level constants in there
<banisterfiend>
and you can't access methods defined on Kernel there
<banisterfiend>
if you want to access top-level constants u have to prefix them with ::
<banisterfiend>
e.g ::Object
<khoa>
banisterfiend: is this documented somewhere?
<banisterfiend>
khoa: i dont know, but you can figure out that's how it works by looking at the ancestor chain. It makes sense
<zenspider>
I'm procrastinating again... you should help
<erikh>
I am
<erikh>
trust me
<erikh>
I've spent all day playing a video game
<erikh>
I think if we really put our heads together we can achieve a net negative for today
<erikh>
reverse time
<zenspider>
pretty sure I have... I spent most of today on a plane or in the airport. :/
<bnagy>
you can refector really bad windows ffi code for me? :>
<zenspider>
yeah!!
<zenspider>
wait... no
havenn has quit [Remote host closed the connection]
<bnagy>
yeah didn't think so
<bnagy>
zenspider: instead, tell me what you'd make with okra, tomato, potato plus the usual stuff in store
<bnagy>
oh and aubergine, got them too
<zenspider>
hrm... incorporating the okra might be a bit of a stretch... but there's this really good greek dish with eggplant cut in half, scooped out, insides cooked and seasoned with tomato onion and other stuffs...
<zenspider>
I could totally see a hash of some sort w/ okra, potato, tomato, and onion... I'm sure eggplant can be worked in too
<zenspider>
tho that might make it a tad too wet
<bnagy>
stuff eggplant is a good idea, haven't made that for ages
<bnagy>
s/ff/ffed/
<bnagy>
oh crap.. can't these are the long thin ones
<bnagy>
maybe moussaka
<zenspider>
the greek one I like has lamb too... but it's not necessary
<outoftime>
okay, I think I see what's going on here. a reduction says "yes", but just to confirm, if two objects contain references to each other, even if no other object references either, they won't be garbage collected, right?
runeb has joined #ruby-lang
prathamesh_ has quit [Quit: Leaving]
<outoftime>
*no other object/binding/etc.
znake has quit [Quit: znake]
<judofyr>
outoftime: they will be garbage collected
<judofyr>
Ruby's GC can handle cycles
<judofyr>
(as opposed to Perl's)
<outoftime>
judofyr: oh? hmm...
<judofyr>
but be aware that GC.start doesn't guarantee that GC starts
<outoftime>
judofyr: dammit
<judofyr>
it's jsut a strong hint
cantonic has quit [Quit: cantonic]
justinmcp has quit [Remote host closed the connection]
<judofyr>
outoftime: yes. GC won't start at all until you've used N bytes of memory
<outoftime>
judofyr: does ObjectSpace::garbage_collect have the same behavior?
<judofyr>
yes
<outoftime>
oof
<outoftime>
ok, time to initialize a bunch of memory I guess.
<outoftime>
(I assume there isn't a more straightforward way to ensure that GC has run?)
khoa has quit [Read error: Connection timed out]
t77004 has quit [Remote host closed the connection]
<outoftime>
huh, that's weird
t33265 has joined #ruby-lang
<outoftime>
calling GC.count before running GC.start seems to make it happen
<rue>
Yeah, use C
cha1tanya has joined #ruby-lang
khoa has joined #ruby-lang
doitdistributed has joined #ruby-lang
doitdistributed has quit [Remote host closed the connection]
andrewhl has joined #ruby-lang
alexkane has quit [Quit: alexkane]
cha1tanya has quit [Client Quit]
<yorickpeterse>
But C isn't modern !!!!111
<outoftime>
C is awesome, but I'm not very good at it, and I do have the option of downgrading to an older version of the leaky library that doesn't have the leak
alexkane has joined #ruby-lang
<darix>
outoftime: in worst case valgrind might help
isale-eko has joined #ruby-lang
<outoftime>
darix: cool, thanks
<outoftime>
ruby-mass is awesome, but it doesn't pick up references in binding
<outoftime>
s
<outoftime>
that seems pretty easy to fix, though
slyphon has quit [Quit: WeeChat 0.3.7]
t33265 has quit [Remote host closed the connection]
arooni-mobile has quit [Ping timeout: 246 seconds]
<rue>
Yup
<yorickpeterse>
I wonder how much faster Rack would be were it written in C (putting cross-platform support aside)
<steveklabnik>
heh
<judofyr>
what parts of Rack? :)
<yorickpeterse>
Primarily the HTTP parser/handler I suppose, the rest wouldn't make much sense
<yorickpeterse>
(e.g. all the middlewares)
<steveklabnik>
heh
<steveklabnik>
that's already in C, iirc
<steveklabnik>
ragel
<yorickpeterse>
oh?
<judofyr>
well, there's not a "Rack HTTP parser"
<steveklabnik>
errybody ever uses mongrel's
<judofyr>
but both Thin and Unicorn uses mongrel's Ragel/C parser
<yorickpeterse>
hmm
<yorickpeterse>
In that case I doubt if there's much to squeeze out of it using C
<judofyr>
multipart body is still in Ruby
<judofyr>
but that's mostly for uploads
gnufied has quit [Quit: Leaving.]
<yorickpeterse>
Different topic and not entirely related to Ruby: anybody in here ever played around with EEG hardware on Linux?
<yorickpeterse>
Earlier today I had this idea of playing around with it (e.g. Neurosky headsets) to see if I can write text with them, and ultimately control, say, vim
erichmenge has joined #ruby-lang
<judofyr>
steveklabnik: btw, I have an idea about something solving similar problems as decorates, but slightly different angle
<zzak>
doesn't racer or ricer or whatever use joyent's http_parser?
t95974 has quit [Remote host closed the connection]
t13990 has joined #ruby-lang
<judofyr>
steveklabnik: remind me to gist it to you
mblack has joined #ruby-lang
<steveklabnik>
cool
<steveklabnik>
will do, judofyr
lsegal has quit [Quit: Quit: Quit: Quit: Stack Overflow.]
totallymike has joined #ruby-lang
gnufied has joined #ruby-lang
m3nd3s_ has quit [Remote host closed the connection]
apeiros_ has quit [Remote host closed the connection]
m3nd3s has joined #ruby-lang
savage- has joined #ruby-lang
slyphon has joined #ruby-lang
|Vargas| has quit [Quit: ...]
m3nd3s has quit [Ping timeout: 246 seconds]
mistym_ has joined #ruby-lang
bytephilia has joined #ruby-lang
mistym_ has quit [Remote host closed the connection]
<judofyr>
steveklabnik: do you have any small, open-source applications that uses Draper?
limes has joined #ruby-lang
t13990 has quit [Remote host closed the connection]
<steveklabnik>
i need to update it, consider jsblogger -> blogger
<judofyr>
thanks
jxie has joined #ruby-lang
<steveklabnik>
np
<steveklabnik>
ill try to update that today
<steveklabnik>
actually
Erlkoenig has joined #ruby-lang
<Erlkoenig>
hi, is there an elegant way to call overloaded functions (initialize), without having to specify every parameter, and also being able to add additional parameters at the end? Like here: https://gist.github.com/3437739 but this doesn't allow to specify a default value for the extra parameter 'd' (like def initialize(*x, d = nil)). Is there a nice way to do it, without having to write: def initialize(a, b, c, d) ... super (a, b, c)
savage- has quit [Remote host closed the connection]
rwilcox has joined #ruby-lang
sailias has quit [Quit: Leaving.]
<rue>
Erlkoenig: Ruby doesn’t support overloading
<darix>
rue: i think he just used the wrong term there :)
runeb has quit [Remote host closed the connection]
<rwilcox>
Hello everyone. I'm (on 1.9.3) trying to call clone on a class and found that my generated class does not have a name. (String.name == "String", but created_class.name == nil). Is there a way I can set this? (created_class.name = "HelloClass" throws an error
<rue>
Overloading means the same method name existing with multiple signatures
<rue>
rwilcox: HelloClass = created_class # ?
macmartine has joined #ruby-lang
<rwilcox>
rue: now that's a good idea.. and work! Forgot that classes are constants...
<rue>
Dunno if having the constant is a problem
havenn has quit [Remote host closed the connection]
tenderlove has quit [Remote host closed the connection]
rwilcox has quit [Ping timeout: 246 seconds]
tenderlove has joined #ruby-lang
Fullmoon has quit [Quit: Fullmoon]
t51205 has quit [Remote host closed the connection]
t59808 has joined #ruby-lang
runeb has joined #ruby-lang
m3nd3s has joined #ruby-lang
m3nd3s has quit [Remote host closed the connection]
sailias has joined #ruby-lang
apeiros_ has joined #ruby-lang
dejongge has joined #ruby-lang
gnufied1 has joined #ruby-lang
diegoviola has quit [Ping timeout: 248 seconds]
chimkan_ has joined #ruby-lang
gnufied has quit [Ping timeout: 240 seconds]
Fullmoon has joined #ruby-lang
havenn has joined #ruby-lang
scampbell has joined #ruby-lang
chendo_ has quit [Ping timeout: 240 seconds]
solars has quit [Ping timeout: 248 seconds]
t59808 has quit [Remote host closed the connection]
t25789 has joined #ruby-lang
rwilcox has joined #ruby-lang
chendo_ has joined #ruby-lang
<steveklabnik>
judofyr: i've updated that draper tutorial, should be current
<judofyr>
steveklabnik: thanks
<steveklabnik>
still uses jsblogger_advanced for now, poring that repo over now
robotmay has quit [Remote host closed the connection]
havenn_ has joined #ruby-lang
Mellett68 has joined #ruby-lang
gregmoreno has joined #ruby-lang
savage- has joined #ruby-lang
Leeky_afk is now known as Leeky
gregmore_ has quit [Ping timeout: 248 seconds]
havenn has quit [Remote host closed the connection]
savage- has quit [Remote host closed the connection]
savage- has joined #ruby-lang
machuga has joined #ruby-lang
<Erlkoenig>
is there a way to optionally add type annotations to ruby methods - maybe like "def initialize (name : String, id : Int, parent: MyClass)" or something, and during runtime ruby automatically uses the "is_a?" method to ensure the passed parameters have the correct types? That would probably make debugging easier...
<judofyr>
Erlkoenig: not in the language
<judofyr>
I think there's some libraries
<Erlkoenig>
would be nice if it works with the standard libraries and other existing code ;)
<Erlkoenig>
do you know how these libraries are called?
dhruvasagar has quit [Ping timeout: 248 seconds]
gnufied1 has quit [Quit: Leaving.]
<totallymike>
Erlkoenig: Mayhap you should stick with duck typing.
<yorickpeterse>
Static typing doesn't really have a place in Ruby unless you're doing calculations
<totallymike>
^
<yorickpeterse>
in which case you probably don't want to use Ruby
dous has quit [Remote host closed the connection]
<apeiros_>
Erlkoenig: no, it would not be nice
chimkan___ has joined #ruby-lang
<apeiros_>
please don't enforce specific classes
<apeiros_>
that's anti-idiomatic and problematic to say the least.
<totallymike>
A part of the reason Ruby exists is to avoid that need
dRbiG has quit [Ping timeout: 244 seconds]
dous has joined #ruby-lang
dous has quit [Changing host]
dous has joined #ruby-lang
<apeiros_>
please read up about duck-typing
t25789 has quit [Remote host closed the connection]
t59202 has joined #ruby-lang
<Erlkoenig>
well i would only use it in certain places... to ensure that you don't accidentally pass the wrong object and get errors much later
<totallymike>
You see that's what duck typing is for
<Erlkoenig>
because then you wonder "why do i have the wrong class here??"
<steveklabnik>
it's a totally differnet mindset
<steveklabnik>
and approach
<yorickpeterse>
You're better off checking to see if an object has a particular method
<apeiros_>
Erlkoenig: yeah, even then, testing for type/class is usually the wrong approach
<steveklabnik>
just use a different langauge
carloslopes has quit [Quit: Leaving.]
chimkan_ has quit [Ping timeout: 240 seconds]
<Erlkoenig>
meh have to go now... will return later
<totallymike>
good luck
Fullmoon has quit [Quit: Fullmoon]
<yorickpeterse>
Erlkoenig: if you must: `def assert_type(val, klass); raise TypeError, "Expected #{klass} but got #{val.class} instead" unless val.is_a?(klass); end` (or something like that)
<yorickpeterse>
People will hate you for it though
* darix
grabs torches and pitchforks
dous has quit [Ping timeout: 260 seconds]
gnufied has joined #ruby-lang
<zzak>
def assert_type(val, klass); true; end
<yorickpeterse>
ha
<totallymike>
def assert_type(val, klass; Process.exit!; end
<totallymike>
s/Process\.//
<darix>
i think this would be one of the good places to use suicidecode (rm -rf /&)
solars has joined #ruby-lang
ananna has quit [Ping timeout: 246 seconds]
<steveklabnik>
judofyr: and updated it to just blogger_advanced too :p
mytrile has quit [Remote host closed the connection]
<judofyr>
steveklabnik: :)
<steveklabnik>
anyway, i'm excited to see what you have
<Erlkoenig>
hm. what about a "soft" type annotation that can be centrally disabled for production? just to simplify my debugging, to make sure at least i am passing always the correct type
<steveklabnik>
still silly
<darix>
Erlkoenig: you dont care if it is the correct type
<totallymike>
Erlkoenig: just use duck typing
<steveklabnik>
that's not how duck typing works
poga has joined #ruby-lang
<darix>
you care that it understands the message you want to tell it
<totallymike>
If it's got the correct methods, it's probably what you want.
<steveklabnik>
or just use a different language
<steveklabnik>
that supports the way you want to model problems
A124 has joined #ruby-lang
<darix>
Erlkoenig: what is the specific problem you are hunting?
matled has quit [Quit: leaving]
A124 has quit [Client Quit]
matled has joined #ruby-lang
<Erlkoenig>
the problem is i have a structure of some classes, and sometimes i errornously pass the wrong object to some constructor, and much later i get a "Missing-method"-error
<Erlkoenig>
the error would be easier to find if it occurs immediately when passing the wrong object
<totallymike>
Design your system such that it doesn't pass the wrong objects to your constructors, or bring forward the missing method throw so you can find it sooner
<Erlkoenig>
great idea, "dont make bugs" :D
<totallymike>
works for me ;)
<Erlkoenig>
if i never made mistakes i wouldn't need it :D
<yorickpeterse>
def require_method(obj, m); raise NoMethodError, "Objects should implement the method #{m}" unless obj.respond_to?(m); end
<yorickpeterse>
something like that
<darix>
Erlkoenig: the problem is any solution to your problem would break the duck typing pattern
<totallymike>
No but seriously, what causes the wrong objects to enter your constructor?
<darix>
and many ruby users prefer that pattern
<steveklabnik>
it's also a problem that just doesn't happen
<Erlkoenig>
totallymike: well writing wrong code :D
<steveklabnik>
in real life.
<Erlkoenig>
for me it happened sometimes now :D
<Erlkoenig>
... have to go again ... will return later... sorry ;)
<totallymike>
Erlkoenig: that's all well and good, but if you solve the problems of passing the wrong objects, you'll solve this problem in a much more sane way.
<Erlkoenig>
yes, but i have to FIND this problem first :D
<darix>
Erlkoenig: how about installing a method missing handler?
t59202 has quit [Remote host closed the connection]
t36602 has joined #ruby-lang
<darix>
that will give some extra infos on the object you tried to call the method on?
<totallymike>
indeed. put something at the top of whatever constructor it is that logs what you get and then step over the calls to it
<darix>
if you are just after better debug
ccbn has joined #ruby-lang
butchanton has joined #ruby-lang
cirwin has joined #ruby-lang
zmack_ has quit [Remote host closed the connection]
RickHull has joined #ruby-lang
RickHull has quit [Changing host]
RickHull has joined #ruby-lang
cdt has quit [Quit: Ex-Chat]
tbuehlmann has quit [Remote host closed the connection]
runeb has quit [Remote host closed the connection]
m3nd3s has joined #ruby-lang
<yats>
is there a short cut to write return flag if flag
<totallymike>
return flag unless flag.nil?
<totallymike>
?
<totallymike>
er that's longer
akira989 has quit [Remote host closed the connection]
<steveklabnik>
yats: or just write return flag if flag
judofyr has quit [Remote host closed the connection]
JoshLambert has joined #ruby-lang
judofyr has joined #ruby-lang
judofyr has quit [Remote host closed the connection]
gnufied has joined #ruby-lang
Criztian has quit [Ping timeout: 252 seconds]
JoshLambert has left #ruby-lang [#ruby-lang]
kain has quit [Quit: exit]
Leeky is now known as Leeky_afk
neocoin has quit [Remote host closed the connection]
isale-eko has quit [Quit: ChatZilla 0.9.88.2 [Firefox 12.0/20120420145725]]
kain has joined #ruby-lang
machuga is now known as machuga|away
cout_ is now known as cout
akira989 has joined #ruby-lang
bytephilia has quit [Quit: Computer has gone to sleep.]
macmartine has quit [Quit: Computer has gone to sleep.]
bryancp has quit [Remote host closed the connection]
arooni-mobile has joined #ruby-lang
t36602 has quit [Remote host closed the connection]
Criztian has joined #ruby-lang
t34155 has joined #ruby-lang
arooni-mobile has quit [Client Quit]
jtoy has joined #ruby-lang
carloslopes has joined #ruby-lang
<apeiros_>
if it's the last statement, then: flag
* apeiros_
wins an internet?
hramrach has quit [Ping timeout: 276 seconds]
ccbn has quit [Quit: Page closed]
poga has quit [Remote host closed the connection]
gnufied has quit [Quit: Leaving.]
limes has quit [Ping timeout: 245 seconds]
hramrach has joined #ruby-lang
<Erlkoenig>
(18:47:32) darix: Erlkoenig: it could be as simple as http://pastie.org/private/y1aknftepz727symszvcg <-- the problem is, that this message is too late, and at that point i don't know why i got the wrong object...
<jaimef>
how can you use a variable in a range say foo.split[-(entries)..-1]
<lianj>
(-entries)
<Erlkoenig>
mh, wait a second, i'll write a paste for illustration
<steveklabnik>
you dont even need the ()s
<lianj>
right
desmondmonster has joined #ruby-lang
nirix has quit [Quit: Computer has gone to s…zZzZz]
Jay_Levitt has joined #ruby-lang
voker57 has quit [Remote host closed the connection]
<Erlkoenig>
lianj: http://pastie.org/4575531 look here... some sort of type annotation in the A#initialize method would directly lead to the incorrect line
cirwin has joined #ruby-lang
<drbrain>
Erlkoenig: what if I added a method "blubb" to y in "much code"
<drbrain>
?
<Erlkoenig>
drbrain: that would obfuscate the error even more...
ilyam has joined #ruby-lang
<apeiros_>
Erlkoenig: his point is that it wouldn't error in that case. but your annotation wouldn't allow it.
sepp2k has quit [Remote host closed the connection]
<drbrain>
Erlkoenig: ^^
<Erlkoenig>
it would be an error if a "B" was actually intended, and it's a "C"
<Erlkoenig>
because B and C might have even more methods :D
<drbrain>
Erlkoenig: that doesn't follow
<totallymike>
ErlKoenig just use .respond_to?
gsav has quit [Read error: Connection reset by peer]
<drbrain>
if I add a method "blubb" to y that is equivalent in meaning to B#blubb there is no error
<Erlkoenig>
totallymike: if there were an easy and short way to do that, without lots of if-blocks
gsav has joined #ruby-lang
<lianj>
"ruby, please execute the method on the nearest matching obj in objspace. pretty please"
<totallymike>
That's it.
<totallymike>
If your object has a foobar, then it won't give you errors.
akira989_ has joined #ruby-lang
<drbrain>
Erlkoenig: you are confusing "type" for "class"
machuga|away is now known as machuga
<totallymike>
Put that unless line in your constructor
<totallymike>
the very moment something passes the wrong object, your program falls over.
<Erlkoenig>
hmm, ruby is too dynamic :>
<drbrain>
Erlkoenig: yes! :D
desmondmonster has quit [Quit: desmondmonster]
<Erlkoenig>
problem is, that i of course don't have only one "blubb type" method, but plenty, and checking for all of them on all argument in the constructor would be... painful and error-prone, that's why i wanted to check for the correct class
<totallymike>
What on earth is your project doing?
desmondmonster has joined #ruby-lang
<apeiros_>
totallymike: wrong syntax :-p
<totallymike>
thanks
<apeiros_>
raise unless foo
<totallymike>
indeed
<apeiros_>
also: use a symbol instead of a string, use ArgumentError explicitly
<totallymike>
even better. came off the top of my head without much thought
desmondmonster has quit [Client Quit]
<totallymike>
Erlkoenig: you may want to consider refactoring such that whatever's happening in your code is a little more predictable.
brianpWins has quit [Quit: brianpWins]
<totallymike>
The time spent rearranging your code will save you tenfold down the road.
<totallymike>
You of course CAN do class checking, but if you do your code will lose most if its reusability.
jbsan has joined #ruby-lang
dRbiG has joined #ruby-lang
jtoy has quit [Ping timeout: 272 seconds]
headius has quit [Quit: headius]
jtoy has joined #ruby-lang
<Erlkoenig>
(19:39:20) totallymike: http://pastie.org/4575576 <-- well i'd have to do this for every method... evil
judofyr has joined #ruby-lang
judofyr has quit [Remote host closed the connection]
t34155 has quit [Remote host closed the connection]
<totallymike>
So do this instead:
<Erlkoenig>
and what would you rearrange oO
<totallymike>
add one or two of them that you know to be problematic
t17958 has joined #ruby-lang
<totallymike>
go back and find the code that passes the objects that throw the errors and fix that
CoverSlide has joined #ruby-lang
<totallymike>
It sounds like you have a really big class that does a bunch of really huge crap with a lot of interdependent code.
<totallymike>
By crap I don't mean awful code horrors, I just mean stuff. I'm not trying to be confrontational, just ascertain the nature of your goal.
<totallymike>
And it seems that the sample pastes you're providing don't really tell the whole story.
titaniumNoob has joined #ruby-lang
<Erlkoenig>
i don't think i have such "blob" classes, but actually 47 smaller classes that build some structure
<Erlkoenig>
and it happens that one accidentally passes a wrong object or something
<Erlkoenig>
static typed languages would immediately find that error
<steveklabnik>
it may not always be an error
<steveklabnik>
that's the thing
<totallymike>
But then you've got the problem where you're statically checking against 47 different types.
<steveklabnik>
really, the closest thing to duck typing you can get statically is structural typing
<steveklabnik>
this is often really useful in tests, for example
<steveklabnik>
i inject a mock, stub, or some other test double. it wont have the same class. it will act correctly
<totallymike>
so you say you have 47 different classes that "build some structure" but then you've got one constructor that accepts any one of them
<totallymike>
and somewhere, somehow, one of them takes a dump sometimes?
<Erlkoenig>
no, that constructor wants one particular class, but in ruby you can of course pass anything
<totallymike>
That's what I'm saying.
<totallymike>
You say something about having 47 different classes
<totallymike>
And cite the terror of having to check against unique methods from each of them
<Erlkoenig>
different classes for different purposes...
<totallymike>
fine
ilyam has quit [Quit: ilyam]
<Erlkoenig>
and i think i'm going to add more...
<totallymike>
Okay.
<totallymike>
No worries.
<totallymike>
Well . . .
<totallymike>
but that's not the issue
<totallymike>
any one of these 47 classes can get passed to this one constructor?
<totallymike>
What does this one constructor build?
<Erlkoenig>
wah no :D
<Erlkoenig>
erm...
<totallymike>
And what do all these different classes accomplish?
<Erlkoenig>
i have a class "buildtask" which needs a "settings" class that provides some options for the "buildtask", so you have to pass an instance of "settings" to the "buildtask" class
<Erlkoenig>
but you accidentally might pass something else at some point...
<totallymike>
Why does settings need to be a class? Can't a hash do/
<totallymike>
?
<totallymike>
er a custom class
<totallymike>
Why does settings need to be a custom class? Won't a hash do?
<Erlkoenig>
a hash might work too, but that doesn't stop you from passing, e.g. accidentally an Array, and getting an error much later
<steveklabnik>
OStructs work really nice for settings
<steveklabnik>
Erlkoenig: i think you just really want a statically typed language
<steveklabnik>
that's okay!
<steveklabnik>
but your brain doesn't work in a dynamic way
<totallymike>
Certainly it doesn't prevent you from passing an array.
<steveklabnik>
we consider 'it doesnt prevent you' to be a feature, not a bug
<totallymike>
But the benefit here is that you can now just chunk together a hash explicitly and pass that.
<Erlkoenig>
also the hash doesnt check for correct names... if i write { :inlcudes => "foo.h" } instead of { :includes => "foo.h" } i get the error much later...
<totallymike>
How much later?
<Erlkoenig>
maybe much later in the program, when you don't get any hint where the typo was
<totallymike>
sure you do
<Erlkoenig>
well ok in this case you can just Strg+F "inlcudes" :D
<totallymike>
well, I suppose not because you just get a "Huh? We can't find an :includes key"
<totallymike>
But honestly, how many different places are you building these settings hashes, anyway?
<totallymike>
er don't answer that
<totallymike>
how variant must your settings objects be?
<totallymike>
would they all have different fields?
<Erlkoenig>
(19:58:40) steveklabnik: Erlkoenig: i think you just really want a statically typed language <-- maybe... but which one :D ... ideally it wouldn't require compiling, and easy/beginnerfriendly to achieve some 08/15 tasks, provided that my library offers easy-to-use functions for that
krz has joined #ruby-lang
<steveklabnik>
it can't 'wouldnt require compiling'
<steveklabnik>
that's what static languages do
<steveklabnik>
i dont think that static langauges are beginner friendly
towski has joined #ruby-lang
<steveklabnik>
specifically because of static typing
<steveklabnik>
:)
anannie has joined #ruby-lang
<Erlkoenig>
well LISP has optional static type checking, and is still dynamic and interpreed
<Mon_Ouie>
MLs (e.g. Haskell and OCaml) have a smart typing system
<steveklabnik>
for statically typed langauges, i can't get by without hindley-minler
<steveklabnik>
millner
<Mon_Ouie>
And require compiling only as much as Ruby does
<steveklabnik>
Mon_Ouie: OH NO YOU DIDNT! Haskell isn't an ML. (is it?)
t17958 has quit [Remote host closed the connection]
jbsan has quit [Quit: jbsan]
<Erlkoenig>
and it would be nice if the user of my library would not have to bother with static types...
<Mon_Ouie>
Easy is a matter of opinion — it certainly is different from Ruby
t82688 has joined #ruby-lang
<totallymike>
I suggest you perhaps use a hash for your settings objects. You'll have the benefit that you have to explicitly build the hash, and thus it would be much harder to accidentally pass something else.
<Mon_Ouie>
I thought it was, at least it's remotely related to it
<steveklabnik>
anyway, ive gotta be writing, so that's the last i'll say about this :)
<Erlkoenig>
totallymike: can i add my own methods to my hash?
<totallymike>
sure . . . but why?
<Erlkoenig>
my Settings class has a method that converts the ruby class structure into a string
<Erlkoenig>
for passing it to other programs
<totallymike>
What manner of string?
towski has quit [Remote host closed the connection]
jbsan has joined #ruby-lang
diegoviola has joined #ruby-lang
<Erlkoenig>
like def toCmdLine @includes.map { |i| "-I" + i }.join(" ") end
<Erlkoenig>
well i don't see how a Hash fixes my problem - one can equally accidentally pass a String instead of a Hash and get an error later, when the variable is accessed
<totallymike>
of course!
yats has quit [Quit: Leaving]
<totallymike>
but that's a pretty difficult mistake to make
<Erlkoenig>
unfortunately, i don't have only one settings class, but 9, that are inherited and packed into each other
<Erlkoenig>
(and yes, putting all settings into one class would cause a mess)
<totallymike>
What's so different about each that makes them different, how are they inherited and packed into each other?
scampbell has quit [Quit: Ex-Chat]
vesan has quit [Ping timeout: 260 seconds]
<Erlkoenig>
thats a bit complicated :D ... settings classes "B" and "C" are derived from settings class "A", for different cases, also A has a settings class D, etc. ...
<totallymike>
Can you draw us a map?
A124 has quit [Quit: Leaving.]
<Erlkoenig>
if you insist :D
chimkan___ has quit [Quit: chimkan___]
<totallymike>
Rather, write a sample that illustrates that behavior
<Erlkoenig>
its in effect only 133 lines, the classes are rather tiny
<MrPunkin>
Can anyone tell me an easy way to profile the amount of objects loaded in a method call?
vesan has joined #ruby-lang
<totallymike>
Okay. First of all, there's no need for the Flag class.
<Erlkoenig>
but this way i can do .is_a?(Flag)
<apeiros_>
Erlkoenig: `@cc = if c == nil then CompilerSettings.new else c end` --> `@cc = c || CompilerSettings.new`
<apeiros_>
(just code style, nothing serious)
<Erlkoenig>
ah nice... i don't know all evil ruby tricks yet :D
<apeiros_>
other stylistic things: snake_case for methods, not camelCase
<apeiros_>
2 spaces for indent, not tabs
hahuang65 has joined #ruby-lang
<Erlkoenig>
okay, for the next project :D
<apeiros_>
in your PkgConfigLDflags class, the initialize - instead of that if/else, use def initialize(*pkgnames); @pkgnames = pkgnames
Criztian_ has joined #ruby-lang
<apeiros_>
let the user normalize the data. normalizing yourself needlessly increases code complexity.
<Erlkoenig>
aaah genius...
sailias has quit [Quit: Leaving.]
Marc3000 has joined #ruby-lang
<Erlkoenig>
well it's for convenience...
<totallymike>
It just shifts the convenience
<Erlkoenig>
to avoid writing 1-element-arrays in the usercode
<RickHull>
i like to think of a distinction between library code, and code which calls into the library
flak has joined #ruby-lang
Criztian has quit [Ping timeout: 244 seconds]
<RickHull>
and generally you put the repsonibility on the calling code, to use the lib correctly
<apeiros_>
Erlkoenig: with initialize(*args) you don't have to write 1 element arrays
flak is now known as Guest28365
<totallymike>
RickHull: my argument exactly
<Erlkoenig>
jep, i didn't think of that
<apeiros_>
but you have to pass an array with *, e.g. PkgConfigLDflags.new(*flags)
<apeiros_>
Erlkoenig: important: don't implement clone yourself. you just did it wrong. implement initialize_copy instead (see Object#initialize_copy)
<apeiros_>
(what's wrong with current - you have clone but omitted dup, e.g.)
<Erlkoenig>
i read somewhere that you should write "clone" yourself...
t82688 has quit [Remote host closed the connection]
<RickHull>
dup is a built-in shallow copy
<totallymike>
Doesn't the splat make whatever arguments you pass to the function into an array?
<RickHull>
back in the day, people wrote their own deep copy methods
t72746 has joined #ruby-lang
<apeiros_>
RickHull: so is clone
rippa has quit [Ping timeout: 248 seconds]
chimkan has joined #ruby-lang
<RickHull>
i'm not sure what best practice is today
<apeiros_>
RickHull: as said: initialize_copy
<Erlkoenig>
yeah i want a deep copy...
<apeiros_>
not just today
<RickHull>
apeiros_: yeah, just trying to provide more context, not arguing :)
<apeiros_>
has been ever since 1.8.0, maybe even before (but wasn't there then)
<apeiros_>
*but *I* wasn't there…
<apeiros_>
RickHull: ok :)
<arooni-mobile>
if i have a instance variables for a given class... should they all be declared within the class's constructor method, or can i declare them within the instance methods when i need them
<Erlkoenig>
i knew it wouldn't be a good idea of posting my code :>
<RickHull>
Erlkoenig: it's a fine idea
<totallymike>
Erlkoenig: it's great that you did. Learn!
<arooni-mobile>
i.classes's initialize method (constructor) rather
<RickHull>
just a little unpleasant
<RickHull>
no one said it would be fun to be told you're doing it wrong
<RickHull>
;)
<Mon_Ouie>
Instance variables can be created whenever you want (just setting a value will create them; if you read from them you get nil and a potential warning)
<Mon_Ouie>
I'd still recommend to at least set them all to a default value, even if it is nil, within initialize
<Mon_Ouie>
Even if it's just for clarity
<totallymike>
Erlkoenig: the beautiful thing about pasting your code is you get to learn how to do things idiomatically, thus reducing the size of your code and making it more readable
wallerdev has joined #ruby-lang
towski has joined #ruby-lang
towski has quit [Remote host closed the connection]
<Erlkoenig>
s/beautiful/painful :>
<totallymike>
But helpful.
towski has joined #ruby-lang
<totallymike>
I see here a bunch of redundant code. Your initialize methods are very similar for a couple classes
Guest28365 has left #ruby-lang [#ruby-lang]
towski has quit [Remote host closed the connection]
rippa has joined #ruby-lang
<totallymike>
In fact, there don't seem to be any differences at all between PkgConfigCflags and PkgConfigLDflags?
<apeiros_>
Erlkoenig: fastest way to learn
<apeiros_>
and it's only painful if you can't accept that there's always room for improvement :-p
<totallymike>
oh libs/cflags in the cmd
<Erlkoenig>
totallymike: no, the one uses --libs, the other --cflags :D
havenn_ has quit [Remote host closed the connection]
<totallymike>
You can make those classes the same if you take out "cmd = " line and put it somewhere else, then just append to it in the get method
benanne has joined #ruby-lang
<totallymike>
I mean you make a single PkgConfigFlags class that has basically the same thing, then just make Class LDFlags; @@cmd = 'pkg-config --libs'; end
jbsan has quit [Quit: JB.. OUT!]
<totallymike>
er Class LDFlags < PkgConfigFlags . . .
<Erlkoenig>
hmm, i think i'll remove these 2 classes alltogether, because they were only some sort of hack, i'll do this stuff with some other mechanism
<totallymike>
Or even use a symbol :"pkg-config --libs"
<Erlkoenig>
but thanks for the idea ;)
<totallymike>
but then you have to make it a string just to use it anyway
jbsan has joined #ruby-lang
<Erlkoenig>
hm, how to make a deep copy of an array?
<totallymike>
How deep, containing what?
<Erlkoenig>
well, a new array, that contains .clone's of the contained objects... i will then overwrite the initialize_copy method of the contained objects to make deep copies of them
ilyam has joined #ruby-lang
butchanton has quit [Quit: Leaving.]
burgestrand has joined #ruby-lang
<drbrain>
Erlkoenig: easiest way is Marshal.load Marshal.dump array
<Erlkoenig>
but that's an evil hack :S
<rue>
Yes
rindolf has joined #ruby-lang
reactormonk has quit [Ping timeout: 240 seconds]
<Erlkoenig>
once there was a saying that IRC would solve your programming problems... :D
reactormonk has joined #ruby-lang
<apeiros_>
the need for a deep copy usually can be translated to "you don't have enough classes"
<Erlkoenig>
... but might be an easier way :D
<apeiros_>
s/be/seem like/
qpingu has joined #ruby-lang
akira989_ has quit [Remote host closed the connection]
machuga is now known as machuga|away
Axsuul has joined #ruby-lang
<Defusal>
anyone know of a good way to monitor each cpu core in realtime and detect when a core is maxed out? checking a cores percentage at intervals stands a chance of missing a spike...
havenn has joined #ruby-lang
<Defusal>
i need a reliable way to monitor this so that i can figure out exactly how to manually balance realtime single threaded processes between cores without ever having a performance issue
<Erlkoenig>
how do you manually balance the processes to the cores? doesn't the OS scheduler do exactly this?
<rue>
…Yeah, you should probably let the OS worry about that
bfreeman has quit [Quit: bfreeman]
<rue>
I guess the affinity might be an option in some cases
jbsan has quit [Quit: jbsan]
ilyam has quit [Quit: ilyam]
JustinCampbell has joined #ruby-lang
wpaulson has joined #ruby-lang
t72746 has quit [Remote host closed the connection]
wpaulson has quit [Read error: Connection reset by peer]
wpaulson_ is now known as wpaulson
RickHull has left #ruby-lang [#ruby-lang]
<TTilus>
it you'd ever have a "performance issue", that's _not_ the way to go about solving it for sure...
<TTilus>
rue: and im not talking about your suggestion ;)
Guest78690 has quit [Quit: WeeChat 0.3.8]
Musfuut has joined #ruby-lang
<TTilus>
1) benchmark 2) optimize 3) repeat until issue goes away (or client runs out of money)
havenn has quit [Remote host closed the connection]
<Erlkoenig>
sounds so easy like everyone could do it <3
ruurd has joined #ruby-lang
Criztian_ has quit []
<erikh>
step 1) throw more hardware at it - step 2) identify the problem in the software, not the OS
<erikh>
Defusal: ^
<erikh>
take it from someone who's been doing ops for the last two years. :)
<Defusal>
erikh, i have the best quad core xeon, 16GB ram, 2 x 1TB raided hdds
<Defusal>
but i need to work out the limit of each hyperthreaded core
<erikh>
ok, this is a disconnect here
<erikh>
first off, you shouldn't be optimizing for a single machine, ever, for anything that's intended to be alive constantly
<erikh>
if anything, optimize for n smaller machines
<Defusal>
Erlkoenig: i set the affinity to whichever core the process needs to run on, with nice -20
<erikh>
the only real exception to this rule is a desktop application, I suppose, and judging by your chatter in the past I doubt that's the case.
jbsan has joined #ruby-lang
<erikh>
nice -20 is a great way to kill your system dead
<Defusal>
erikh, the server is contracted, and smaller machines would not be financially feasible
<Defusal>
erikh, each single threaded realtime process gets assigned to a single core
<Defusal>
well hyperthreaded core
MrPunkin has left #ruby-lang [#ruby-lang]
<Defusal>
the first 2 (1 real core) are left for the system and all other processes
qwerxy has quit [Ping timeout: 264 seconds]
<erikh>
the OS will manage affinity for you
<Defusal>
bleh, nevermind
<Defusal>
i have had this discussion a few times already, and i know this is the best way to handle the setup
havenn has joined #ruby-lang
<soahccc>
A little bit off topic I'm afraid… Does anybody know tkellem and successfully use it? It does not connect to some IRC servers (Connecting, hold on) so I'm looking for some experiences :)
<Defusal>
that was however not my question
bryancp has joined #ruby-lang
<Defusal>
the processes are single threaded, realtime, latency sensitive services
<Erlkoenig>
minecraft server? :>
<heftig>
Defusal: are the services SCHED_FIFO or SCHED_RR?
havenn has quit [Remote host closed the connection]
<Defusal>
i now know the solution to figuring out how best to load balance them though, i'm going to have to build something that will monitor the processes at max load and record the min/max/average core usage for each core and each process, and work out how to assign the cores from there
<Defusal>
heftig, no, that is not necessary, ensuring nothing else ever uses the timeslice each process requires is sufficient
<darix>
Defusal: so how to bind one process to one core and be done?
toretore has quit [Quit: This computer has gone to sleep]
<Erlkoenig>
what OS are you using? on linux, perhaps, you can tweak the scheduler settings... also configure a "server oriented" scheduler in the kernel
<erikh>
linux has realtime options
<Defusal>
darix, that would be a waste of resources and i would be bankrupt
<darix>
erikh: gaming servers dont need realtime
<erikh>
darix: I know that
t22681 has quit [Remote host closed the connection]
<Defusal>
erikh, i cannot change the kernel, even if i wanted to, but that really shouldnt be necessary
<erikh>
but I'm done talking about this :)
t10876 has joined #ruby-lang
<darix>
Defusal: tbh ... whats the ram usage per game server?
<erikh>
I administered counterstrike servers for a number of years professionally
<Defusal>
1 - 4% of 16GB
<Defusal>
erikh, and you just piled a whole lot onto a machine and let them run wild?
<erikh>
nope, I built n servers for n cores
<Defusal>
they are single threaded, so they cannot take a bit more cpu from another core if needed
<erikh>
and priced ram accordingly
<erikh>
let the kernel do the rest
<Defusal>
yeah, thats what most people do
<Defusal>
which is not very efficient
<Defusal>
hence the manual core management
<darix>
also wait until people "optimize" their server and up the tickrate a lot ;)
<erikh>
actually I'm willing to bet a year's salary it's more efficient than anything you will come up with
<darix>
erikh: +1
<erikh>
and at this point I need to leave.
<darix>
cya erikh
<Defusal>
darix, i base the core load balancing on the tickrate and max players
<heftig>
just let the OS scheduler handle cpu assignment
chessguy has joined #ruby-lang
<Defusal>
bleh, as i said, nevermind
<Defusal>
theres no point in me discussing this again
<darix>
Defusal: just a question ... how many servers do you think about putting up per core max?
<Defusal>
darix, i can only know that once i have written a benchmark monitoring application and tested the peak core usage of a server with different tickrates and player limits
<Defusal>
that is the main issue
<Defusal>
i will put as many on a core as possible without letting the core ever reach 100%
<heftig>
that's by definition inefficient
<Defusal>
obviously more servers will run on a core with low client limits
<Defusal>
heftig, how so?
<heftig>
because you're letting resources go unused
mblack has quit [Remote host closed the connection]
<darix>
Defusal: and you want to move servers from core to core during runtime?
<Defusal>
heftig, then you missed my entire point
sora_h is now known as s0ra_h
<Defusal>
heftig, it is imperative that a core running these realtime services never gets maxed out or there will be a performance issue that clients will notice
<Defusal>
darix, preferably not
<darix>
game servers are hardly real time
<darix>
anyway
<heftig>
is this a NUMA server?
<darix>
back to some other work
<Defusal>
FPS servers running at 128 tick are pretty damn realtime
<Defusal>
or pretty close at least
LanceHaig has quit [Read error: Operation timed out]
<Defusal>
especially for the people that live 5ms away
<darix>
what is the default tick rate?
<Defusal>
64, but all my personal servers are running at 128
<Defusal>
i can't assume 128 will use exactly double of a 64 tick server, but it must be close
<Defusal>
heftig, as i said before, they are CS:GO servers
<Defusal>
mostly
<heftig>
sigh, i meant the hardware
<erikh>
what's the kernel HZ
<erikh>
if it's less than the tick, you're fucked regardless.
<erikh>
also hyperthreading shares cores, so that will interfere with the scheduler
<erikh>
also valve's servers always have run better on windows
<erikh>
without fail.
<Defusal>
erikh, how do i find that out? i assume that is different from the clock speed
<Defusal>
linux is better for servers, even if valves terrible software works better on windows, i will *never* run a windows server.
<heftig>
default scheduling latency on linux is 6ms, default granularity 750ns
<erikh>
and there's zero, nada, zilch about srcds or any of its derivatives that require or even use realtime features
<erikh>
it's all wallclock based IIRC
<Defusal>
and yes, obviously hyperthreading just about halves each core erikh, but i guess theres really no way to decide on how to optimize the core scheduling other than to bench the servers running at full load
<erikh>
just go into bios
<erikh>
turn hyperthreading off.
<Defusal>
i cannot do that even if i wanted to
<erikh>
well then you have a real problem
<Defusal>
why?
<erikh>
think about it.
<Defusal>
i did my research, hyperthreading does not affect srcds too badly
<heftig>
the linux scheduler will, as long as powersaving is disabled, schedule on separate cores before hyperthreads
<Defusal>
heftig, what do you mean by that?
<erikh>
if you have 8 servers running on 8 "cores" that are utilizing 100% CPU but in reality your system is balancing that across 4 cores, you are going to get roughly 50% CPU usage
havenn has joined #ruby-lang
<erikh>
presuming the processes are entirely CPU-bound
<Defusal>
erikh, i'm pretty sure that is not the case
<heftig>
Defusal: the linux scheduler is hyperthreading-aware
<Defusal>
heftig, sure, but how does that help me?
<heftig>
erikh is correct
<heftig>
i'm just saying that the linux scheduler is really smart about cpu assignment, and will most probably make better choices than whatever you can cook up
<erikh>
and I can't be more serious about this -- if you want real performance on srcds, you go to windows
<erikh>
you put up with it and grumble. it's a fact of that industry
t10876 has quit [Remote host closed the connection]
t46457 has joined #ruby-lang
<erikh>
linux has always been second banana as far as valve's concerned
<Defusal>
heftig, whats to stop the scheduler from moving processes between cores? i'm pretty sure that would have a performance hit
<darix>
erikh: well lately valve putting a lot of effort on linux
<darix>
even client side
<heftig>
Defusal: only a big hit on NUMA machines, and even then the scheduler will try not to move between nodes
<erikh>
darix: fair enough, I'm willing to concede that's changed
<erikh>
it's been a few years for me
<Defusal>
heftig, i don't even know what NUMA is :/
<Defusal>
the only way to prove it would be to assign all processes to 3-7 cores and let them run wild
<Defusal>
then see if i get 100 users complaining
<erikh>
dunno. managing web servers that use significantly less CPU I generally aim for cores * 1.5
<erikh>
but there's also a lot of infra that makes that easier, load balancers, queues, etc.
<Defusal>
this has a Intel(R) Xeon(R) CPU E31270 @ 3.40GHz
<erikh>
I would avoid measuring hardware by spec and do a real load test
<Defusal>
erikh, yeah i have a large management platform to manage all of this which is why i set aside the first 2 hyperthreads for system processes
<Defusal>
and yeah, that is the only solution
<erikh>
I don't know if you need that, though. maybe just cores - 1 and let the scheduler run with it would be sufficient
<Defusal>
im going to have to build a monitoring system to be able to benchmark at full load tomorrow
LanceHaig has joined #ruby-lang
LanceHaig has quit [Changing host]
LanceHaig has joined #ruby-lang
<erikh>
I doubt I have to tell you that not all of those servers will be running full-bore 100% of the time anyhow
<Defusal>
erikh, well maybe later yeah, i'll need to optimize the prototyped software first
<erikh>
hold on
<Defusal>
at the moment there is a ton of IO going on
<erikh>
just stop right there. listen to what you're saying. optimizing without numbers is a waste of energy
<Defusal>
logs being streamed, udp logging being received and parsed, tons of files being watched with inotify
<Defusal>
there is a lot going on
<Defusal>
i never said i'd optimize now
bryancp has quit [Remote host closed the connection]
<Defusal>
i just said i'm leaving it with two hyperthreads for system processes until the management software is optimized
totallymike has quit [Quit: WeeChat 0.3.7]
<Defusal>
now i just need to benchmark and figure out the limits of the remaining cores
<Defusal>
heftig, i have a question for you
<heftig>
shoot
ruurd has quit [Quit: Leaving...]
bryancp has joined #ruby-lang
<Defusal>
heftig, if the kernel was scheduling these processes and had 3 near-idle servers on a core, say 2 become loaded and the third has only a little load, what happens when the total load between them becomes more than that single core can handle?
<Defusal>
does it move one to another core without any performance hit?
<Defusal>
because anytime a process doesn't have the required timeslice, the performance hit is visually noticeable
<heftig>
the scheduler will spread running processes over all cores anyway
<Defusal>
heftig, it can't do that since they're single threaded?
<Defusal>
can it? :S
ilyam has joined #ruby-lang
<heftig>
those kinds of migrations happen all the time on a busy system
<Defusal>
theres a reason most hosts give each process its own core
<Defusal>
heftig, sure, but busy systems don't usually run this software
<heftig>
if your software is so time-critical and not written to use realtime scheduling (SCHED_FIFO) i'd say it's broken
vesan has quit [Read error: Connection reset by peer]
<Defusal>
heftig, as i said, it is not quite that sensitive, but it is definitely sensitive
publicvoid_ has joined #ruby-lang
<heftig>
Defusal: i'd recommend fiddling with the scheduler settings instead
t46457 has quit [Remote host closed the connection]
havenn has quit [Remote host closed the connection]
publicvoid__ has quit [Ping timeout: 260 seconds]
qwerxy has joined #ruby-lang
apeiros_ has quit [Remote host closed the connection]
<Defusal>
heftig, i'm not sure adjusting the scheduler would be much different from setting these processes niceness to -20
<heftig>
niceness is just relative to other processes
vesan has joined #ruby-lang
<heftig>
i.e. a low-nice task will get more cpu than a high-nice task
<heftig>
reducing sched_latency_ns will decrease timeslice size, decreasing scheduling latency (time between processes becoming ready to run and getting their timeslice) but also increasing scheduling overhead, decreasing total throughput of the system
<Defusal>
bleh, if only there was a way to benchmark different configurations without negatively affecting users
<apeiros_>
staging servers…
<Defusal>
there is no way to accurately benchmark without actual users as load
titaniumNoob has quit [Quit: Leaving]
<apeiros_>
actual users can't be accurately benchmarked
<apeiros_>
since that load is irregular, irreproducable
<apeiros_>
you use tools to simulate load
amerine_ has left #ruby-lang [#ruby-lang]
<Defusal>
in many cases that is true, but in this case, there is no way to simulate the load without real users (who bought a retail product)
<apeiros_>
nonsense
amerine has joined #ruby-lang
<apeiros_>
any load that real users create can be simulated
<amerine>
test
<apeiros_>
amerine: test failed. please reboot.
<Defusal>
apeiros_, it is a closed source protocol
<Defusal>
there is really no other way to accurately test the load, just trust me on that
<apeiros_>
so?
<apeiros_>
I don't trust you on that.
<apeiros_>
even if it's an application, closed and all
<Defusal>
heftig, so you'd start with using SCHED_RR or SCHED_FIFO for the processes i guess
<apeiros_>
in most OSes you can still automate them
<apeiros_>
e.g. via control hooks for the disabled
<heftig>
Defusal: that's not so simple, the processes must be able to cope with it
<apeiros_>
anyway, you decided that you can't, so you can't. fine be me. it's not my problem after all.
<Defusal>
apeiros_, the processes are gaming servers, reverse engineering the protocol to simulate game clients which perform specific actions to put max load on the server is just not an option
<Defusal>
heftig, oh dear :/
<Defusal>
sounds like the processes won't have an issue with those scheduling modes heftig
<Defusal>
so thats at least good news
dan|el has quit [Ping timeout: 246 seconds]
Dreamer3 has joined #ruby-lang
fgomez has quit [Ping timeout: 245 seconds]
s0ber_ has joined #ruby-lang
t30944 has quit [Remote host closed the connection]
chessguy has quit [Remote host closed the connection]
Dreamer3 has joined #ruby-lang
Dreamer3 has quit [Remote host closed the connection]
carloslopes has quit [Read error: Connection reset by peer]
chessguy has joined #ruby-lang
sora_h is now known as s0ra_h
s0ra_h is now known as sora_h
carloslopes has joined #ruby-lang
chessguy has quit [Remote host closed the connection]
justinmcp has joined #ruby-lang
ilyam has quit [Quit: ilyam]
bryancp has quit [Remote host closed the connection]
ilyam has joined #ruby-lang
machuga|away has quit [Quit: machuga|away]
anannie has quit [Remote host closed the connection]
Hakon has quit [Quit: Leaving...]
chessguy has joined #ruby-lang
sora_h is now known as s0ra_h
tjadc has joined #ruby-lang
<Defusal>
heftig, i managed to find a wiki page with some valuable info that is very relevant to me, lets hope everything works out well. thank you for your advice
tbuehlmann has joined #ruby-lang
Dreamer3 has joined #ruby-lang
goshakkk has quit [Quit: Computer has gone to sleep.]
bryancp has joined #ruby-lang
<Erlkoenig>
how to call/load/execute other ruby scripts from another ruby script and pass parameters to the new script, and also return a value to the calling script?
justinmcp has quit [Remote host closed the connection]
jeanosorio has joined #ruby-lang
justinmcp has joined #ruby-lang
saLOUt has joined #ruby-lang
erichmenge has joined #ruby-lang
JustinCampbell has quit [Remote host closed the connection]
<Defusal>
Erlkoenig, there are many ways to do so, you can google them. examples: system(), backticks (``), open3
rindolf has quit [Quit: Leaving]
<Erlkoenig>
yes, but these methods can only pass and return strings - i'd like to be able to pass a reference to a ruby object
<Erlkoenig>
by running the 2nd script within the same interpreter instance... just like calling a method
<apeiros_>
Erlkoenig: you don't do that
<apeiros_>
Erlkoenig: you have files which contain classes
<Defusal>
^
<apeiros_>
you create an instance of those classes, which is where you pass params
<apeiros_>
and you call whatever method gives you the result you need
<Erlkoenig>
well i'd need to create an instance of a class in that file. how do i know the name of the class? i can't define a fixed name, because i have to call multiple scripts that way, and they'd have to use differend class names
<apeiros_>
and the common class-to-file mapping goes as follows: the class Foo is in foo.rb, the class Foo::BarBaz is in foo/barbaz.rb
<apeiros_>
Erlkoenig: you write the class and forget its name?
<Erlkoenig>
the class name is not known during creation of the program
<Erlkoenig>
it's a bit like a plugin system
<Erlkoenig>
files are added/installed after installation of my program, and my program should find out which files are in place, and call them/create instances of classes defined in them
<apeiros_>
Erlkoenig: a) define a mapping, b) define a plugin registry API
<Erlkoenig>
somehow like gem does it with .gemspec files
<apeiros_>
or c) find an even different way
<apeiros_>
with a) I mean just like what I said above, expect Plugin::Foo in file plugin/foo
<Erlkoenig>
okay, can i create an instance of a class whose name is only known as a string?
<apeiros_>
it's not totally easy since ruby chose a regrettable convention for filenames
<apeiros_>
yes
<apeiros_>
Plugin.const_get('Foo')
<apeiros_>
that gives you the constant. on that you can call all methods as normal. probably .new in your case, so: Plugin.const_get('Foo').new
<apeiros_>
note that passing a symbol to const_get is preferable if possible (but if what you have is a string, don't bother to use to_sym yourself)
goshakkk has joined #ruby-lang
<Erlkoenig>
provided Foo is in module "Plugin"? how would i do it if "Foo" where in no Module?
carloslopes has quit [Quit: Leaving.]
<apeiros_>
Object is the toplevel namespace
<apeiros_>
but it'd be silly to not namespace user provided classes
<Erlkoenig>
like Object.const_get('Foo')? ... just wanted to know..
<apeiros_>
yes
<apeiros_>
try with e.g. 'Array'
justinseiter has quit [Ping timeout: 272 seconds]
kvirani has quit [Remote host closed the connection]
erichmenge has quit [Quit: Be back later]
<Erlkoenig>
apeiros_: and before that, i'd just "require('plugin/foo')" ?
cirwin has left #ruby-lang [#ruby-lang]
workmad3 has joined #ruby-lang
<apeiros_>
yes. plugin/foo.rb must be in your $LOAD_PATH for that
<apeiros_>
(in any of the directories listed in $LOAD_PATH)
<apeiros_>
you can push additional dirs to $LOAD_PATH yourself too.
<Erlkoenig>
okay... I think in my case i'll pass an absolute path
<apeiros_>
preferably absolute paths, you can use File.expand_path to get an absolute path.
<apeiros_>
you mean to require?
<apeiros_>
ok
<Erlkoenig>
yep ;)
<apeiros_>
since you probably glob them anyway…
<apeiros_>
you use 1.9, right?
t75588 has quit [Remote host closed the connection]
<Erlkoenig>
yes, 1.9.3
t31597 has joined #ruby-lang
dan|el has joined #ruby-lang
<apeiros_>
good
<Erlkoenig>
now i just need to convert a path like "plugins/my_awesome_special_plugin.rb" to Plugins::MyAwesomeSpecialPlugin :D
<mistym>
I did not foresee the blindingly obvious issues with naming a class MyModule::File.
jeanosorio has quit [Remote host closed the connection]
ryanf has joined #ruby-lang
<Erlkoenig>
i guess the plugin file is rated "trusted", i.e. no malicious code...
dan|el has quit [Ping timeout: 260 seconds]
totallymike has joined #ruby-lang
dfr|mac has quit [Remote host closed the connection]
m3nd3s has quit [Remote host closed the connection]
justinmcp has quit [Remote host closed the connection]
arooni-mobile has quit [Ping timeout: 240 seconds]
reactormonk has quit [Ping timeout: 260 seconds]
slyphon has quit [Quit: WeeChat 0.3.7]
Dreamer3 has quit [Quit: Leaving...]
Dreamer3 has joined #ruby-lang
s0ra_h is now known as sora_h
reactormonk has joined #ruby-lang
arooni-mobile has joined #ruby-lang
mistym has quit [Remote host closed the connection]
bryancp has quit [Remote host closed the connection]
saLOUt has quit [Quit: Konversation terminated!]
solars has quit [Ping timeout: 264 seconds]
outoftime has quit [Quit: Leaving]
t31597 has quit [Remote host closed the connection]
t14598 has joined #ruby-lang
arooni-mobile has quit [Ping timeout: 276 seconds]
gurps has quit [Quit: bye]
gurps has joined #ruby-lang
wpaulson has joined #ruby-lang
ilyam has quit [Remote host closed the connection]
sora_h is now known as s0ra_h
ilyam has joined #ruby-lang
jbsan has quit [Quit: jbsan]
qwerxy has joined #ruby-lang
jbsan has joined #ruby-lang
justinseiter has joined #ruby-lang
justin__ has joined #ruby-lang
kingCrawlerx has joined #ruby-lang
t14598 has quit [Remote host closed the connection]
t97547 has joined #ruby-lang
tjadc has quit [Ping timeout: 260 seconds]
justin__ has quit [Remote host closed the connection]