Coder Social home page Coder Social logo

Comments (6)

imzyxwvu avatar imzyxwvu commented on July 16, 2024

Since Lua strings need hash calculating when they are being created and immutable, creating them is slower. But they are very fast when being compared and indexed with. Actually Lua strings are fast enough. I created an TCP/IP stack mostly in Lua and it heavily depends on Lua strings, but it could generate more than 3000 IP frames per second on my RPi2.

The problems I guess we would meet:

  1. When Lua strings are used as table indexes, they are used as values, but userdatas would be used as references. This might make old Lua users feel confused. They have to be aware to convert buffers into Lua strings.
  2. Decoder-style stream demuxers heavily depend on Lua string pattern match APIs for line-text protocols. They would not benefit from this kind of buffers. If a raw find method is implemented, this problem would disappear.
  3. luajit could inline some string operations. If buffers are implemented in a foreign library, this optimize could not take place.

from luvi.

creationix avatar creationix commented on July 16, 2024

Is speed really a bottleneck using strings in a real use case? I also made a test http server that decodes the http protocol using lua string methods and it was able to handle insanely high speeds on my desktop computer.

from luvi.

zhaozg avatar zhaozg commented on July 16, 2024

Yes, I think lua string enough to handle plain text protocol,include HTTP,SMTP,POP.
But please think about to inline handle msgpack or SNMP binary based protocol.
Maybe string.pack and string.unpack come from lua5.3 will better solution. I prefer to string.pack/unpack than mutable string.

from luvi.

imzyxwvu avatar imzyxwvu commented on July 16, 2024

string.pack and string.unpack could be found in a C library called struct. There is also one msgpack implement for Lua you could found in msgpack homepage.

from luvi.

zhaozg avatar zhaozg commented on July 16, 2024

Combine string pack/unpack in luvi better than extern module.

from luvi.

zhaozg avatar zhaozg commented on July 16, 2024

Close this, #76

from luvi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.