Jump to content
Erik@Grijjy

An XML DOM with just 8 bytes per node

Recommended Posts

@Erik@Grijjy

Great stuff, thanks for that.

 

What is your next project, are you going to implement similar structure to the JSON parser ? :classic_blush:

Share this post


Link to post
Guest

Great article and neat library, thank you !

Now, i wonder if a memory manager is next on your workshop desk ?
I genuinely think it is a matter of when, not if.

Share this post


Link to post
49 minutes ago, Rollo62 said:

@Erik@Grijjy

Great stuff, thanks for that.

 

What is your next project, are you going to implement similar structure to the JSON parser ? :classic_blush:

Glad you like it! Could be interesting to see if this can by applied to JSON as well. Wouldn't want to break the existing API though...

Share this post


Link to post
43 minutes ago, Kas Ob. said:

Great article and neat library, thank you !

Now, i wonder if a memory manager is next on your workshop desk ?
I genuinely think it is a matter of when, not if.

Happy to hear! Don't know about creating a memory manager though. Very advanced stuff. And there are already some pretty good 3rd party memory managers out there.

Although it would be nice to have a high performance memory manager for mobile platforms as well. Maybe something like Microsoft's Mimalloc.

Share this post


Link to post

Very interesting library! I am used to use SimpleXML, but if your library is really that fast, I will definitely switch to it. SimpleXML supports ANSI encoding to reduce memory usage, but I think it will not be too difficult to add ANSI to Neslib.Xml.

 

Converting one of my program from SimpleXML to Neslib.Xml was not difficult, but I ran into an exception EIntOverflow in the procedure TXmlPointerMap.Map. Call stack is:

Quote

Neslib.Xml.Types.TXmlPointerMap.Map($406FDB,4765096,$19FDF8)
Neslib.Xml.Types.TXmlPointerMap.Map($B50FF0,0,$B51008)
Neslib.Xml.TXmlAttribute.SetNext(($B51008))
Neslib.Xml.TXmlNode.InternalAddAttribute(5,'4')
Neslib.Xml.TXmlNode.AddAttribute('check2','4')
ExportToXml.DoExportToXml($27E1AF0,TXmlDocument($27D3604) as IXmlDocument)
ExportToXml.ExportToXml

I was able to make a truncated test project to demonstrate the exception, please look at the attachment.

 

P.S. And thank you for the insightful article. I like this type of optimizations!

 

Test Export To XML.zip

Edited by Kryvich

Share this post


Link to post
8 minutes ago, Kryvich said:

Converting one of my program from SimpleXML to Neslib.Xml was not difficult, but I ran into an exception EIntOverflow in the procedure TXmlPointerMap.Map.

Glad you like it, and thanks for pointing out this issue. It only happens when you compile with Overflow Checking turned on. The hash functions I use should be compiled with overflow checking turned off, so I just added an {$OVERFLOWCHECKS OFF} directive to the Neslib.Xml.Types unit. Could you pull the latest version and try again?

  • Like 1

Share this post


Link to post

Yes, I can now export my data to XML. The resulting XML looks similar to what I get with SimpleXML. I will test it further.

Thank you!

 

  • Like 1

Share this post


Link to post
2 hours ago, Erik@Grijjy said:

Glad you like it, and thanks for pointing out this issue. It only happens when you compile with Overflow Checking turned on. The hash functions I use should be compiled with overflow checking turned off, so I just added an {$OVERFLOWCHECKS OFF} directive to the Neslib.Xml.Types unit. Could you pull the latest version and try again?

Would be nice to localise the disabling of overflow checks to just the hashing routines. 

  • Like 4

Share this post


Link to post
6 minutes ago, David Heffernan said:

Would be nice to localise the disabling of overflow checks to just the hashing routines. 

Your wish is my command. Guess I was a bit lazy earlier...

Pushed an updated for this.

  • Like 3
  • Thanks 2

Share this post


Link to post

I just felt like with the best cow of the dairy-farm which gives 40 liters of milk then knocks over the bucket.

Can't compile the code because of the inline variables 😕

Share this post


Link to post
1 minute ago, Attila Kovacs said:

Can't compile the code because of the inline variables 😕

Then maybe now is a good time to upgrade to the latest Delphi version😉

  • Haha 1
  • Sad 2

Share this post


Link to post
7 hours ago, balabuev said:

The price is - you cannot have DOMs, smaller than the OS memory page (4KB).

True, but for such small DOMs, memory isn't the issue anyway, so the overhead is negligible. Although you still get the advantage of reduced memory fragmentation though...

Share this post


Link to post

Just as an idea:

FFreeList can be implemented as a linked list, without any additional allocations.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×