Giter VIP home page Giter VIP logo

jx's People

Contributors

1046102779 avatar alextomaili avatar allenx2018 avatar bboreham avatar bbrks avatar carlcarl avatar cch123 avatar ceshihao avatar dependabot[bot] avatar dvrkps avatar elee1766 avatar ernado avatar eruca avatar fishyww avatar ggaaooppeenngg avatar javierprovecho avatar liggitt avatar nikhita avatar olegshaldybin avatar onelrdm avatar polyzy avatar quasilyte avatar superfashi avatar taowen avatar tdakkota avatar teou avatar thockin avatar toffaletti avatar yjhmelody avatar zhaitianduo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jx's Issues

test: cleanup

  • Use Go test naming convention (TestDecoder_Skip instead of Test_skip)
  • Unify benchmarks and delete duplicates (BenchmarkValid vs BenchmarkSkip)
  • Populate testdata with different cases (real world objects, big array of primitives, use some benchmark sets)
    • #12 (added floats.json)
    • #15 (added small/medium/large/etc)
    • #18 (added bools.json and nulls.json)
    • e00d36c (added corpus from JSONTestSuite)
  • Use table tests, generate cases for in-memory and streaming decoding

perf: get rid of allocation in float decoding slow path

Currently, float decoder fallbacks to strconv.ParseFloat and causes []byte -> string allocation. Possibly we could avoid such conversion by vendoring float implementation from Go library. Also we should try to improve current float parsing algorithm.

ability to stream arbitrary bytes to the underlying writer when in streaming mode

i have a use case where i would like part of my message to be json streamed encoded from reflection, but i would still like to use jx for the remaining encoding, as most requests are small and do not require any reflection.

currently, when the writer is in streaming mode, all calls to Write will cause an error.

i propose to simply flush the buffer and then pass the call to Write, which would allow now other json-encoders to stream into jx's encoder. i did this in a fork https://github.com/elee1766/jx and it seems to be working?

given that the package does not want to do any reflection based encoding, this seems like a good compromise?

perf: research performance impact of bytesets

Currently we use some bytesets to improve matching speed

  • To match space characters

    jx/dec_read.go

    Lines 15 to 17 in 3ed0c1e

    var spaceSet = [256]byte{
    ' ': 1, '\n': 1, '\t': 1, '\r': 1,
    }
  • To match digits and skip number

    jx/dec_skip.go

    Lines 47 to 66 in 97d4e11

    skipNumberSet = [256]byte{
    '0': 1,
    '1': 1,
    '2': 1,
    '3': 1,
    '4': 1,
    '5': 1,
    '6': 1,
    '7': 1,
    '8': 1,
    '9': 1,
    ',': 2,
    ']': 2,
    '}': 2,
    ' ': 2,
    '\t': 2,
    '\n': 2,
    '\r': 2,
    }
  • To match and validate hex and fast string escaping

    jx/dec_skip.go

    Lines 242 to 256 in 97d4e11

    escapedStrSet = [256]byte{
    '"': 1, '\\': 1, '/': 1, 'b': 1, 'f': 1, 'n': 1, 'r': 1, 't': 1,
    'u': 2,
    }
    hexSet = [256]byte{
    '0': 1, '1': 1, '2': 1, '3': 1,
    '4': 1, '5': 1, '6': 1, '7': 1,
    '8': 1, '9': 1,
    'A': 1, 'B': 1, 'C': 1, 'D': 1,
    'E': 1, 'F': 1,
    'a': 1, 'b': 1, 'c': 1, 'd': 1,
    'e': 1, 'f': 1,
    }

    jx/w_str.go

    Lines 211 to 219 in c048666

    var safeSet = [256]byte{
    // First 31 characters.
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    '"': 1,
    '\\': 1,
    }
  • To make HTML-safe escaping

    jx/w_str.go

    Line 14 in c048666

    var htmlSafeSet = [utf8.RuneSelf]bool{

Totaly we have 6 sets, 5 of [256]byte and one [128]byte, it tooks 256*5 + 128 = 1408 bytes.
In benchmarks it performs well because we use only 1-2 of them.
But it may cause cache pollution and slow down parser in realistic cases.

We need to research real impact of such optimizations and possibly use comparsion instead or merge some sets and use bit masks.

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.