Re: problem with gc?

2015-05-28 Thread zhmt via Digitalmars-d-learn
Thanks for all help.

Re: problem with gc?

2015-05-28 Thread zhmt via Digitalmars-d-learn
On Thursday, 28 May 2015 at 02:00:57 UTC, zhmt wrote: I think it is not problem of gc, it is my fault: The operations is serialized: clent send - server recv - server send - client recv, so if one operation takes too long time, the throughput will definitely fall down. I cant explain why

Re: problem with gc?

2015-05-27 Thread zhmt via Digitalmars-d-learn
On Wednesday, 27 May 2015 at 09:39:42 UTC, Anonymouse wrote: On Wednesday, 27 May 2015 at 08:42:01 UTC, zhmt wrote: When I enable the --profle, get something like this, it doesnt give me too much help: [...] Tried callgrind and kcachegrind? If nothing else it's better at illustrating the

Re: problem with gc?

2015-05-27 Thread zhmt via Digitalmars-d-learn
When I enable the --profle, get something like this, it doesnt give me too much help: Timer Is 3579545 Ticks/Sec, Times are in Microsecs Num TreeFuncPer CallsTimeTimeCall 1298756 4996649885 49875773773840

Re: problem with gc?

2015-05-27 Thread zhmt via Digitalmars-d-learn
@jklp And also you could try to surround the whole block with `GC.disable` and `GC.enable`. This would help to determine if the GC is involved: --- Ptr!Conn conn = connect(127.0.0.1,8881); GC.disable; ubyte[100] buf; string str; for(int i=0; iN; i++) { str = format(%s,i);

Re: problem with gc?

2015-05-27 Thread zhmt via Digitalmars-d-learn
What happened when the code changes a little? Who will give an explaination,Thanks a lot? what happend if you use sformat instead? Ptr!Conn conn = connect(127.0.0.1,8881); ubyte[100] buf; char[100] buf2; for(int i=0; iN; i++) { auto str = sformat(buf2, %s,i);

Re: problem with gc?

2015-05-27 Thread zhmt via Digitalmars-d-learn
If I pass a timeout with 1ms to epoll_wait,the cpu will not be busy when throughput falls down.

Re: problem with gc?

2015-05-27 Thread zhmt via Digitalmars-d-learn
It seems that dlang library is not so effient?

Re: problem with gc?

2015-05-27 Thread zhmt via Digitalmars-d-learn
On Wednesday, 27 May 2015 at 05:51:21 UTC, zhmt wrote: I noticed that the cpu% falls from 99% down to 4% as well when the throughput falls down. I tried again for several times, the cpu is still busy, 98.9%.

Re: problem with gc?

2015-05-27 Thread zhmt via Digitalmars-d-learn
I think it is not problem of gc, it is my fault: The operations is serialized: clent send - server recv - server send - client recv, so if one operation takes too long time, the throughput will definitely fall down. I cant explain why it so fast when buffer is big enough, and so low when

Re: problem with gc?

2015-05-27 Thread zhmt via Digitalmars-d-learn
On Wednesday, 27 May 2015 at 19:04:53 UTC, Márcio Martins wrote: On Wednesday, 27 May 2015 at 05:48:13 UTC, zhmt wrote: The code you posted is the client code, but the issue seems to be on the server side. Can you post the server code and also the timing code? @Márcio Martins here is

problem with gc?

2015-05-26 Thread zhmt via Digitalmars-d-learn
I am writing a echoclient, as below: Ptr!Conn conn = connect(127.0.0.1,8881); ubyte[100] buf; for(int i=0; iN; i++) { scope string str = format(%s,i); conn.write((cast(ubyte*)str.ptr)[0..str.length]); conn.read(buf[0..str.length]); n++; } conn.close(); When it

Re: problem with gc?

2015-05-26 Thread zhmt via Digitalmars-d-learn
I noticed that the cpu% falls from 99% down to 4% as well when the throughput falls down.

Re: Error: conflicting Ddoc and obj generation options

2015-05-05 Thread zhmt via Digitalmars-d-learn
Finally,I got the dmd command line as below: dmd -c -of.dub/build/application-debug-linux.posix-x86_64-dmd_2067-3E65324D543ED19695028F22620736D3/ezsock.o -debug -g -w -version=Have_ezsock -version=Have_gamelibd -Isource/ -I../gamelibd/source/ -Jviews source/app.d .. And try to remove

Re: dub building is extremely slow

2015-05-04 Thread zhmt via Digitalmars-d-learn
On Thursday, 30 April 2015 at 12:31:54 UTC, wobbles wrote: On Thursday, 30 April 2015 at 03:00:36 UTC, zhmt wrote: On Thursday, 30 April 2015 at 02:02:50 UTC, zhmt wrote: dub build is running on centos7. It works well until today, It becomes very slow suddenly. It will take minuties per

Error: conflicting Ddoc and obj generation options

2015-05-04 Thread zhmt via Digitalmars-d-learn
mono-d is running on centos7 with options below: first: { name: ezsock, targetType: executable, description: A minimal D application., copyright: Copyright © 2015, zhmt, authors: [zhmt], mainSourceFile: source/app.d, dependencies: {

dub building is extremely slow

2015-04-29 Thread zhmt via Digitalmars-d-learn
dub build is running on centos7. It works well until today, It becomes very slow suddenly. It will take minuties per compilation, there is 10 files in project. Has anyone experienced this?

Re: dub building is extremely slow

2015-04-29 Thread zhmt via Digitalmars-d-learn
On Thursday, 30 April 2015 at 02:02:50 UTC, zhmt wrote: dub build is running on centos7. It works well until today, It becomes very slow suddenly. It will take minuties per compilation, there is 10 files in project. Has anyone experienced this? It is because: The dub will connect to some

Re: How to connect asynchronously (non block) with kqueue?

2015-03-24 Thread zhmt via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 12:25:14 UTC, Etienne wrote: On 3/24/2015 5:50 AM, zhmt wrote: I am using kqueue on macosx, I know how to write a simple server. But don't know which event will be triggered in kqueue when connected successfully , which event when failed? EVFILT_READ or

How to connect asynchronously (non block) with kqueue?

2015-03-24 Thread zhmt via Digitalmars-d-learn
I am using kqueue on macosx, I know how to write a simple server. But don't know which event will be triggered in kqueue when connected successfully , which event when failed? EVFILT_READ or EVFILT_WRITE? I have googled this question, got no examples, any suggestions are welcome, Thanks.

Re: how to pass a ubyte[] to c interface?

2015-03-13 Thread zhmt via Digitalmars-d-learn
On Friday, 13 March 2015 at 06:39:31 UTC, Rikki Cattermole wrote: On 13/03/2015 7:35 p.m., zhmt wrote: ubyte[] arr ; I pass the arr.ptr to c program, it fails silently. Is there any way to cast a ubyte[] to a clang pointer? Theoretically this should work. D: void func(ubyte[] value) {

how to pass a ubyte[] to c interface?

2015-03-13 Thread zhmt via Digitalmars-d-learn
ubyte[] arr ; I pass the arr.ptr to c program, it fails silently. Is there any way to cast a ubyte[] to a clang pointer?

Re: how to pass a ubyte[] to c interface?

2015-03-13 Thread zhmt via Digitalmars-d-learn
I have some source code of vibe.d, it does this in the same way, and it works . void read(ubyte[] dst) { checkConnected(false); acquireReader(); scope(exit) releaseReader(); while (dst.length 0) {

Re: how to pass a ubyte[] to c interface?

2015-03-13 Thread zhmt via Digitalmars-d-learn
On Friday, 13 March 2015 at 06:56:33 UTC, Ali Çehreli wrote: On 03/12/2015 11:35 PM, zhmt wrote: ubyte[] arr ; I pass the arr.ptr to c program Unless there is sentinel value at the end of the array, you must also pass the number of elements (as Rikki Cattermole has shown). However, if

How to reference another dub project?

2015-03-13 Thread zhmt via Digitalmars-d-learn
I have two dub projects, one is library, the other one is app. The library is referenced by the app. How to reference it in dub.json? I found the subPackage, It does not meet my needs exactly.

Re: How to reference another dub project?

2015-03-13 Thread zhmt via Digitalmars-d-learn
On Friday, 13 March 2015 at 08:24:11 UTC, zhmt wrote: I have two dub projects, one is library, the other one is app. The library is referenced by the app. How to reference it in dub.json? I found the subPackage, It does not meet my needs exactly. I got it: dependencies: {

Re: How to find the cause of crash?

2015-03-12 Thread zhmt via Digitalmars-d-learn
I want to know how to locate the position of crashing in dlang? for example: there is stack dump in c, exception stack in java, they could help to locate the root of problems.

vibe.d crashs when forwarding a stream to another?

2015-03-12 Thread zhmt via Digitalmars-d-learn
I posted in vibe.d forum, no one replied . Help me please: http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/24458/

How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
I developed a socks5 proxy server with vibe.d. but it crashed after running a few minutes, with the output below: Task terminated with uncaught exception: Operating on closed TCPConnection. Task terminated with uncaught exception: Operating on closed TCPConnection. Task terminated with

Re: How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 10:13:12 UTC, Théo Bueno wrote: On Wednesday, 11 March 2015 at 08:16:17 UTC, zhmt wrote: Now , my question is: How to get the position it crashes? Or get the method call stack? If you are developing under Linux, you can use GDB to debug your D apps, just like

Re: How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 11:09:42 UTC, Daniel Kozák wrote: On Wed, 11 Mar 2015 10:05:39 + zhmt via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I want to know how to locate the position of crashing in dlang? for example: there is stack dump in c, exception stack

Re: How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 08:16:17 UTC, zhmt wrote: I developed a socks5 proxy server with vibe.d. but it crashed after running a few minutes, with the output below: Task terminated with uncaught exception: Operating on closed TCPConnection. Task terminated with uncaught exception:

Re: How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 10:13:12 UTC, Théo Bueno wrote: On Wednesday, 11 March 2015 at 08:16:17 UTC, zhmt wrote: Now , my question is: How to get the position it crashes? Or get the method call stack? If you are developing under Linux, you can use GDB to debug your D apps, just like

Re: how to read some in vibe.d tcpconnection?

2015-03-09 Thread zhmt via Digitalmars-d-learn
On Sunday, 8 March 2015 at 13:56:37 UTC, Kagamin wrote: On Sunday, 8 March 2015 at 03:09:00 UTC, zhmt wrote: Yes, this a good idea, if the author of vibe.d do this, will be better, it is used frequently in many scenes. You can do it too, unlike in C++, in D you can write extension methods to

Re: how to read some in vibe.d tcpconnection?

2015-03-07 Thread zhmt via Digitalmars-d-learn
On Saturday, 7 March 2015 at 09:39:42 UTC, Kagamin wrote: On Saturday, 7 March 2015 at 02:23:10 UTC, zhmt wrote: Hi,I got the right answer in vibe.d forum,here is the link: http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/24403/#post-24416 If that's correct, you can

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
Hi,I got the right answer in vibe.d forum,here is the link: http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/24403/#post-24416

how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
TCPConnecion has a read method, which will block untill the buf is fully filled. This is not what I want. I want a readSome method, which will return if some data comes from remote end, and notify the length of data to me. so I can process data in time. what should I do ?

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
There should be a function called DataAvilable. Simply read the data if this function returns true Thanks you! But the DataAvilable just return a bool value, so I dont know the available data size, I cant call the read method simply. Is there more info to solve this problem?

Re: I want to introduce boost_asio to dlang

2015-03-06 Thread zhmt via Digitalmars-d-learn
On Friday, 6 March 2015 at 09:30:51 UTC, ketmar wrote: On Fri, 06 Mar 2015 01:19:40 +, zhmt wrote: Thanks for all the suggestions and pointing the right direction,I will learn and try vibe.d, try to use it in my gameserver. i've seen people using vibe.d to write warcraft server, so it's

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
I am forwarding data from client to another server, if the client send data to server,I want to forward that to another server in time. So, if the server recieves nothing it will wait, if it receive some data , forward them to another server immediately. I dont think the TCPConnecion.read

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
Take a look at empty and leastSize. https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/stream.d#L33 @Rikki Cattermole Thanks for your reply, but it is not what I want, and I cant implement my goal with them. in boost::asio, It has a method like this :

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
On Friday, 6 March 2015 at 20:03:52 UTC, Ola Fosheim Grøstad wrote: On Friday, 6 March 2015 at 19:33:56 UTC, zhmt wrote: On Friday, 6 March 2015 at 18:40:28 UTC, Kagamin wrote: I'd say, peek is the right method, it returns what's already in the buffer (but doesn't read), while leastSize

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread zhmt via Digitalmars-d-learn
On Friday, 6 March 2015 at 18:40:28 UTC, Kagamin wrote: I'd say, peek is the right method, it returns what's already in the buffer (but doesn't read), while leastSize returns full logical size of the stream. The api of vibe.d is too simple to use in real work.

Re: I want to introduce boost_asio to dlang

2015-03-05 Thread zhmt via Digitalmars-d-learn
On Thursday, 5 March 2015 at 08:22:33 UTC, Jack Applegame wrote: On Thursday, 5 March 2015 at 06:05:56 UTC, zhmt wrote: I am a gameserver developer, my programming lang is java now. I want to change java to dlang, and I like boost_asio and it's coroutine, so, I want to create a binding of

Re: how to write a string to a c pointer?

2015-03-05 Thread zhmt via Digitalmars-d-learn
On Thursday, 5 March 2015 at 09:42:53 UTC, Kagamin wrote: string s; char[] b = cast(char[])asArray(); b[0..s.length] = s[]; Thank you very much. I should stop my developing , and read the dlang tutorial again.

Re: I want to introduce boost_asio to dlang

2015-03-05 Thread zhmt via Digitalmars-d-learn
Thanks for all the suggestions and pointing the right direction,I will learn and try vibe.d, try to use it in my gameserver.

how to write a string to a c pointer?

2015-03-04 Thread zhmt via Digitalmars-d-learn
I am writing a asio binding. Objects need to be serialized into a buffer (void *), for example, write utf8 string into buffer, write int into buffer, write long into buffer, Here is my class class Buffer { private void *ptr; private int size; private int _cap;

I want to introduce boost_asio to dlang

2015-03-04 Thread zhmt via Digitalmars-d-learn
I am a gameserver developer, my programming lang is java now. I want to change java to dlang, and I like boost_asio and it's coroutine, so, I want to create a binding of boost_asio. But I am not familiar with dlang, so I want to find someone help me, or develope this binding with me. I

Re: Why hibernated does not create tables automatically?

2015-02-12 Thread zhmt via Digitalmars-d-learn
how to update table schema automatically: this() { mdb = new MysqlDB(connStr); auto conn = mdb.lockConnection(); scope(exit) conn.close(); MysqlOrmUtil.updateTableSchema!(Customer)(conn);

Re: Why hibernated does not create tables automatically?

2015-02-12 Thread zhmt via Digitalmars-d-learn
here is how to use: @UniqueIndex(id,[id]) class Card { @NotNull() @Auto() long id; string pwd; long agentId; bool valid; long rmb; long createDate; long soldDate; long chargeDate; } public Card[]

Re: Why hibernated does not create tables automatically?

2015-02-12 Thread zhmt via Digitalmars-d-learn
finally ,I write a orm tool to replace hibernated, it is simple, and it is easy to use, and every thing in control. It is free to copy ,improve. module mysqlormutil; import vibe.d; import std.stdio; import mysql.connection; import mysql.db; struct NotNull { } struct Auto { } struct

Re: Why hibernated does not create tables automatically?

2015-02-06 Thread zhmt via Digitalmars-d-learn
I have submit an issue on github, hope that the author could help me.

Re: Why hibernated does not create tables automatically?

2015-02-06 Thread zhmt via Digitalmars-d-learn
class Card { import hibernated.core; @Id @Generated long id; @UniqueKey string pwd; } MySQLDriver driver = new MySQLDriver(); string url = MySQLDriver.generateUrl(10.211.55.10, 3306, test); string[string] params =

Why hibernated does not create tables automatically?

2015-02-06 Thread zhmt via Digitalmars-d-learn
The app compiles fine, but It throw an exception when I try to save data to mysql : hibernated.type.MappingException@../../../zhmt/.dub/packages/hibernated-0.2.19/source/hibernated/metadata.d(3332): Cannot find entity by class ezsockacount.Dao.Customer My initialization code is something

Re: Why hibernated does not create tables automatically?

2015-02-06 Thread zhmt via Digitalmars-d-learn
Hi,Arjan,Thx for your replies, I have tried your suggestion, MySQLDriver driver = new MySQLDriver(); string url = MySQLDriver.generateUrl(10.211.55.10, 3306, test); string[string] params = MySQLDriver.setUserAndPassword(root, xxx); auto ds = new

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
The behavior of array is more or less unpredictable. If it is always a reference like class , it will be more predictable.

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
Sorry, I misunderstand the meaning of array pointer, it is not equals to arr.ptr. The array pointer meets my need perfectly . Ignore my replies above, Sorry!!!

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
Will arr.ptr change in the future? As the array add more members , it need more memroy, then remalloc may be called, the pointer maybe change, then the stored pointer will be invalid. Will this happen?

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
On Thursday, 5 February 2015 at 08:58:47 UTC, bearophile wrote: zhmt: Will arr.ptr change in the future? As the array add more members , it need more memroy, then remalloc may be called, the pointer maybe change, then the stored pointer will be invalid. Will this happen? Yes, it can

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
On Thursday, 5 February 2015 at 10:12:47 UTC, wrote: On Thursday, 5 February 2015 at 06:58:09 UTC, Ali Çehreli wrote: On 02/04/2015 10:42 PM, zhmt wrote: Here is a simple code snippet: With this approach, the allocation of `arr` itself is often clumsy and error-prone. In this case it is

Re: how can I get a reference of array?

2015-02-04 Thread zhmt via Digitalmars-d-learn
void test(ref int[] arr) { arr ~= 4; } It is something like ref variables. But ref just be used in function declaration.

Re: how can I get a reference of array?

2015-02-04 Thread zhmt via Digitalmars-d-learn
@Ali I know the direction now, I should learn more about the pointers. Thx very much.

how can I get a reference of array?

2015-02-04 Thread zhmt via Digitalmars-d-learn
Here is a simple code snippet: class A { public int[] arr; } class B { public int[] arr; } void main() { int[] arr; A a = new A; B b = new B; a.arr = arr; b.arr = arr; arr ~= 1; arr ~= -2; foreach(data; a.arr)

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
Anybody help?

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
void getT(SRC,DEST)(SRC src,DEST dest) { foreach (i, type; typeof(SRC.tupleof)) { string name = SRC.tupleof[i].stringof; __traits(getMember, dest, name) = __traits(getMember, src, name); writeln(name); } } when I write the code above, the

How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
I have a struct created by thrift: struct Card { long id; string pwd; long agentId; bool valid; long rmb; long createDate; long soldDate; long chargeDate; mixin TStructHelpers!([ TFieldMeta(`id`, 1, TReq.OPTIONAL), TFieldMeta(`pwd`, 2, TReq.OPTIONAL),

Re: shared Variant[string]

2015-01-28 Thread zhmt via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 10:16:02 UTC, Fyodor Ustinov wrote: Hi! Simple program: import std.variant; shared Variant[string] t; void main() { t[t] = bebebe; } Without shared this program compiles and works. With shared I get: aa.d(6): Error: template

Re: shared Variant[string]

2015-01-28 Thread zhmt via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 10:32:56 UTC, Fyodor Ustinov wrote: On Wednesday, 28 January 2015 at 10:20:42 UTC, zhmt wrote: try __gshared It seems to me - is not the solution, it's a hack. I want to understand what the happening. :) I am new to D. But I that error yesterday, and it's

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
The final version works well: void copyObj(SRC,DEST)(ref SRC src,ref DEST dest) { foreach (i, type; typeof(SRC.tupleof)) { __traits(getMember, dest, SRC.tupleof[i].stringof) = __traits(getMember, src, SRC.tupleof[i].stringof); } } thank u , @Marc Schütz .

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
Thx very much for all the help, I will try.

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 14:59:52 UTC, Ali Çehreli wrote: name must be 'enum': On 01/28/2015 06:34 AM, zhmt wrote: void getT(SRC,DEST)(SRC src,DEST dest) { foreach (i, type; typeof(SRC.tupleof)) { string name = SRC.tupleof[i].stringof; enum name =

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 23:34:10 UTC, Chris Williams wrote: On Wednesday, 28 January 2015 at 09:44:29 UTC, zhmt wrote: Sometime , I need to copy them: thrift.Card tc; db.Card dc; dc.id = tc.id; dc.pwd = tc.pwd; ... It is boring coding, I want a solution to copy them

Re: why there is no TBase in thrift for dlang?

2015-01-27 Thread zhmt via Digitalmars-d-learn
sorry , I am quite new to dlang.

Re: why there is no TBase in thrift for dlang?

2015-01-27 Thread zhmt via Digitalmars-d-learn
I resovled it by Generic programming : private const (ubyte)[] serialObj(T) (T obj) { TMemoryBuffer trans = new TMemoryBuffer(); auto prot = new TCompactProtocol!TMemoryBuffer(trans); obj.write(prot); return

why there is no TBase in thrift for dlang?

2015-01-27 Thread zhmt via Digitalmars-d-learn
I am writing code below: private Cmd deserialCmd(ubyte[] data) { Cmd ret; TMemoryBuffer trans = new TMemoryBuffer(data); auto prot = new TCompactProtocol!TMemoryBuffer(trans); ret.read(prot); return ret;