IRC log for #storm on 20100412

00:08.03*** join/#storm artista_frustrad (~artista_f@201-25-167-171.ctame704.dsl.brasiltelecom.net.br)
00:17.36*** join/#storm danilos (~danilo@canonical/launchpad/danilos)
00:34.16*** join/#storm fcorrea (~fcorrea@201-75-152-196-nd.cpe.vivax.com.br)
01:08.42*** join/#storm shaunm (~shaunm@c-98-212-133-244.hsd1.il.comcast.net)
02:43.03*** join/#storm stub (~stub@ppp-58-8-14-142.revip2.asianet.co.th)
02:43.03*** join/#storm stub (~stub@canonical/launchpad/stub)
03:32.30*** join/#storm stub (~stub@ppp-58-8-14-142.revip2.asianet.co.th)
03:32.30*** join/#storm stub (~stub@canonical/launchpad/stub)
04:58.50*** join/#storm jukart (~jukart@d86-32-163-62.cust.tele2.at)
05:47.02*** join/#storm jukart (lovely@81.189.156.94)
07:13.26*** join/#storm elmom_ (~elmom@vallila-gw.hupnet.helsinki.fi)
08:21.04*** join/#storm zmijunkie (~chatzilla@i59F5ED4D.versanet.de)
08:44.12*** join/#storm jkakar (~jkakar@83.34.90.69)
09:07.43*** join/#storm keppla (~keppla@i577B1598.versanet.de)
10:50.30*** join/#storm stub (~stub@canonical/launchpad/stub)
11:01.21*** join/#storm stub1 (~stub@ppp-58-8-14-126.revip2.asianet.co.th)
11:01.24*** join/#storm stub (~stub@canonical/launchpad/stub)
12:21.16*** join/#storm niemeyer_ (~niemeyer@189.74.206.84)
13:27.08*** join/#storm fcorrea (~fcorrea@187.3.15.40)
13:42.49*** join/#storm stub (~stub@canonical/launchpad/stub)
16:18.54midgetspyIn my attempt to make storm/sqlite work in a multi-threaded environment I've built a single thread that contains the only storm.locals.Store() object in my app, and have built a queue system where I pass functions in to that thread and it gives me results. So instead of store.find(..) in a different thread I do my.safe_store("find", ...).
16:19.19jkakarmidgetspy: Sounds nice!
16:19.23midgetspyWhat I've encountered with this approach is the constant attempt by Storm to create store objects all over the place and use them implicitly
16:20.10jkakarmidgetspy: Yeah, you don't want to use the objects outside the thread you got them from.  Which I guess is a big problem for the approach you describe.
16:20.11midgetspyerr, not create them, just pass them and use them
16:21.07midgetspyI specifically worked around ResultSet.one(), and now I've discovered that [x for x in myResultSet] also attempts to use a store. So I'm wondering, is it worth trying to work around these problems or is this approach flawed to begin with? And if so, how should storm/sqlite multithreading be done properly (or is it even possible)?
16:22.18midgetspyjkakar: so it is literally not possible to use storm/sqlite in a multi-threaded app unless all storm objects are kept in a single thread and only the data is passed out/in?
16:24.37midgetspybob2 mentioned zstorm, but from what I can tell it is only going to manage store objects in a manner similar to how I'm already trying to do it so I'm not sure if that's really the solution either?
16:24.39*** join/#storm keppla1 (~keppla@i577B05E7.versanet.de)
16:24.49jkakarmidgetspy: Most likely yes... this is because of SQLite, it's single-connection, right?
16:28.14midgetspyyes but that's not really the problem
16:28.21*** join/#storm jukart (~jukart@d86-32-163-62.cust.tele2.at)
16:28.47midgetspythe problem is that you can't use an sqlite object in a thread other than the one it was created in
16:28.50jkakarmidgetspy: Well, sure, it's part of the problem.
16:29.19jkakarmidgetspy: But yeah, I see your point.
16:29.32midgetspywell the single access just means that the DB may be locked at any time so I may need to wait to get access. waiting isn't a big deal though
16:30.53midgetspybut a Store keeps an sqlite object inside it it seems which means it can't be used in any thread other than the one it was created in (which means my storm objects can't be, either)
16:31.32jkakarmidgetspy: Yeah, true.
16:32.06jkakarmidgetspy: I haven't used Storm to actually write an application with SQLite (the applications I work on are all PostgreSQL-based) so sorry for the fuzzy answers. :/
16:32.22midgetspynp
16:32.53midgetspyI think ideally it should create a new sqlite object for every new transaction which would then only limit any single transaction to a single thread... any idea how hard that'd be to implement? I imagine it's all generic at that point, eh...
16:36.02jkakarmidgetspy: That wouldn't be too much different than creating a store and throwing it away when you're done.
16:36.15jkakarmidgetspy: It would involve connection overhead for each transaction though.
16:37.29jkakarmidgetspy: You could probably do some refactoring in Storm itself to avoid that overhead, using a pool of connections, one per thread.  I think it'd mostly be tricky because you'd need to maintain the existing behaviour.
16:38.43midgetspyright, I can live with some overhead for now (at least when the other option is starting over from scratch without storm, hehe)
16:38.48jkakarHehe
16:39.01midgetspyI always worry about performance last anyway
16:41.11jkakarMake it right, then make it fast. :)
16:41.30jkakarSometimes that doesn't work, but much of the time it does.
16:45.06midgetspyso having never looked at the storm code, how difficult is it going to be to make storm throw away store objects after every transaction? is it something that's feasible for me to implement myself or would it be a major job?
16:47.14jkakarmidgetspy: Instead of changing Storm, what about just creating a new store for each transaction and then calling store.close on it when you're done...?
16:52.27midgetspyhm that might work, I will have to try that. If I do a myResultSet = store.find() then store.close() in one thread then pass myResultSet to another thread and do myResultSet.one() on it, will it just make a new store? or will that store still be alive? (or should I just try it and figure out for myself? ;-P)
16:52.54jkakarThings will blow up.  You need to make the store and use the objects and then close the store all in the same thread.
16:56.13midgetspyhm
17:09.24midgetspyyeah so I still have the same problem, closing the store can't solve it. For example, I have Foo with bar=Reference(_bar_id, Bar.id). If I get an instance of Foo from my single-thread store, there's no way I can use Foo.bar in another thread because it requires the store instance. If I close it it blows up, if I leave it alone it dies because I'm using a sqlite object in a different thread than it was created in.
17:17.34jkakarmidgetspy: Right, so in a given thread you need to: (1) get a store, (2) use it and do whatever computation you want to, (3) call store.close.
17:17.42jkakarmidgetspy: IOW, you can't share objects between threads.
17:22.17midgetspyjkakar: well computations in one thread would be one thing, but since accessing referenced data (Foo.bar.attr in the above example) on my storm-backed objects requires a store, I can't even access my data in more than one thread I guess
17:22.46midgetspyperhaps I could make a special accessor on the objects that passes itself to the store thread, does the access there, and returns the value
17:23.28midgetspyAfter working on this right before bed I dreamt about this problem last night... tonight it will be a nightmare ;-P
17:25.31jkakarHeh
17:25.47jkakarmidgetspy: Yes, you can't access data in more than one thread.
17:25.47jkakarI'm stepping away, good luck!
17:25.54midgetspyok, thanks
20:40.54*** part/#storm jkakar (~jkakar@83.34.90.69)
23:25.38*** join/#storm shaunm (~shaunm@c-98-212-133-244.hsd1.il.comcast.net)

Generated by irclog2html.pl Modified by Tim Riker to work with infobot.