[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua Digest, Vol 198, Issue 1
- From: Lingfeng Xiong <jilingshu@...>
- Date: Mon, 15 Mar 2010 23:53:39 +0800
Hi,
I try to rename luasocket.dll to socket.dll and use
"require("socket")",it still give me this error.and also,the luaxml
has this error too.
Parament incorrect?i build these libs on wince5 by vs2008.what shall i
do to make everything goes well?thx!!!
2010/3/15, lua-request@bazar2.conectiva.com.br
<lua-request@bazar2.conectiva.com.br>:
> Send Lua mailing list submissions to
> lua@bazar2.conectiva.com.br
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://bazar2.conectiva.com.br/mailman/listinfo/lua
> or, via email, send a message with subject or body 'help' to
> lua-request@bazar2.conectiva.com.br
>
> You can reach the person managing the list at
> lua-owner@bazar2.conectiva.com.br
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Lua digest..."
>
>
> Today's Topics:
>
> 1. RE: exception when calling lua with iup (Antonio Scuri)
> 2. Re: Standard Libraries: (Luiz Henrique de Figueiredo)
> 3. Re: Performance improvement in luaL_addlstring (Majic)
> 4. Re: private/public key support ? (Robert Raschke)
> 5. Re: private/public key support ? (Valerio Schiavoni)
> 6. Re: private/public key support ? (Valerio Schiavoni)
> 7. Re: Performance improvement in luaL_addlstring (Leo Razoumov)
> 8. Re: private/public key support ? (Luiz Henrique de Figueiredo)
> 9. Re: Performance improvement in luaL_addlstring
> (Luiz Henrique de Figueiredo)
> 10. Re: Performance improvement in luaL_addlstring (Leo Razoumov)
> 11. Re: Performance improvement in luaL_addlstring (David Burgess)
> 12. Re: Performance improvement in luaL_addlstring (Matthew Wild)
> 13. about C library (Bear)
> 14. Re: about C library (Jeff Pohlmeyer)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 14 Mar 2010 12:35:29 -0300
> From: "Antonio Scuri" <scuri@tecgraf.puc-rio.br>
> Subject: RE: exception when calling lua with iup
> To: "'Lua list'" <lua@bazar2.conectiva.com.br>
> Message-ID: <001801cac38b$faec48a0$f0c4d9e0$@puc-rio.br>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Ok. Thanks.
>
> Since it is not crashing while you call IUP, and you are using Visual C++
> 6, so it does look like a RTL memory problem.
>
> I made a few tests with that code you sent:
>
> test.exe, lua5.1.dll and iuplua51.dll (all built with vc8 depending on
> MSVCR80.DLL) -> ok
> test.exe, lua5.1.dll and iuplua51.dll (exe built with vc6 depending on
> MSVCRT.DLL, dlls built with vc8 depending on MSVCR80.DLL) -> still ok
> test.exe, lua5.1.dll and iuplua51.dll (exe built with vc6 static RTL, dlls
> still built with vc8 depending on MSVCR80.DLL) -> crash
>
> Maybe your project configuration must have to be adjusted.
>
> The standard in Lua for Windows is vc8 depending on MSVCR80.DLL, so some
> DLLs may work some don't. I think IUP are that case that don't.
>
> You may try using the DLLs for vc6 depending on MSVCRT.DLL. There are
> pre-compiled binaries for download in IUP web site.
>
> Best Regards,
> Antonio Scuri
>
>> -----Original Message-----
>> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-
>> bounces@bazar2.conectiva.com.br] On Behalf Of "J.J?rgen von Bargen"
>> Sent: domingo, 14 de mar?o de 2010 08:01
>> To: lua@bazar2.conectiva.com.br
>> Subject: Re: exception when calling lua with iup
>>
>> Am 12.03.2010 16:21, schrieb Antonio Scuri:
>> > Are you using IUP from LfW? That would be IUP 2. Can you try the same
>> using the IUP 3 DLLs?
>> >
>> Hi!
>> I just downloaded LuaForWindows_v5.1.4-33, extracted iuplua51.dll and
>> iupdll to my testdirectory (i dont want to spoil my
>> LuaForWindows_v5.1.4-30 installation yet),
>> changed package.cpath to point to my local folder and...
>> ... the same crash. (Well not really the same, Crt now manages to show
>> the error message before the exception, so it's a bit better, but I'll
>> call it a crash anyway):
>>
>> ---------------------------
>> Microsoft Visual C++ Debug Library
>> ---------------------------
>> Debug Assertion Failed!
>>
>> Program: D:\MYPROJECTS\LuaDialog2\LuaDialog\Debug\LuaDialog.exe
>> File: dbgheap.c
>> Line: 1044
>>
>> Expression: _CrtIsValidHeapPointer(pUserData)
>>
>> For information on how your program can cause an assertion
>> failure, see the Visual C++ documentation on asserts.
>>
>> (Press Retry to debug the application)
>> ---------------------------
>> Abbrechen Wiederholen Ignorieren
>> ---------------------------
>>
>> So the problems remain the same...
>>
>> Regards
>>
>> > Thanks,
>> > scuri
>> >
>> >
>> >> -----Original Message-----
>> >> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-
>> >> bounces@bazar2.conectiva.com.br] On Behalf Of "J.J?rgen von Bargen"
>> >> Sent: sexta-feira, 12 de mar?o de 2010 03:17
>> >> To: lua@bazar2.conectiva.com.br
>> >> Subject: exception when calling lua with iup
>> >>
>> >> Hi folks!
>> >>
>> >> This error originaly occurs in a big application, but to get a focus
>> on
>> >> in, I reproduced it in a small environment.
>> >> Im using VisualStudio (VisualC++ 6.0). I created a standard dialog
>> >> application with a text field and a button to call lua with the
>> text.
>> >> This is the relevant code:
>> >>
>> >> void CLuaDialogDlg::OnDo()
>> >> {
>> >> lua_State *L = lua_open(); /* create state */
>> >> if (L == NULL)
>> >> {
>> >> MessageBox("cannot create state: not enough memory");
>> >> return;
>> >> }
>> >> luaL_openlibs(L);
>> >> lua_register(L,"print",print);
>> >>
>> >> CString code;
>> >> GetDlgItemText(IDC_LUACODE,code);
>> >> int status=luaL_dostring(L,code);
>> >>
>> >> if (status&& !lua_isnil(L, -1))
>> >> {
>> >> const char *msg = lua_tostring(L, -1);
>> >> if (msg == NULL) msg = "(error object is not a string)";
>> >> MessageBox(msg);
>> >> lua_pop(L, 1);
>> >> }
>> >> lua_close(L);
>> >> }
>> >>
>> >> This works fine for a lot of lua scripts. After fiddling the
>> >> package.cpath and package.path (by adding a package.cpath="... lot
>> of
>> >> entries..." to the script) to point to my LuaForWindows installation
>> I
>> >> can also use lfs and other libs with no problems.
>> >>
>> >> The trouble begins, when I try to use iuplua. The following code
>> >>
>> >> require"iuplua"
>> >> iup.Alarm('TITLE','TEXT','OK')
>> >>
>> >> shows the alarm, but then get a "unhandled exception" inside the
>> >> lua_close. Interesting, even a
>> >>
>> >> require"iuplua"
>> >>
>> >> with no further code causes the crash.
>> >>
>> >>
>> >> The stacktrack shows up like this:
>> >>
>> >> 00db26a0()
>> >> USER32! 7e381923()
>> >> USER32! 7e37b317()
>> >> USER32! 7e3778d0()
>> >> NTDLL! 7c91e473()
>> >> USER32! 7e369402()
>> >> USER32! 7e377611()
>> >> USER32! 7e3749c4()
>> >> USER32! 7e38a956()
>> >> USER32! 7e38a2bc()
>> >> USER32! 7e3b63fd()
>> >> USER32! 7e3b64a2()
>> >> USER32! 7e3a0877()
>> >> USER32! 7e3a082f()
>> >> __crtMessageBoxA(const char * 0x0012b198, const char * 0x004d5bfc
>> >> `string', unsigned int 73746) line 65
>> >> CrtMessageWindow(int 2, const char * 0x004d5198 `string', const char
>> *
>> >> 0x0012c2cc, const char * 0x00000000, const char * 0x0012e2f0) line
>> 520
>> >> +
>> >> 22 bytes
>> >> _CrtDbgReport(int 2, const char * 0x004d5198 `string', int 1044,
>> const
>> >> char * 0x00000000, const char * 0x004d52b4 `string') line 419 + 76
>> >> bytes
>> >> _free_dbg_lk(void * 0x00e41858, int 1) line 1044 + 40 bytes
>> >> _free_dbg(void * 0x00e41858, int 1) line 1001 + 13 bytes
>> >> free(void * 0x00e41858) line 956 + 11 bytes
>> >> l_alloc(void * 0x00000000, void * 0x00e41858, unsigned int 32,
>> unsigned
>> >> int 0) line 631 + 9 bytes
>> >> luaM_realloc_(lua_State * 0x009a4d08, void * 0x00e41858, unsigned
>> int
>> >> 32, unsigned int 0) line 79 + 27 bytes
>> >> luaH_free(lua_State * 0x009a4d08, Table * 0x00cb4560) line 376 + 39
>> >> bytes
>> >> freeobj(lua_State * 0x009a4d08, GCObject * 0x00cb4560) line 383 + 13
>> >> bytes
>> >> sweeplist(lua_State * 0x009a4d08, GCObject * * 0x009a4d9c, unsigned
>> int
>> >> 4294967289) line 424 + 13 bytes
>> >> luaC_freeall(lua_State * 0x009a4d08) line 487 + 18 bytes
>> >> close_state(lua_State * 0x009a4d08) line 108 + 9 bytes
>> >> lua_close(lua_State * 0x009a4d08) line 212 + 9 bytes
>> >> CLuaDialogDlg::OnDo() line 224 + 9 bytes
>> >>
>> >> After setting a breakpoint into CrtMessageWindow I could fetch the
>> >> message
>> >>
>> >> "Debug Assertion Failed!
>> >>
>> >> Program: D:\MYPROJECTS\LuaDialog2\LuaDialog\Debug\LuaDialog.exe
>> >> File: dbgheap.c
>> >> Line: 1044
>> >>
>> >> Expression: _CrtIsValidHeapPointer(pUserData)
>> >>
>> >> So this looks to me, as if free is called with an invalid pointer,
>> but
>> >> there must be more memory corrupted, because the error message newer
>> >> gets displayed.
>> >>
>> >> Im using lua-5.1.4 from the source-tar statically linked, every
>> other
>> >> lib or dll is loaded via package from LuaForWindows_v5.1.4-30
>> >> Can you give me any helpfull hints, how to fix (or avoid) the
>> problem?
>> >>
>> >> Regards
>> >>
>> >
>> >
> -------------- next part --------------
> An embedded and charset-unspecified text was scrubbed...
> Name: lua_init_load.c
> Url:
> http://bazar2.conectiva.com.br/mailman/private/lua/attachments/20100314/1c4e2408/lua_init_load-0001.c
>
> ------------------------------
>
> Message: 2
> Date: Sun, 14 Mar 2010 21:24:09 -0300
> From: Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
> Subject: Re: Standard Libraries:
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID: <20100314212409.A22890@lua.tecgraf.puc-rio.br>
> Content-Type: text/plain; charset=us-ascii
>
>> The list of useful types I've identified so far is pretty short:
>> [...]
>> - arbitary-precision integers
>
> See my lbc, http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lbc
>
>> - perhaps decimal floating point numbers
>
> See Lua decNumber, http://luaforge.net/projects/ldecnumber/
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 15 Mar 2010 07:31:13 +0000
> From: Majic <majic.one@gmail.com>
> Subject: Re: Performance improvement in luaL_addlstring
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID:
> <7e46a0591003150031j49ef208fhff99266ca8149a55@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Very nice! :D
>
> On Fri, Mar 12, 2010 at 2:17 PM, Chuck Coffing <clc@alum.mit.edu> wrote:
>> Hi list,
>>
>> At work we use Lua in an embedded environment. ?It's a large project that
>> does a lot of network IO. ?After some profiling, I discovered that
>> luaL_addlstring was consuming a large amount of the processor; much of the
>> usage was initiated by luasockets.
>>
>> It turns out that luaL_addlstring calls luaL_addchar for every byte, which
>> means that multiple dereferences, a test, and a jump occur for every byte
>> received over the network.
>>
>> The buffer, however, already knows how much space it has available, so the
>> repeated tests are unnecessary. ?I changed luaL_addlstring to memcpy the
>> largest chunk that is known to fit, and then expand the buffer as needed.
>>
>> For a trivial luasocket client that receives data, the change cuts the
>> number
>> of instructions executed by more than 50%. ?(I use valgrind to count
>> instructions.) ?I recall (although it's been a while) that it cut the
>> instruction count of our app by about 13% overall.
>>
>> The change only minimally increases the code size (16 bytes larger on
>> x86):
>>
>> chuck@magma:~/lua-perf$ nm -S lua.orig | grep addlstring
>> 08059ec0 00000068 T luaL_addlstring
>> chuck@magma:~/lua-perf$ nm -S lua.perf | grep addlstring
>> 08059ec0 00000078 T luaL_addlstring
>>
>> I made the change on 5.1.4, but it looks like 5.2 has the same performance
>> issue.
>>
>> Patch is below; the trivial test script and output from Valgrind is also
>> below.
>>
>> --
>> Chuck
>>
>>
>>
>> --- lua-5.1.4.orig/src/lauxlib.c ? ?2008-01-21 06:20:51.000000000 -0700
>> +++ lua-5.1.4/src/lauxlib.c 2010-03-12 05:48:39.000000000 -0700
>> @@ -434,8 +434,19 @@
>>
>>
>> ?LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l)
>> {
>> - ?while (l--)
>> - ? ?luaL_addchar(B, *s++);
>> + ?while (l) {
>> + ? ?size_t min;
>> + ? ?size_t avail = bufffree(B);
>> + ? ?if (!avail) {
>> + ? ? ?luaL_prepbuffer(B);
>> + ? ? ?avail = bufffree(B);
>> + ? ?}
>> + ? ?min = avail <= l ? avail : l;
>> + ? ?memcpy(B->p, s, min);
>> + ? ?B->p += min;
>> + ? ?s += min;
>> + ? ?l -= min;
>> + ?}
>> ?}
>>
>>
>>
>>
>> chuck@magma:~/lua-perf$ cat echo.lua
>> require "socket"
>>
>> server, err = socket.bind("*", 0)
>> assert(server, err)
>> ip, port = server:getsockname()
>> print("Please telnet to localhost on port " .. port)
>> client, err = server:accept()
>> total = 0
>> while not err do
>> ?data, err = client:receive(4096)
>> ?if err then break end
>> ?client:send("receive(" .. tostring(#data) .. ")")
>> ?total = total + #data
>> ?if total >= 1024*1024 then break end
>> end
>> client:close()
>> chuck@magma:~/lua-perf$ valgrind --tool=cachegrind ./lua.orig echo.lua
>> ==8565== Cachegrind, a cache and branch-prediction profiler
>> ==8565== Copyright (C) 2002-2009, and GNU GPL'd, by Nicholas Nethercote et
>> al.
>> ==8565== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for
>> copyright info
>> ==8565== Command: ./lua.orig echo.lua
>> ==8565==
>> Please telnet to localhost on port 60342
>> ==8565==
>> ==8565== I ? refs: ? ? ?16,345,890
>> ==8565== I1 ?misses: ? ? ? ?28,037
>> ==8565== L2i misses: ? ? ? ? 2,426
>> ==8565== I1 ?miss rate: ? ? ? 0.17%
>> ==8565== L2i miss rate: ? ? ? 0.01%
>> ==8565==
>> ==8565== D ? refs: ? ? ? 8,229,564 ?(4,619,517 rd ? + 3,610,047 wr)
>> ==8565== D1 ?misses: ? ? ? ?53,970 ?( ? 32,310 rd ? + ? ?21,660 wr)
>> ==8565== L2d misses: ? ? ? ? 5,991 ?( ? ?3,442 rd ? + ? ? 2,549 wr)
>> ==8565== D1 ?miss rate: ? ? ? ?0.6% ( ? ? ?0.6% ? ? + ? ? ? 0.5% ?)
>> ==8565== L2d miss rate: ? ? ? ?0.0% ( ? ? ?0.0% ? ? + ? ? ? 0.0% ?)
>> ==8565==
>> ==8565== L2 refs: ? ? ? ? ? 82,007 ?( ? 60,347 rd ? + ? ?21,660 wr)
>> ==8565== L2 misses: ? ? ? ? ?8,417 ?( ? ?5,868 rd ? + ? ? 2,549 wr)
>> ==8565== L2 miss rate: ? ? ? ? 0.0% ( ? ? ?0.0% ? ? + ? ? ? 0.0% ?)
>> chuck@magma:~/lua-perf$ valgrind --tool=cachegrind ./lua.orig echo.lua
>> [...snip...]
>> ==8570== I ? refs: ? ? ?16,345,917
>> [...snip...]
>> chuck@magma:~/lua-perf$ valgrind --tool=cachegrind ./lua.orig echo.lua
>> [...snip...]
>> ==8575== I ? refs: ? ? ?16,345,861
>> [...snip...]
>> chuck@magma:~/lua-perf$ valgrind --tool=cachegrind ./lua.perf echo.lua
>> ==8580== Cachegrind, a cache and branch-prediction profiler
>> ==8580== Copyright (C) 2002-2009, and GNU GPL'd, by Nicholas Nethercote et
>> al.
>> ==8580== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for
>> copyright info
>> ==8580== Command: ./lua.perf echo.lua
>> ==8580==
>> Please telnet to localhost on port 43713
>> ==8580==
>> ==8580== I ? refs: ? ? ?7,179,931
>> ==8580== I1 ?misses: ? ? ? 26,354
>> ==8580== L2i misses: ? ? ? ?2,422
>> ==8580== I1 ?miss rate: ? ? ?0.36%
>> ==8580== L2i miss rate: ? ? ?0.03%
>> ==8580==
>> ==8580== D ? refs: ? ? ?4,563,501 ?(2,786,905 rd ? + 1,776,596 wr)
>> ==8580== D1 ?misses: ? ? ? 54,462 ?( ? 32,711 rd ? + ? ?21,751 wr)
>> ==8580== L2d misses: ? ? ? ?5,989 ?( ? ?3,440 rd ? + ? ? 2,549 wr)
>> ==8580== D1 ?miss rate: ? ? ? 1.1% ( ? ? ?1.1% ? ? + ? ? ? 1.2% ?)
>> ==8580== L2d miss rate: ? ? ? 0.1% ( ? ? ?0.1% ? ? + ? ? ? 0.1% ?)
>> ==8580==
>> ==8580== L2 refs: ? ? ? ? ?80,816 ?( ? 59,065 rd ? + ? ?21,751 wr)
>> ==8580== L2 misses: ? ? ? ? 8,411 ?( ? ?5,862 rd ? + ? ? 2,549 wr)
>> ==8580== L2 miss rate: ? ? ? ?0.0% ( ? ? ?0.0% ? ? + ? ? ? 0.1% ?)
>> chuck@magma:~/lua-perf$ valgrind --tool=cachegrind ./lua.perf echo.lua
>> [...snip...]
>> ==8586== I ? refs: ? ? ?7,179,933
>> [...snip...]
>> chuck@magma:~/lua-perf$ valgrind --tool=cachegrind ./lua.perf echo.lua
>> [...snip...]
>> ==8591== I ? refs: ? ? ?7,179,922
>> [...snip...]
>> chuck@magma:~/lua-perf$
>>
>>
>
>
> ------------------------------
>
> Message: 4
> Date: Mon, 15 Mar 2010 09:54:37 +0000
> From: Robert Raschke <rtrlists@googlemail.com>
> Subject: Re: private/public key support ?
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID:
> <6a3ae47e1003150254g2096aca4s4c9b353dea07789b@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> On Sat, Mar 13, 2010 at 5:05 PM, Valerio Schiavoni <
> valerio.schiavoni@gmail.com> wrote:
>
>> Hello,
>> which library should I use to implement public/private key encryption ?
>> It seems to me that LyaCrypto only exposes OpenSSL digest operations.
>>
>> Thanks for any pointer,
>> Valerio
>>
>
> LuaSec (http://www.inf.puc-rio.br/~brunoos/luasec/) works well to handle SSL
> communication; but I'm not sure if that's what you are asking.
>
> Robby
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://bazar2.conectiva.com.br/mailman/private/lua/attachments/20100315/8e6ef190/attachment-0001.html
>
> ------------------------------
>
> Message: 5
> Date: Mon, 15 Mar 2010 11:23:46 +0100
> From: Valerio Schiavoni <valerio.schiavoni@gmail.com>
> Subject: Re: private/public key support ?
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID:
> <fa5c729b1003150323w768d5cedrb2cf33a0dfb7dea9@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hello Robert,
>
> On Mon, Mar 15, 2010 at 10:54 AM, Robert Raschke
> <rtrlists@googlemail.com> wrote:
>> LuaSec (http://www.inf.puc-rio.br/~brunoos/luasec/) works well to handle
>> SSL
>> communication; but I'm not sure if that's what you are asking.
>
> i'm asking for RSA or SHA-1 or any other public/private key encryption
> support.
>
> For instance, in this presentation
> http://fliiby.com/file/272148/4hh27ix1dt.html they mention a lua
> library called Prism which seems to do the job, but i can't find it.
>
>
> valerio
>
>
> ------------------------------
>
> Message: 6
> Date: Mon, 15 Mar 2010 13:21:58 +0100
> From: Valerio Schiavoni <valerio.schiavoni@gmail.com>
> Subject: Re: private/public key support ?
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID:
> <fa5c729b1003150521y6926f38ej75b97b0e286a013c@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> I've found what I was looking for:
>
> http://luaforge.net/frs/?group_id=394&release_id=1120
>
> it's "very" slow because it's in pure Lua, but it's exactly what I was
> searching.
> Maybe some C-backed implementation would be better..
>
> On Mon, Mar 15, 2010 at 11:23 AM, Valerio Schiavoni
> <valerio.schiavoni@gmail.com> wrote:
>> Hello Robert,
>>
>> On Mon, Mar 15, 2010 at 10:54 AM, Robert Raschke
>> <rtrlists@googlemail.com> wrote:
>>> LuaSec (http://www.inf.puc-rio.br/~brunoos/luasec/) works well to handle
>>> SSL
>>> communication; but I'm not sure if that's what you are asking.
>>
>> i'm asking for RSA or SHA-1 or any other public/private key encryption
>> support.
>>
>> For instance, in this presentation
>> http://fliiby.com/file/272148/4hh27ix1dt.html they mention a lua
>> library called Prism which seems to do the job, but i can't find it.
>>
>>
>> valerio
>>
>
>
> ------------------------------
>
> Message: 7
> Date: Mon, 15 Mar 2010 08:49:19 -0400
> From: Leo Razoumov <slonik.az@gmail.com>
> Subject: Re: Performance improvement in luaL_addlstring
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID:
> <ee2a733e1003150549k2e684246xe1ed0f087e639f81@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On 2010-03-12, Chuck Coffing <clc@alum.mit.edu> wrote:
>> Hi list,
>>
>> At work we use Lua in an embedded environment. It's a large project that
>> does a lot of network IO. After some profiling, I discovered that
>> luaL_addlstring was consuming a large amount of the processor; much of
>> the
>> usage was initiated by luasockets.
>>
>> It turns out that luaL_addlstring calls luaL_addchar for every byte,
>> which
>> means that multiple dereferences, a test, and a jump occur for every byte
>> received over the network.
>>
>> The buffer, however, already knows how much space it has available, so
>> the
>> repeated tests are unnecessary. I changed luaL_addlstring to memcpy the
>> largest chunk that is known to fit, and then expand the buffer as needed.
>>
>> For a trivial luasocket client that receives data, the change cuts the
>> number
>> of instructions executed by more than 50%. (I use valgrind to count
>> instructions.) I recall (although it's been a while) that it cut the
>> instruction count of our app by about 13% overall.
>>
>> The change only minimally increases the code size (16 bytes larger on
>> x86):
>>
>> chuck@magma:~/lua-perf$ nm -S lua.orig | grep addlstring
>> 08059ec0 00000068 T luaL_addlstring
>> chuck@magma:~/lua-perf$ nm -S lua.perf | grep addlstring
>> 08059ec0 00000078 T luaL_addlstring
>>
>> I made the change on 5.1.4, but it looks like 5.2 has the same
>> performance
>> issue.
>>
>> Patch is below; the trivial test script and output from Valgrind is also
>> below.
>>
>
> It would be great if this patch (or its equivalent) makes its way into
> official Lua-5.1.4 patch list at http://www.lua.org/bugs.html
>
> --Leo--
>
>
> ------------------------------
>
> Message: 8
> Date: Mon, 15 Mar 2010 09:56:14 -0300
> From: Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
> Subject: Re: private/public key support ?
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID: <20100315095613.A24354@lua.tecgraf.puc-rio.br>
> Content-Type: text/plain; charset=us-ascii
>
>> I've found what I was looking for:
>>
>> http://luaforge.net/frs/?group_id=394&release_id=1120
>>
>> it's "very" slow because it's in pure Lua, but it's exactly what I was
>> searching.
>> Maybe some C-backed implementation would be better..
>
> You can combine my lmd5 (which also supports SHA1) with my lbc, which does
> arbitrary precision arithmetic, including modular exponentiation. See
> http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lmd5
> http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lbc
>
>
> ------------------------------
>
> Message: 9
> Date: Mon, 15 Mar 2010 09:56:44 -0300
> From: Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
> Subject: Re: Performance improvement in luaL_addlstring
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID: <20100315095644.B24354@lua.tecgraf.puc-rio.br>
> Content-Type: text/plain; charset=us-ascii
>
>> It would be great if this patch (or its equivalent) makes its way into
>> official Lua-5.1.4 patch list at http://www.lua.org/bugs.html
>
> Why? It's not a bug, is it?
>
>
> ------------------------------
>
> Message: 10
> Date: Mon, 15 Mar 2010 09:15:44 -0400
> From: Leo Razoumov <slonik.az@gmail.com>
> Subject: Re: Performance improvement in luaL_addlstring
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID:
> <ee2a733e1003150615g625ca908pb9d796f729eaf100@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On 2010-03-15, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
>> > It would be great if this patch (or its equivalent) makes its way into
>> > official Lua-5.1.4 patch list at http://www.lua.org/bugs.html
>>
>>
>> Why? It's not a bug, is it?
>>
>
> Technically speaking it is not a bug. However, it is an obvious
> performance improvement that would benefit many people who use Lua
> (socket, COPAS, etc) for TCP servers. As far as I know the only
> official place for in-between-release patches is
> http://www.lua.org/bugs.html. Where else should this patch go?
> How about http://www.lua.org/patches.html ??
>
> --Leo--
>
> P.S. On closer inspection http://www.lua.org/bugs.html does include
> performance related fixes. E.g.: Lua-5.1.4 #6:
>
> 6. GC may get stuck during parsing and avoids proper resizing of the
> string table, making its lists grow too much and degrading
> performance.
>
>
> ------------------------------
>
> Message: 11
> Date: Tue, 16 Mar 2010 00:24:37 +1100
> From: David Burgess <dabsoft@gmail.com>
> Subject: Re: Performance improvement in luaL_addlstring
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID: <4B9E3515.5080102@gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> I would second the idea of putting the patch out as 5.1.4 patch.
>
> On 15/3/2010 11:49 PM, Leo Razoumov wrote:
>> It would be great if this patch (or its equivalent) makes its way into
>> official Lua-5.1.4 patch list at http://www.lua.org/bugs.html
>>
>> --Leo--
>
>
> ------------------------------
>
> Message: 12
> Date: Mon, 15 Mar 2010 14:27:42 +0000
> From: Matthew Wild <mwild1@gmail.com>
> Subject: Re: Performance improvement in luaL_addlstring
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID:
> <4db9cacb1003150727p15a2f819i340760abcce50fca@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On 15 March 2010 13:24, David Burgess <dabsoft@gmail.com> wrote:
>> I would second the idea of putting the patch out as 5.1.4 patch.
>>
>
> I would third it, but shan't get my hopes up :)
>
> Thanks Chuck, for giving me something to benchmark in a spare moment.
>
> Matthew
>
>
> ------------------------------
>
> Message: 13
> Date: Mon, 15 Mar 2010 22:48:48 +0800
> From: Bear <jilingshu@gmail.com>
> Subject: about C library
> To: "lua" <lua@bazar2.conectiva.com.br>
> Message-ID: <201003152248440946491@Gmail.com>
> Content-Type: text/plain; charset="us-ascii"
>
> hi all,
> i just compile two lua libraries.one is LuaXml and the other one is
> LuaSocket.I try to use them in my script like this:
>
> io.write("hello world\n");
> require("luasocket");
> require("LuaXml");
>
> but unfortunely,none of the libraries can work well.the system told me this:
>
> ERR:1
> ERR MSG:error loading module 'luasocket' from file '\Program
> Files\wmssystem\luasocket.dll':
> system error 87
>
>
> and
>
> ERR:1
> ERR MSG:error loading module 'LuaXml' from file '\Program
> Files\wmssystem\LuaXml.dll':
> system error 87
>
>
> i tried to google this error message but nothing found.could u give me some
> advise?thx!!
>
> P.S.:these two libraries are necessary for my project.i must slove this
> problem ASAP.
> --------------
> Bear
> 2010-03-15
>
>
>
> ------------------------------
>
> Message: 14
> Date: Mon, 15 Mar 2010 09:57:00 -0500
> From: Jeff Pohlmeyer <yetanothergeek@gmail.com>
> Subject: Re: about C library
> To: Lua list <lua@bazar2.conectiva.com.br>
> Message-ID:
> <a275e6d01003150757w433e2f1er2f819d1803ce20ad@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Mon, Mar 15, 2010 at 9:48 AM, Bear <jilingshu@gmail.com> wrote:
>
>> require("luasocket");
>
> I think that should be:
> require("socket");
>
>
>> system error 87
>
> According to:
> http://msdn.microsoft.com/en-us/library/ms681381%28VS.85%29.aspx
> 87 = ERROR_INVALID_PARAMETER "The parameter is incorrect."
>
>
> - Jeff
>
>
> End of Lua Digest, Vol 198, Issue 1
> ***********************************
>
--
从我的移动设备发送