1. 26 Apr, 2020 5 commits
    • Eric Myhre's avatar
      More extraction and DRY'ing. · 7754ce08
      Eric Myhre authored
      Int is now basically all common stuff.  Now I'm really gonna quit.
      
      Interestingly, the total line count isn't going down very fast.
      108 insertions, 165 deletions, according to the git diff stat.
      Evidentally the overhead of things opting into this is darn near
      the amount of lines saved in many cases.
      7754ce08
    • Eric Myhre's avatar
      AssignNull method now also DRY across reprs :D · 3c03a6d3
      Eric Myhre authored
      Decided a basic bool property for this is probably fine after all.
      (For quite a while I'd been wondering if we'd end up with an enum
      of variants that are more or less semantic siblings of Repr, but it
      still hasn't happened, and thus it's now seeming quite unlikely.)
      3c03a6d3
    • Eric Myhre's avatar
      Extract and DRY AssignNull method for most types. · ef17e649
      Eric Myhre authored
      This one turns out to be different betweens scalars and recursives,
      if in a small (and fortunately consistent) way.
      ef17e649
    • Eric Myhre's avatar
      More DRY'ing efforts in codegen. · f6cbe842
      Eric Myhre authored
      Some are easier than others.
      
      I'm starting to evolve a (still ad-hoc) naming convention for the
      extracted functions in order to provide some cues for how common you can
      expect the thing to be.  Scalars have a lot more commonizable stuff
      than non-scalars, for example.
      f6cbe842
    • Eric Myhre's avatar
      DRY EmitTypedNodeMethodRepresentation. · 83bf3c07
      Eric Myhre authored
      83bf3c07
  2. 24 Apr, 2020 2 commits
  3. 19 Apr, 2020 9 commits
    • Eric Myhre's avatar
      Terribly important character. Avoids alloc. · 66047ce9
      Eric Myhre authored
      With use of pointer here: overall benchmarks if marshalling or suchlike
      are perfectly reasonable and on par with the basicnode implementations
      (the biggest cost is getting iterators, which is similar in each).
      
      With the typo causing a copy and another heap escape: that extra alloc
      causes a zonking 10% slowdown on selected marshalling benchmark.
      
      (I'm using benchmarks on the 'realgen' package.  MapNStrMap3StrInt can
      be exercised now -- isn't that neat?  Suppose I'll commit that next.)
      66047ce9
    • Eric Myhre's avatar
      Recursive maps: works, and tested. · d52e2c27
      Eric Myhre authored
      Reset methods on assemblers were needed for this.  So far, we'd gotten
      along without these, because structs happen to not reuse assemblers
      between fields.  But we definitely do need them in general.
      
      It would've been possible to avoid having the reset methods on scalars,
      but it doesn't seem work the effort; it would save a line of GSLOC,
      but make absolutely no other practical difference, and also make the
      templates a fair sight more complicated.  So meh to that.
      d52e2c27
    • Eric Myhre's avatar
      Dry up emitNativeMaybe, and apply it everywhere. · 51460752
      Eric Myhre authored
      Also, hej: now recursive maps can be compiled!  (Previously they were
      stymied simply because the maybe emission hadn't been pasted in.)
      51460752
    • Eric Myhre's avatar
      Map gen now works. · fa8b487a
      Eric Myhre authored
      Through compilation, at least.  No functional tests yet written.
      
      Bunch of small fixes for maybe pointers.  (Somehow I had gotten their
      embedding in the entry struct wrong, and that kinda splashed all over.)
      
      The refactor of method names 'construct'->'fromString' also made a
      bunch of the generated map code line up, since it was already written
      to target that convention.
      
      Then it's just the matter of adding the tests that compile.
      
      And so far so good: combos of nullable values, not nullable,
      and maybe with or without use of pointers all appear to compile!
      fa8b487a
    • Eric Myhre's avatar
      Third checkpoint in progress towards map gen. · 81bdd932
      Eric Myhre authored
      This seems to be getting pretty close: the only compile errors left
      are about not finding "fromString" methods for key reification...
      which is of course sensible, because that's not what those methods
      have been called yet in the cases where they've shown up;
      and they also haven't been placed on type-level styles yet.
      
      So the next commit will be a little detour to touch over those methods
      formerly known as "construct" and update them a bit to this pattern.
      81bdd932
    • Eric Myhre's avatar
      Next checkpoint in progress towards map gen. · 2a347854
      Eric Myhre authored
      Fixes many issues with maybes.  Some minor typo-scale stuff; some
      pretty consequential.  What to do about speciated lookup methods
      still has big honking questions on it: returning a maybe there if
      you didn't already have data in that format can be *not cheap*.
      Figuring out the best DX there is gonna be interesting.
      
      Making progress on how to handle keys, but slow.  Complex keys are...
      well, really complex.  So far I've learned several things that *won't*
      work, which is fun.  It's looking unlikely that having a KeyAssembler
      type at all is actually going to be a good idea.
      2a347854
    • Eric Myhre's avatar
      Checkpoint first thrust of map gen features. · 5ed03b8c
      Eric Myhre authored
      Complex keys are a behemoth of a feature, and it's gonna take
      substantial effort to sort all of that out.
      5ed03b8c
    • Eric Myhre's avatar
      Fix safety in face of over-held child assemblers for struct fields that aren't maybes. · 65f49f76
      Eric Myhre authored
      (Ain't that a lovely bunch of conditions?)
      
      Previous comment in here missed an important case.
      65f49f76
    • Eric Myhre's avatar
      Fix some typos in kind errors. · d12324e7
      Eric Myhre authored
      d12324e7
  4. 16 Apr, 2020 1 commit
    • Eric Myhre's avatar
      Remove finish callback. Much faster. Bench. · 6d31b15f
      Eric Myhre authored
      If you've been following along for a while now, you don't need to see
      the benchmarks to know what's coming.  The long story short is:
      allocations are the root of all evil, and we got rid of some, and now
      things are significantly faster.
      
      Here's the numbers:
      
      basicnode (just for a baseline to compare to):
      
      ```
      BenchmarkMapStrInt_3n_AssembleStandard-8         1988986               588 ns/op             520 B/op          8 allocs/op
      BenchmarkMapStrInt_3n_AssembleEntry-8            2158921               559 ns/op             520 B/op          8 allocs/op
      BenchmarkMapStrInt_3n_Iteration-8               19679841                67.0 ns/op            16 B/op          1 allocs/op
      BenchmarkSpec_Marshal_Map3StrInt-8               1377094               870 ns/op             544 B/op          7 allocs/op
      BenchmarkSpec_Marshal_Map3StrInt_CodecNull-8     4560031               278 ns/op             176 B/op          3 allocs/op
      BenchmarkSpec_Unmarshal_Map3StrInt-8              368763              3239 ns/op            1608 B/op         32 allocs/op
      ```
      
      realgen, previously, using fcb:
      
      ```
      BenchmarkMapStrInt_3n_AssembleStandard-8         4293072               278 ns/op             208 B/op          5 allocs/op
      BenchmarkMapStrInt_3n_AssembleEntry-8            4643892               259 ns/op             208 B/op          5 allocs/op
      BenchmarkMapStrInt_3n_Iteration-8               20307603                59.9 ns/op            16 B/op          1 allocs/op
      BenchmarkSpec_Marshal_Map3StrInt-8               1346115               913 ns/op             544 B/op          7 allocs/op
      BenchmarkSpec_Marshal_Map3StrInt_CodecNull-8     4606304               256 ns/op             176 B/op          3 allocs/op
      BenchmarkSpec_Unmarshal_Map3StrInt-8              425662              2793 ns/op            1160 B/op         27 allocs/op
      ```
      
      realgen, new, improved:
      
      ```
      BenchmarkMapStrInt_3n_AssembleStandard-8         6138765               183 ns/op             129 B/op          3 allocs/op
      BenchmarkMapStrInt_3n_AssembleEntry-8            7276795               176 ns/op             129 B/op          3 allocs/op
      BenchmarkMapStrInt_3n_Iteration-8               19593212                67.2 ns/op            16 B/op          1 allocs/op
      BenchmarkSpec_Marshal_Map3StrInt-8               1309916               912 ns/op             544 B/op          7 allocs/op
      BenchmarkSpec_Marshal_Map3StrInt_CodecNull-8     4579935               257 ns/op             176 B/op          3 allocs/op
      BenchmarkSpec_Unmarshal_Map3StrInt-8              465195              2599 ns/op            1080 B/op         25 allocs/op
      ```
      
      So!  About 150% improvement on assembly between gen with fcb and our new-improved no-callback system.
      
      And about 321% improvement in total now for codegen structs over the basicnode map.
      
      That's the kind of ratio I was looking for :)
      
      As with all of these measurements: these will also get much bigger on bigger corpuses.
      Some of the improvements here are O(n) -> O(1), and some apply even more heartily in deeper trees, etc.
      But it's telling that even on very small corpuses, the impact is already huge.
      6d31b15f
  5. 07 Apr, 2020 1 commit
    • Eric Myhre's avatar
      Support for struct field rename directives. · 5f93c298
      Eric Myhre authored
      Some touches to ImplicitValue came along for the ride, but aren't
      exercised yet.
      
      Tests are getting unwieldy.  I think something must be done about
      this before proceding much further or it's going to start resulting
      in increasingly significant velocity loss.
      5f93c298
  6. 06 Apr, 2020 2 commits
  7. 01 Apr, 2020 8 commits
    • Eric Myhre's avatar
      Tests on gen output; some fixes; working. · 072098e6
      Eric Myhre authored
      I'm almost a little staggered.  We've got structures with maybes
      both using pointers and not, and everything seems fine.
      
      A few fixes were necessary, but they were mostly "d'oh" grade.
      (The finishCallback logic is a bit hairy, but appears correct now.)
      
      More cases for more variations in presence coming up next.
      072098e6
    • Eric Myhre's avatar
      Support maybe implemented using ptr. · 255bbc57
      Eric Myhre authored
      Easier than previous commit message seemed to think.
      
      Since we already have finishCallback functions in play in any scene
      where maybes can also be in play, we can just make those responsible
      for copying out a pointer from the child assembler to the parent value.
      That makes the child assembler able to create a new value late in
      its lifecycle and still expect it can land in a proper home.
      
      Tests needed badly; this is *oodles* of edge cases.
      Unrelated fix needed first.  (Might make that elsewhere and rebase
      this to include that, to reduce the carnage ever so slightly.)
      255bbc57
    • Eric Myhre's avatar
      Fix many issues with maybes; adjunct config for if maybe is implemented using... · 125a2a7f
      Eric Myhre authored
      Fix many issues with maybes; adjunct config for if maybe is implemented using a pointer; attempt the finishCallback system for reusable child assemblers.
      
      This... almost appears to be on a dang nice track.
      
      Except one fairly critical thing.  It doesn't work correctly if your
      maybe IS implemented as containing a pointer.
      
      Because that pointer starts life as nil in the parent structure.
      
      And that's hard to fix.
      
      We can't have a pointer to a pointer in the assembler;
      that'd cause the type bifructation we've been trying to avoid.
      (We can give up and do that of course; it would be correct.
      Just... more code and larger final assembly size.
      And if we did this, a lot of this diff would be rewritten.)
      
      We could have the parent structure allocate a blank of the field,
      and put a pointer to it in the maybe and also in the child assembler.
      Except... this is a wasted allocation if it turns out to be null.
      
      Rock and hard place detected in a paired configuration.
      Might have to back out of this approach entirely.  Not sure.
      125a2a7f
    • Eric Myhre's avatar
      Late night thoughts on reducing gen type count. · 896d0e57
      Eric Myhre authored
      We'll see how this works out.
      896d0e57
    • Eric Myhre's avatar
      ErrInvalidKey type, and use it. · 27873cb0
      Eric Myhre authored
      27873cb0
    • Eric Myhre's avatar
      Checkpoint of codegen'd struct assemblers. · fd94a062
      Eric Myhre authored
      Lots of tasty bitshuffling in this commit.
      
      Remaining: creating, embedding, and returning child value assemblers.
      This might involve a full type per field: doing so would be direct,
      have pretty excellent verbosity in debugging symbols,
      and pointers back to parent suffer no interface indirection;
      overall, it's probably going to have the fastest results.
      However, it would also mean: we can't save resident memory size if we
      have more than one field in a struct that has the same type;
      and we we can't avoid increasing binary size if the same types are used
      as fields in several places.
      Going to pause to think about this for a while.
      fd94a062
    • Eric Myhre's avatar
      Nicely composable NodeBuilderGenerator, +mixins. · 7ff42bd3
      Eric Myhre authored
      This cleans up a lot of stuff and reduces the amount of boilerplate
      content that's just generating monomorphizing error method stubs.
      
      The nodeGenerator mixins now also use the node mixins.  I don't know
      why I failed to do that from the start; I certainly meant to.
      It results in shorter generated code, and the compiler turns it into
      identical assembly.
      7ff42bd3
    • Eric Myhre's avatar
      Checkpoint of struct gen progress. · 80b0ba29
      Eric Myhre authored
      Compiles and runs; but the results don't.
      Some small issues; some big issues.  Just needed a checkpoint.
      
      It's feeling like it's time to deal with breaking down the assembler
      generators in the same way we did for all the node components, which
      is going to be kind of a big shakeup.
      80b0ba29
  8. 29 Mar, 2020 1 commit