question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for more than 32 shared structures

See original GitHub issue

I created a file that walks through all the possible messages that I have in a system that i’m building. I expected the code below to create the complete structure but it’s only generated for the first 32 message. the structure for messages from tp: 38 are not being generated.

here the exampleMessages from the file: https://www.npoint.io/docs/94e158745cdd8c21f296

import { exampleMessages } from './message/examples';
import * as fs from 'fs';
import { Packr } from 'msgpackr';

const packr = new Packr(
  {
    getStructures() {
      return JSON.parse(fs.readFileSync('./message/structure.json', 'utf8'));
    },
    saveStructures(structures) {
      console.log('create structures', structures);
      fs.writeFileSync('./message/structure.json', JSON.stringify(structures));
    }
  }
);

const main = async  () => {
  for (const exampleMessage of exampleMessages) {
    packr.encode(exampleMessage)
  }

  await new Promise((resolve, _reject) => {
    setTimeout(() => {
      resolve('finish timeout')
    }, 10000)
  })
}

main()

console.log('We created the structure for your messages');

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kriszypcommented, Jul 30, 2021

Yes, it is by design. The idea is that data may have often have commonly used structures and may also have rarer structures or objects composed of more dynamic keys. And with a limit of shared structures, we can hopefully capture most of the commonly used structures while still being resilient to overloading the shared structures with rare/ad-hoc structures, which may not be reused (or reused infrequently).

This design is also motivated by how structures are encoded. When record structures are enabled and defined, msgpackr defines records with byte encodings that replace the byte encodings for the expansive (I think excessively) range of bytes used for positive integers (0-127). There are 128 some byte encodings available, and I didn’t want to replace the most commonly used positive integers, 0-63, so 64 - 127 are used for records. Of these half (32) are allocated to shared use, and half reserved for use within individual encodings (once you have used up the shared ones, you still want ids available for use within individual data structures).

There are certainly more sophisticated techniques that could be used for differentiating between shared and private structures, but more sophisticating tracking would likely involve more code complexity and could reduce performance. This technique also benefits from being very deterministic.

That being said, probably one of the most straightforward and biggest improvements for situations where there are a lot of data structures that would benefit from being shared, would be to simply allow for two (or more) byte encodings of record ids, which would provide space for vastly more record ids and shared record structures.

Of course, your request to have more flexibility in potentially specifying more shared structures and/or use two byte encodings for more shared structures is quite reasonable, and something I did actually intend to implement at some point. So, I guess I will get to work on adding that 😃.

1reaction
kriszypcommented, Aug 1, 2021

It is a work in progress, definitely not done or even working at all yet.

On Sun, Aug 1, 2021, 8:09 AM Bob Singor @.***> wrote:

@kriszyp https://github.com/kriszyp I see you did this commit. Is this already a working version? Or work in progress?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kriszyp/msgpackr/issues/33#issuecomment-890527588, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAIKBSMEJIKWV7DW5L3SLLT2VIQRANCNFSM5BJLHZVQ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exchange 2016 CU18 (Any Limitation for Shared Mailbox ...
Outlook is limited to displaying only the first 32 entries (If a delegate user has an archive, the user counts as 2 entries)....
Read more >
View Shared Subfolders in an Exchange Mailbox
In Outlook 2013 and 2016, use the Sharing invitation to share calendar folders. Right click on the folder you want to share and...
Read more >
Adding a shared mailbox to the 'From' field in Outlook 2016 ...
Adding a shared mailbox to the 'From' field in Outlook 2016 for Windows. Shared mailboxes allow a group of users to view and...
Read more >
Multiple Exchange accounts limit
If you for some reason need to add more than 10 Exchange accounts to your mail profile, you can extend this limit to...
Read more >
C++ Core Guidelines - GitHub Pages
Many of the rules are designed to be supported by an analysis tool. Violations of rules will ... of a library can be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found