ServiceStack benchmark continued: why does persisting a simple (complex) to JSON slow down SELECTs?

前端 未结 1 1009
南笙
南笙 2021-01-22 07:19

I would like to switch over to OrmLite, and I need to figure out if it is slow, and if so, why.

In my research, I come to the conclusion that complex objects, that in Or

相关标签:
1条回答
  • 2021-01-22 07:28

    I've managed to download and profile this solution which highlighted the cause of the issue of not caching the type accessors of late-bound types which is resolved with this commit.

    With this change performance for loading 10000 rows with complex types reduced from 11,765ms to 669ms (on my iMac 5k) as seen below:

    This change is available from v5.1.1 that's now available on MyGet.

    Note: I've removed the JsConfig.IncludeTypeInfo line below:

    JsConfig.IncludeTypeInfo = true;
    

    Which forces the Serializers to emit type info for every object which increases the payload size and decreases performance. ServiceStack.Text will already emit the type info when it's needed, i.e. for object, interfaces and abstract classes, so you should rarely force it yourself unless it's absolutely needed, as it can have a major detrimental impact on performance.

    Ideally your DTO's should not use interfaces, late-bound objects or inheritance but if you are consider making the base types abstract to force the type info to only where it's needed, instead of always emitting them.

    0 讨论(0)
提交回复
热议问题