新足迹

 找回密码
 注册

精华好帖回顾

· Aloha - 夏威夷欧胡岛亲子深度游 - Mahalo (2018-9-12) MU · [摄出你的足迹]-- 一条废驴的影像生活 (2013-1-13) autrant
· 征文活动: 做个快乐的推销员!! 简直太有才了 (2009-9-11) 太有才了 · 说说我溜猫的经历.-照片已经上了 (2009-4-6) suel
Advertisement
Advertisement
查看: 1829|回复: 11

[IT] csharp datatable performance is terrible [复制链接]

发表于 2022-9-1 12:51 |显示全部楼层
此文章由 DDD888 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 DDD888 所有!转贴必须注明作者、出处和本声明,并保持内容完整
我在11年前照抄公司经理的vb.net代码使用了DataTable在csharp代码里,现在发觉速度越来越慢,数据量大概是一千行数据,用到了点排序功能,根据我的经验,一千行数据并不是啥大数据啦,竟然用时要超过三秒,然后改成https://github.com/DapperLib/Dapper,彻底不使用DataTable, 只用List,速度就缩减到0.5秒,用了三天时间转代码,看来microsoft的东西真是不堪大用,垃圾

看来我选择使用rust language开发应用是明智的选择,微软的东西都藏着坑,一不小心就会掉进去
Advertisement
Advertisement

发表于 2022-9-1 13:49 来自手机 |显示全部楼层
此文章由 cppbug 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 cppbug 所有!转贴必须注明作者、出处和本声明,并保持内容完整
很明显你当年照抄的时候没有更进一步的搞清楚对于你的use case,DataTable是不是一个合适的数据结构。每一个技术都有他适用的地方,就好比你喜欢的rust,如果你一味的觉得他适用于各种项目,那十几年后你同样会对rust发出同样的感慨

发表于 2022-9-1 13:57 |显示全部楼层
此文章由 lhj0532 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 lhj0532 所有!转贴必须注明作者、出处和本声明,并保持内容完整
11年前照抄公司经理的vb.net

发表于 2022-9-1 14:03 |显示全部楼层
此文章由 DDD888 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 DDD888 所有!转贴必须注明作者、出处和本声明,并保持内容完整
本帖最后由 DDD888 于 2022-9-1 13:11 编辑
cppbug 发表于 2022-9-1 12:49
很明显你当年照抄的时候没有更进一步的搞清楚对于你的use case,DataTable是不是一个合适的数据结构。每一 ...


老板雇佣我的时候就是要vb.net windows desktop app convert to asp.net mvc website, 开发进度越快越好,当初花了大概两个月上线弄了第一个客户,那时候测试数据量很小,几十个数据啦,经过11年的网站的使用,增加了许多大客户,有的客户数据量就增加到一千多个啦,任何项目都是渐进的啦,不可能一步到位,例如一个十岁的小孩吃饭的碗不可能一开始就给个大男人吃饭的碗,所以你说没选择好component显然有失偏颇啦,更何况在11年前谁知道datatable有这种性能上的缺陷,关键microsoft还不改进,所以现在我只能不用datatable

我选择rust language做了十几个项目,感觉挺棒的呀,代码的性能都在可控之中,不像datatable像个大黑盒,谁知道里边是如何运作的呀

你提到rust language,我感觉我喜欢rust最大的好处就是不用调用free, delete而且没有内存管理虚拟机啦,既然基于这点,有许多程序都是可以用rust language例如要求精确控制响应延迟的股票,期货炒作软件啦,速度如果任由内存管理虚拟机控制,那是不可接受的啦

发表于 2022-9-1 18:45 |显示全部楼层
此文章由 fnf2000 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 fnf2000 所有!转贴必须注明作者、出处和本声明,并保持内容完整
呃,十几年前用datatable是正常的,现在即使抄,也应该知道不用这种老古董了吧。。。

发表于 2022-9-7 10:21 |显示全部楼层
此文章由 DDD888 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 DDD888 所有!转贴必须注明作者、出处和本声明,并保持内容完整
cppbug 发表于 2022-9-1 12:49
很明显你当年照抄的时候没有更进一步的搞清楚对于你的use case,DataTable是不是一个合适的数据结构。每一 ...

我发觉rust language编译出的结果依赖编译系统的glibc
https://kobzol.github.io/rust/ci ... th-older-glibc.html

google tensorflow docker image file是用的很老的版本的linux, 里面的glibc和我用的rust language 编译出来的程序glibc不支持,浪费了我一周时间来测试
Advertisement
Advertisement
头像被屏蔽

禁止发言

发表于 2022-9-7 12:02 |显示全部楼层
此文章由 InTheEnd 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 InTheEnd 所有!转贴必须注明作者、出处和本声明,并保持内容完整
楼主现在三句不离rust

发表于 2022-9-7 12:35 |显示全部楼层
此文章由 DDD888 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 DDD888 所有!转贴必须注明作者、出处和本声明,并保持内容完整
InTheEnd 发表于 2022-9-7 11:02
楼主现在三句不离rust

此所谓做啥爱啥

发表于 2022-9-7 13:17 来自手机 |显示全部楼层
此文章由 whoisit 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 whoisit 所有!转贴必须注明作者、出处和本声明,并保持内容完整
本帖最后由 whoisit 于 2022-9-7 12:27 编辑
DDD888 发表于 2022-9-1 13:03
老板雇佣我的时候就是要vb.net windows desktop app convert to asp.net mvc website, 开发进度越快越好 ...


您不要对虚拟机有什么偏见啦,什么慢啦,这个都看优化,坐飞机是快,但考虑到安检,机场地理位置比较偏远各种因素,不能把去机场的时间排除在外,高铁站都是在市区很快就到,安检也快,所以几百公里路程飞机不一定比高铁快,
看看大牛Jeffrey Richter怎么说managed app 可以比unmanaged app更快:
For those developers coming from an unmanaged C or C++ background, you’re probably thinking about the performance ramifications of all this. After all, unmanaged code is compiled for a specific CPU platform, and, when invoked, the code can simply execute. In this managed environment, compiling the code is accomplished in two phases. First, the compiler passes over the source code, doing as much work as possible in producing IL. But to execute the code, the IL itself must be compiled into native CPU instructions at run time, requiring more non-shareable memory to be allocated and requiring additional CPU time to do the work. Believe me, because I approached the CLR from a C/C++ background myself, I was quite skeptical and concerned about this additional overhead. The truth is that this second compilation stage that occurs at run time does hurt performance, and it does allocate dynamic memory. However, Microsoft has done a lot of performance work to keep this additional overhead to a minimum. If you too are skeptical, you should certainly build some applications and test the performance for yourself. In addition, you should run some nontrivial managed applications Microsoft or others have produced, and measure their performance. I think you’ll be surprised at how good the performance actually is. You’ll probably find this hard to believe, but many people (including me) think that managed applications could actually outperform unmanaged applications. There are many reasons to believe this. For example, when the JIT compiler compiles the IL code into native code at run time, the compiler knows more about the execution environment than an unmanaged compiler would know. Here are some ways that managed code can outperform unmanaged code: ■ A JIT compiler can determine if the application is running on an Intel Pentium 4 CPU and produce native code that takes advantage of any special instructions offered by the Pentium 4. Usually, unmanaged applications are compiled for the lowest-common-denominator CPU and avoid using special instructions that would give the application a performance boost  
  A JIT compiler can determine when a certain test is always false on the machine that it is running on. For example, consider a method that contains the following code. if (numberOfCPUs > 1) { ... } This code could cause the JIT compiler to not generate any CPU instructions if the host machine has only one CPU. In this case, the native code would be fine-tuned for the host machine; the resulting code is smaller and executes faster. ■ The CLR could profile the code’s execution and recompile the IL into native code while the application runs. The recompiled code could be reorganized to reduce incorrect branch predictions depending on the observed execution patterns. Current versions of the CLR do not do this, but future versions might.  

发表于 2022-9-7 13:22 |显示全部楼层
此文章由 ろげん 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 ろげん 所有!转贴必须注明作者、出处和本声明,并保持内容完整
DDD888 发表于 2022-9-7 11:35
此所谓做啥爱啥

楼主要不要自创一种比RUST还优秀的语言?

发表于 2022-9-7 13:24 |显示全部楼层
此文章由 DDD888 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 DDD888 所有!转贴必须注明作者、出处和本声明,并保持内容完整
本帖最后由 DDD888 于 2022-9-7 12:52 编辑
whoisit 发表于 2022-9-7 12:17
您不要对虚拟机有什么偏见啦,什么慢啦,看看大牛Jeffrey Richter怎么说,
For those developers coming  ...


我从2000年开发j2ee orion application server velocity java网站到2010年起开发asp.net mvc csharp网站,2014年起开发golang网站,已用了20年的三种虚拟机了,现在仍旧被asp.net csharp的虚拟机的慢困扰啦

我发觉使用了rust language actix web彻底解放了

我读了下你发的引用,这句是最重要的“Current versions of the CLR do not do this, but future versions might.  ”,显然所说都是废话,根本就不现实的,呵呵

这是随意搜的比较啦
https://medium.com/@dexthinks/co ... d-rust-fdb21bd5fb7c
Advertisement
Advertisement

发表于 2022-9-7 13:24 |显示全部楼层
此文章由 DDD888 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 DDD888 所有!转贴必须注明作者、出处和本声明,并保持内容完整
ろげん 发表于 2022-9-7 12:22
楼主要不要自创一种比RUST还优秀的语言?

不,我想有空还是用来赚钱比较好

发表回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Advertisement
Advertisement
返回顶部