Marko Tasic Profile picture
Feb 4 8 tweets 2 min read
In C implementation of #colony #colang, every object has two fields, 64bit kind and 64bit value. Which means that we spend 2 64bit registers just present single value in case of primitive values such as bool, u8, u32, u64, i64, f64.
In case of GC'ed objects such as generic, array, dict, struct, union, and so on, we need indirection because these "structures" simply require more space. But in case of everything above, I think we can do better.
Perhaps, for abstract types we can move RC in "type" field, and limit mac RC count to 2 **56 which is quite large number, and currently good enough for our GC needs.
Once I wrote all of this, I think actually that this is potential premature optimization.

I need more time to experiment around this to justify such a change.
However, place where is practical benefit is with short bytes and str objects. They might fit into 128bits. We need 8bits for kind field, in case of bytes/str, since they are immutable and short, spend rest of 120bits which is 15 bytes, or 3-15 chars unicode str.
For example, long meta-programming attribute that I am aware is "__generic_get_attr__" which is 20 bytes/chars. However, if we have special form for meta-programming strings, we can assume they start and end with "__" which means that we need 16 bytes.
"__generic_get_attr__" or "generic_get_attr" is one byte above our limit, so I might need to think of shorter version such as 15 bytes "generic_getattr" or even 14 bytes "genericgetattr". User will still type "__generic_get_attr__", but it can be recognized and stiped down.
Working with these kind of strings is quite frequent and benefit could be huge.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Marko Tasic

Marko Tasic Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @mtasic85

Feb 4
In #colony #colang, bytes type is really not required as primitive type. str type should exist since it is unicode and mostly used by developers. However, bytes can be represented as Array<u8>.
Since #colony #colang is GC'ed using Reference Counting, refcount, or RC, we can introduce special kind of references called "immortal references" and an example is `bytes: type = Array<u8>`. This should be implementation detail and not exposed to developers.
Immortal objects are GC'ed. So, incref or decref is almost fast as NOP. It will need to check flag on object and determine if object is immortal. Immortal means it stays forever alive while programming is being executed.
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(