[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Mapper! (Hehehehe.)

Mapper! (Hehehehe.)

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1  2  3  4 5  

Posted by Faux   United Kingdom  (77 posts)  [Biography] bio
Date Reply #45 on Thu 20 Jan 2005 09:51 PM (UTC)
Message
Quote:
I suspect the culprit is DBRow, more than the table manipulation...

/tmp=os.clock() t={} a={5,6,7,8,"and","back","!"} for i=1,100000 do table.insert(t,a) end print(table.getn(t)) print (os.clock()-tmp)

Takes around 1/4th of a second on my pc.

Now.. something faster. Anyone know how to use MDAC directly, and how to build Lua interfaces? No? Thought not.. :/

Quote:
Maybe you're not clearing references..

The only thing I know how to clean up is the provided function to close the database connection. And that isn't it, as far as I know? We're reaching the ends of my knowledge of Lua here.




Faux, from Discworld. Feel free to come talk to me =)

http://faux.servebeer.com/
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #46 on Thu 20 Jan 2005 10:01 PM (UTC)
Message
Well, if you leave global variables around, they won't be cleaned up, either. The garbage collector is fairly straightforward; if there are no references to something it gets cleaned up.

As for the table speed, I was pretty sure the table wasn't to blame. Now we just have to write better DB interfaces. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Faux   United Kingdom  (77 posts)  [Biography] bio
Date Reply #47 on Thu 20 Jan 2005 10:55 PM (UTC)

Amended on Thu 20 Jan 2005 10:59 PM (UTC) by Faux

Message
I'm trawling the MDAC SDK as I write this. Wish me luck. :p

I'm thinking of a custom extension that processes everything in C (++ so it's not my fault if it leaks) and just returns a lua table. See if that'll get the speed up a bit (ie. ignoring activex).

On the cleaning up thing, I'm =nil or ={}ing everything I know about, and every time I call this lump of code MUSH's memory usage goes up by ~2MB. It definitely isn't adding anything to anything..

Realoding the script file appears to have no affect on this continued memory gobble. I have no idea how to get MUSH to re-load the dll.. I assumed reloading the scirpt did this.

Changing language, for instance, has no effect, either.

Faux, from Discworld. Feel free to come talk to me =)

http://faux.servebeer.com/
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #48 on Thu 20 Jan 2005 11:01 PM (UTC)
Message
Quote:
(++ so it's not my fault if it leaks)
It's always the programmer's fault if it leaks, unless you're using a garbage-collecting system. :P (Even then...)

As for your memory problems, I'm not sure what the issue is. You can explicitly tell Lua to garbage collect, I think; maybe you should try that.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Faux   United Kingdom  (77 posts)  [Biography] bio
Date Reply #49 on Fri 21 Jan 2005 12:21 AM (UTC)
Message
Quote:
You can explicitly tell Lua to garbage collect..

I am :)

Quote:
It's always the programmer's fault if it leaks,

I'm not writing in C++, but I am using basically an exact copy of an MSDN article, so it's still not my fault =)





Progress report:
Using ODBC I can select at a rate of about 10,000 records/second (in c). Now, how slow can the Luainterface possibly be?

I'm aware that writing this whole thing in C is cheating, but I may call it LuaODBC or something, and release it as an extension, etc. etc. :p

Faux, from Discworld. Feel free to come talk to me =)

http://faux.servebeer.com/
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #50 on Fri 21 Jan 2005 12:33 AM (UTC)
Message
Quote:
I'm not writing in C++, but I am using basically an exact copy of an MSDN article, so it's still not my fault =)
Well, MSDN articles don't pretend to completely manage memory, rather, they just show the concepts, so... :-)
Quote:
Now, how slow can the Luainterface possibly be?
Well... I'm not sure Lua is meant to do constant bouncing back and forth. It might be faster to have an interface that returned a Lua array of results, as opposed to the common paradigm of: while (row) { ... row = getrow() }.
Quote:
I'm aware that writing this whole thing in C is cheating, but I may call it LuaODBC or something, and release it as an extension, etc. etc. :p
I don't think that's cheating... in fact, it seems to me that it's what you're supposed to do with Lua: write extensions to add functionality. Lua's libraries don't claim to do much, after all, in fact they claim to do very little.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Faux   United Kingdom  (77 posts)  [Biography] bio
Date Reply #51 on Fri 21 Jan 2005 02:10 PM (UTC)
Message
Quote:
It might be faster to have an interface that returned a Lua array of results...


Already planned. =)

Quote:
I don't think that's cheating...


First build is going to do all of the array processing in the dll, which defeats the point of using Lua.. but I intend to generalise it at some point ;p

Quote:
They just show the concepts, so...


Theoretically the "copy from the samples directory then build it yourself" ones should build without error or leak :)

Faux, from Discworld. Feel free to come talk to me =)

http://faux.servebeer.com/
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #52 on Fri 21 Jan 2005 02:42 PM (UTC)
Message
Quote:
Theoretically the "copy from the samples directory then build it yourself" ones should build without error or leak :)
I disagree. I don't think samples are meant to be full & complete, production-ready programs. Rather, I think they're meant to show the overall guidelines, how to get something running conceptually. In fact, I tend to expect the bare minimum in terms of leaks etc. from a sample, unless it explicitly claims to be a full, complete & production-ready piece of code. But I suppose that's just a personal opinion...

But why are you taking code from the MSDN anyhow? Are you using ODBC stuff from there? And are you sure the leak is there to begin with? :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Faux   United Kingdom  (77 posts)  [Biography] bio
Date Reply #53 on Fri 21 Jan 2005 03:32 PM (UTC)

Amended on Fri 21 Jan 2005 03:34 PM (UTC) by Faux

Message
Okay, if you want to be technically accurate it's from the MDAC SDK. :p

But yeah, I'm using code from there, because I had (and still have) absolutely no idea what ODBC is ;p

Quote:
And are you sure the leak is there to begin with?

If it is, it's not my problem ;p

Faux, from Discworld. Feel free to come talk to me =)

http://faux.servebeer.com/
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #54 on Fri 21 Jan 2005 03:38 PM (UTC)

Amended on Fri 21 Jan 2005 03:40 PM (UTC) by David Haley

Message
ODBC is a driver for accessing databases, a sort of interface that lets you run SQL queries if you will. Generally it's a PITA to program a driver much less a DBMS (underneath the driver), which is why people very rarely write their own database interfaces. Generally, the drivers work just fine... The problem is of course making sure that the database you're accessing has an intelligent design to it geared towards whatever purpose you're trying to accomplish.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Faux   United Kingdom  (77 posts)  [Biography] bio
Date Reply #55 on Fri 21 Jan 2005 07:39 PM (UTC)
Message
*nods, pretending to understand*

And the SQL language that it uses ishorrid. :p

--- Faus thge possibly very silightly intoxicated :P

Faux, from Discworld. Feel free to come talk to me =)

http://faux.servebeer.com/
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #56 on Fri 21 Jan 2005 10:46 PM (UTC)
Message
Quote:
And the SQL language that it uses ishorrid. :p
There is only one "SQL language" (modulo different standard versions); in fact, SQL stands for "Simple Query Language". There are of course various implementations of SQL that implement the standard slightly differently. Did you mean that its implementation was bad? What were you referring to?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Faux   United Kingdom  (77 posts)  [Biography] bio
Date Reply #57 on Sat 22 Jan 2005 02:42 AM (UTC)
Message
I had a query that I was running on the MDB that was ran and returned correct results, but wasn't valid as what I'd call SQL (having used it through php/mysql), and didn't execute on my MySQL server (with an identical copy of the db). Some kind of syntax error, I don't remmeber.

I've deleted the code witht he query in, so I can't paste it to you :/

In case you hadn't guessed yet, I learn by the "duct tape" method. :p

Faux, from Discworld. Feel free to come talk to me =)

http://faux.servebeer.com/
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #58 on Sat 22 Jan 2005 02:48 AM (UTC)
Message
Well, different implementations do sometimes have ever so slightly different syntax. The major SQL flavors are MySQL, Oracle and ODBC. Oracle has its own quirks as well; but generally it's not too hard to get queries working for one or the other.
Quote:
In case you hadn't guessed yet, I learn by the "duct tape" method. :p
So you'd learn how to do it, but how do you know you're doing it the right way? :-P

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Faux   United Kingdom  (77 posts)  [Biography] bio
Date Reply #59 on Sat 22 Jan 2005 05:09 AM (UTC)
Message
Quote:
So you'd learn how to do it, but how do you know you're doing it the right way? :-P


..right? :p

Nah, what I meant was I learn by leeching other people's code and beating it senseless (like, stripping it from c++ to c), then duct-taping it on to my project. Normally ends up with me having a pretty good knowledge of what's going on by the end of it..
If it works, too, that's a plus. :)


Quote:
The major SQL flavors are..

And Postgres, just so you don't get eaten by trolls. :p

Faux, from Discworld. Feel free to come talk to me =)

http://faux.servebeer.com/
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


135,526 views.

This is page 4, subject is 5 pages long:  [Previous page]  1  2  3  4 5  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]